Hi. I have this simple code that defines some constants in code: #include <REG922.H> code const unsigned char LEDRegister0[] = {0xff,0xfe,0xfd,0xfb,0xff,0xff,0xff,0xff,0xf7,0xff,0xff,0xbf}; code const unsigned char LEDRegister1[] = {0x7f,0xff,0xff,0xff,0xef,0xfd,0xfb,0xf7,0xff,0xbf,0xfe,0xff}; code const unsigned char Pattern1[] = {54,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,19,21,25,27,30,33,36,40,45,50,50,45,40,36,33,30,27,25,21,19,19,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1}; code const unsigned char Pattern2[] = {54,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,19,21,25,27,30,33,36,40,45,50,50,45,40,36,33,30,27,25,21,19,19,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1}; code const unsigned char Pattern3[] = {54,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,19,21,25,27,30,33,36,40,45,50,50,45,40,36,33,30,27,25,21,19,19,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1}; void main() { unsigned char i; P1M1 = 0; for(;;) { P1 = 0xaa; P1 = 0x55; } } When I simulate this code it runs fine, but when I download it to my chip (an LPC920), it doesn't run. I then remove the last constant definition named Pattern3, recompile and now the code simulates AND runs in the chip. I started from the Blinky example and simply changed the target chip to compile. I'm using small memory model and small code size (2k or less). If anyone can tell me what I'm doing wrong, I would be grateful. Thanks, Marc.
"I started from the Blinky example and simply changed the target chip to compile. " That's not true! Here's the code of Blinky.c:
/* BLINKY.C - LED Flasher for the Keil MCBx51 Evaluation Board with 80C51 device*/ #include <REG51F.H> void wait (void) { /* wait function */ ; /* only to delay for LED flashes */ } void main (void) { unsigned int i; /* Delay var */ unsigned char j; /* LED var */ while (1) { /* Loop forever */ for (j=0x01; j< 0x80; j<<=1) { /* Blink LED 0, 1, 2, 3, 4, 5, 6 */ P1 = j; /* Output to LED Port */ for (i = 0; i < 10000; i++) { /* Delay for 10000 Counts */ wait (); /* call wait function */ } } for (j=0x80; j> 0x01; j>>=1) { /* Blink LED 6, 5, 4, 3, 2, 1 */ P1 = j; /* Output to LED Port */ for (i = 0; i < 10000; i++) { /* Delay for 10000 Counts */ wait (); /* call wait function */ } } } }