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.
here is a Copy/Paste of a part of my M51 file. BL51 BANKED LINKER/LOCATER V5.12, INVOKED BY: C:\KEIL\C51\BIN\BL51.EXE Blinky.obj, START900.obj TO Blinky RAMSIZE (256) CODE (0X0000-0X07FF) MEMORY MODEL: SMALL INPUT MODULES INCLUDED: Blinky.obj (BLINKY) START900.obj (?C_STARTUP) LINK MAP OF MODULE: Blinky (BLINKY) TYPE BASE LENGTH RELOCATION SEGMENT NAME ----------------------------------------------------- * * * * * * * D A T A M E M O R Y * * * * * * * REG 0000H 0008H ABSOLUTE "REG BANK 0" IDATA 0008H 0001H UNIT ?STACK * * * * * * * C O D E M E M O R Y * * * * * * * CODE 0000H 0003H ABSOLUTE CODE 0003H 004FH UNIT ?CO?BLINKY CODE 0052H 000CH UNIT ?C_C51STARTUP CODE 005EH 000BH INBLOCK ?PR?MAIN?BLINKY 0069H FF87H *** GAP *** CODE FFF0H 000CH ABSOLUTE Thanks, Marc.
now, what does it look like "When I add the Pattern3 declaration" (the case where it fail) Erik
Forgive me, but the M51 from before is with the Pattern2[] AND Pattern3[] definitions commented out. This one is with them both active. It looks like this: BL51 BANKED LINKER/LOCATER V5.12, INVOKED BY: C:\KEIL\C51\BIN\BL51.EXE Blinky.obj, START900.obj TO Blinky RAMSIZE (256) CODE (0X0000-0X07FF) MEMORY MODEL: SMALL INPUT MODULES INCLUDED: Blinky.obj (BLINKY) START900.obj (?C_STARTUP) LINK MAP OF MODULE: Blinky (BLINKY) TYPE BASE LENGTH RELOCATION SEGMENT NAME ----------------------------------------------------- * * * * * * * D A T A M E M O R Y * * * * * * * REG 0000H 0008H ABSOLUTE "REG BANK 0" IDATA 0008H 0001H UNIT ?STACK * * * * * * * C O D E M E M O R Y * * * * * * * CODE 0000H 0003H ABSOLUTE CODE 0003H 00BDH UNIT ?CO?BLINKY CODE 00C0H 000CH UNIT ?C_C51STARTUP CODE 00CCH 000BH INBLOCK ?PR?MAIN?BLINKY 00D7H FF19H *** GAP *** CODE FFF0H 000CH ABSOLUTE I think the problem lies in the memory spaces, but I am not competent enough to follow all the segments from the startup to the C code, etc... Thanks, Marc.
I found a solution to my problem, even though I don't fully understand what happened. When I program my chip using the ICP method with the MCB900 board, I get the errors mentionned previously. But I tried programming it using the ISP method (instead of the ICP method) and the code runs just fine, like the simulator predicted. I must have been doing something wrong with using the ICP method. I was however, able to reprogram the ISP code in FLASH using the ICP method. BTW, I now use Erik's NoTouch approach for ISP. I changed his code to a simple LJMP 0700H if the TX pin is held low (instead of being pulled up) on startup. Thanks everyone! :) Marc.