Exercise 5: Developing an Embedded Application Write a software application to run on the system that we built in the previous exercise Compile the code using Altera Monitor Program Run the program and examine some debugging features of the Altera Monitor Program 1
Application Code (/exercise5/fpga_gpio.c) 2 Read switches and display on LEDs and 7-Segs int main(void)( volatile int * LEDs = (int *) 0xFF200000; volatile int * HEX3_HEX0= (int *) 0xFF200020; volatile int * SW_switch= (int *) 0xFF200040; int hex_conversions[16]= {0x3F,..., 0x71}; while(1) { int value= *SW_switch; *LEDs= value; int first_digit= value & 0xF; int second_digit= (value >> 4) & 0xF; int third_digit= (value >> 8) & 0xF; int hex_value= hex_conversions[first_digit]; hex_value|= hex_conversions[second_digit] << 8; hex_value|= hex_conversions[third_digit] << 16; *HEX3_HEX0= hex_value; }
Application Code (/exercise5/fpga_gpio.c) 3 Read switches and display on LEDs and 7-Segs int main(void)( volatile int * LEDs = (int *) 0xFF200000; volatile int * HEX3_HEX0= (int *) 0xFF200020; volatile int * SW_switch= (int *) 0xFF200040; int hex_conversions[16]= {0x3F,..., 0x71}; while(1) { int value= *SW_switch; *LEDs= value; int first_digit= value & 0xF; int second_digit= (value >> 4) & 0xF; int third_digit= (value >> 8) & 0xF; int hex_value= hex_conversions[first_digit]; hex_value|= hex_conversions[second_digit] << 8; hex_value|= hex_conversions[third_digit] << 16; *HEX3_HEX0= hex_value; }
Application Code (/exercise5/fpga_gpio.c) 4 Read switches and display on LEDs and 7-Segs int main(void)( volatile int * LEDs = (int *) 0xFF200000; volatile int * HEX3_HEX0= (int *) 0xFF200020; volatile int * SW_switch= (int *) 0xFF200040; int hex_conversions[16]= {0x3F,..., 0x71}; while(1) { int value= *SW_switch; *LEDs= value; int first_digit= value & 0xF; int second_digit= (value >> 4) & 0xF; int third_digit= (value >> 8) & 0xF; int hex_value= hex_conversions[first_digit]; hex_value|= hex_conversions[second_digit] << 8; hex_value|= hex_conversions[third_digit] << 16; *HEX3_HEX0= hex_value; }
Program Behaviour 5
6
Step 1: Start Altera Monitor Program 7
Step 2: Create a New Project 8 Sets up the Altera Monitor Program Select files to work with Specify target system
Step 2.1: Specify name, directory and architecture 9
Step 2.2: Select a Custom System 10
Step 2.3: Select Program Type 11
Step 2.4: Add Source File 12
Step 2.5: Set Board Connection and Select Processor 13
Step 2.6: Leave Default Memory Settings 14
Step 3: Program the FPGA with the Custom System 15
Step 4: Compile and Load 16 Compile your C language program Load the compiled code into the memory on the DE1-SoC board
Step 5: Examine the Window Contents 17
Step 5: Examine the Window Contents 18 Disassembly
Step 5: Examine the Window Contents 19 Registers
Step 5: Examine the Window Contents 20 Info & Error Msgs
Step 5: Examine the Window Contents 21 Terminal
Step 6: Run the Program and Toggle Switches on Board 22
Step 7: Pause the Processor 23
Step 8: Go to 0xff in Memory Window
Step 9: Read PIO Registers (Right Click) 25
Step 9: Examine Values 26
Step 10: Alter the Red LED PIO Register (Double Click) 27
Step 11: Test Other Features 28 Single Step
Step 11: Test Other Features 29 Breakpoints
Step 11: Test Other Features 30 Restart Program
Step 12: Disconnect 31