Page 189 - Programming Microcontrollers in C
P. 189
174 Chapter 4 Small 8-Bit Systems
0xc0 and the program memory starts at 0x300. Note that the com
piler places the global variables in 0xc0 through 0xc3, and the
executable program begins at 0x300 as one would expect.
The first several instructions clear the count location and set or
reset proper bits in the TSCR. The instruction CLI clears the inter
rupt bit in the status register of the microcontroller. When this bit is
cleared, interrupts will detected and processed.
The beginning of the loop defined by the macro command FOR
EVER is at address 0x30d. This macro causes no code at the beginning
of the loop. At the end of the loop, address 0x32b, there is an instruc
tion BRA 0x30d that causes control of the program to start at the
beginning of the loop. That is the total code created by the macro
FOREVER. Within this loop, the code created by the compiler is
straightforward and not very different from code that would be cre
ated by a competent assembly language programmer.
#include “hc05j1.h”
0000 #pragma portrw PORTA @ 0x00;
0001 #pragma portrw PORTB @ 0x01;
0003 #pragma portr PORTD @ 0x03;
0004 #pragma portrw DDRA @ 0x04;
0005 #pragma portrw DDRB @ 0x05;
0008 #pragma portrw TCST @ 0x08;
0009 #pragma portrw TCNT @ 0x09;
07F0 #pragma portrw __COPSVS @ 0x7f0;
07F8 #pragma vector __TIMER @ 0x07f8;
07FA #pragma vector __IRQ @ 0x07fa;
07FC #pragma vector __SWI @ 0x07fc ;
07FE #pragma vector __RESET @ 0x07fe;
#pragma has STOP ;
#pragma has WAIT ;
#pragma has MUL ;
00C0 0040 #pragma memory RAMPAGE0 [64] @ 0xc0;
0300 0400 #pragma memory ROMPROG [1024] @ 0x300;