??? 10/13/06 12:18 Read: times |
#126397 - Jan ... Guide me more Responding to: ???'s previous message |
Dear Jan ...
thank you very much for your efforts ... you said : Arvind Shrivastava said: org 2010h Why??? '51 starts executing program after reset from 0000h, doesnt' it? Sir The user code must be above 2000h and also as stated by you the satements ;there is an ORG 2000h somewhere above this FLASH_API: PUSH IE ;DISABLE INTERRUPTS CLR EA ANL FCF,#0FCh ;enable boot sector - !!! this command MUST be located ABOVE 2000h!!! CALL 01FF0H ;call to ISP_API (modifies B register but no Rx) ORL FCF,#001h ;switch back to user FLASH POP IE RET as you has stated for the FCF modification that the command should be above 2000h ... daz y I had given it org 2010h acall FLASH_SUBROUTINE you said: Arvind Shrivastava said: FIRMWARE_BIT equ 010h ;flag for checking whether the program is ; exceuting for the forst time or not ; 0 for first time executing I thought you want to keep this flag in non-volatile memory = FLASH, won't you? Then, you need to choose a space for it so that it won't get into conflict with the software. I wouldn't put it at 0010h, as the interrupt vectors are there, so if you want to use them in the future it would interfere. It does not matter if you put it below 2000h or above 2000h; the whole APPLICATION FLASH (Block 0) is treated by the IAP in the same way. Of course, if stored in FLASH, you cannot simply test it by jb/jnb instruction. You need to fetch it from the code memory (=FLASH) using MOVC into accumulator, and THEN test it in accumulator. Also, you can chose the default value of the flag simply by putting it in the source as data. Then it would get burned together with the rest of code, to be prepared for the first time usage. I would suggest you to have the default ("intact") value = 00h and store it in the same page than the password (say, at address 327Fh - I assume the password will be less than 128 bytes long); so that if you erase the flash page to reprogram the password, the flag gets automatically complemented. So if we assume you will do it as I described above, store the flag at position 327Fh and the password from 3200h; you will include into source code the following to get the initial value of the flag: ORG 327f FIRMWARE_FLAG: db 0 I dont understand fully FIRMWARE_FLAG: db 0 ... also ... ORG 3200h is the starting address of my START subroutine and not the address of my password ... you can see that I have moved the value of r4 and r5 in dptr ... I am sorry 3200 is decimal and I have converted to hex and then moved to dptr ... and jumping to 3200h ... could please tell me the stupidity I am doing here ... as I am confused ... Please again revert for the mistakes ... regards AS |