Microprocessors: From Assembly Language to C Using thePIC18Fxx2

| 1. | The M file option to the HI-TECH PICC-18 compiler produces a map file that specifies the memory locations of functions and variables. Compile the ledf lash. c code with full optimization and give the locations of functions main() and a_delay(). Examine the compiled code for a_delay() and determine the memory location reserved for variable i (Hint: The auto variable i is not listed in the variable map, so import the hex file into MPLAB and look for the code that initializes i in the for{} loop). |
|
| 2. | Create a test program whose main() contains the code given in this problem. Compile this program with full optimization and without, and use the MPLAB StopWatch to determine the accuracy of the DelayMs(1) delay for a clock frequency of 40 MHz. (Hint: Find the code that implements the statement PORT = ~PORTB and put a breakpoint at this location.) while(1){ DelayMs(1); PORTB = -PORTB;} |
|
| 3. | Compile ledflash.c with and without optimization and compare the code (memory used for instructions) and data sizes (memory used for variables). |
|
| 4. | Modify the a_delay() function of the ledflash.c code to use DelayMs() to implement a delay that flashes the LED two times per second. |
|
| 5. | What is the maximum parameter value that can be used with the DelayUs() macro of Figure 8.6 for FOSC = 30 MHz? |
|
| 6. | In the schematic of Figure 8.4, erratic... |