??? 10/10/04 15:15 Read: times |
#79095 - RE: PROGRAM BYTE IAP 89C51RD2 ACC !00 Responding to: ???'s previous message |
After reading the helpfull replies from Erik and Oleg I finaly realized that with the P89 one can not flash a single byte without erasing it's 4K page first. Except that you can program binary 1's to 0's but not the other way around. With the AT89 however, the same bootprom API call (02) can reprogram a single byte withot the need to clear its page first. This ability (to re-flash 1,2,4,..or,128 bytes)is requiered by the ISD51 debugger from www.Keil.com if it is to support flash breakpoints, which is a must if one want to be able to run the application at full speed between breakpoints. (It's a source or mixed source/assembly level, target debugger, expensive, but looks nice. I've only used the demo version so far).
Below is copy/paste of my preliminary (but tested) code for re-flashing a single byte, with entries to be called from ISD51, and Keil "C". It's a beginners code, so for sure it can be done more efficient etc. PUBLIC isd51EntryHacked PUBLIC CWRITER PUBLIC _testCWRITE ?PR?FLLIB SEGMENT CODE INBLOCK ; CSEG AT 0xF000 RSEG ?PR?FLLIB USING 0 PGM_MTP EQU 0xFFF0 ; 89C51RD2 XTAL EQU 16 ; Xtal frequency rounded down (We have 15.9744) NA for Atmel sfr AUXR1 =0xA2 ; SFRegister AUXR1 in 89C51RD2 ENBOOT EQU 0x20 ; Bit in AUXR1 to ENable BOOTrom shadow at FC00-FFFF DISBOOT EQU 0xDF ; Bin in AUXR1 to DISable BOOTrom shadow at FC00-FFFF CBLK EQU 10H ; MUST be same as in ISD51.A51 !!!!! ;----------------------------------------------------------------------- ; CWRITERoutine (not macro) CWRITER: PUSH AR1 ; We sort of unexpectedly use this one ORL AUXR1,#ENBOOT ; Enable shadow BOOTrom where PGM_MTP is MOV DPL,R0 ; DPL <- R0 MOV DPH,A ; DPH <- ACC MOV R0,#XTAL ; R0 <- #XTAL (Philips only) MOV R1,#02H ; R1 <- #0x02 { IAP call = "Program Byte". (No WDT) } MOV A,CBLK ; ACC <- CBLK (IDATA, byte address) PUSH ACC ; Need it to verify afterwards PUSH DPL ; -"- PUSH DPH ; -"- PUSH AR2 ; From Atmel sample flash code PUSH AR4 ; -"- PUSH AR6 ; -"- LCALL PGM_MTP ; Return data in A not reliable. See Errata ANL AUXR1,#DISBOOT ; Disable shadow BOOTrom at PGM_MTP POP AR6 POP AR4 POP AR2 POP DPH POP DPL POP AR0 ; We POP previous ACC into AR0 MOV A,#0 MOVC A,@A+DPTR ; Read back written byte CLR C SUBB A,R0 ; Subtract what should have been written (0=OK) POP AR1 RET ;----------------------------------------------------------------------- ; _testCWRITE : For testing the CWRITER from a "C" test program ; (Keil "C" expects all register may be destroyed, and ; passes arguments in R7,R6,R5,etc. (Max 3 "C" args) ) _testCWRITE: PUSH IE CLR EA MOV A,CBLK ; Push content of CBLK PUSH ACC MOV A,R7 ; R0 <- arg1 low byte MOV R0,A MOV A,R6 ; A <- arg1 high byte MOV CBLK,R5 ; Byte to be written expected at CBLK CALL CWRITER MOV R7,A ; Return value POP ACC ; Pop content of CBLK MOV CBLK,A POP IE RET ;-------------------------------------------------------------------------- ; This is something I used for my self when testing ISD51, because I/we needed ; to have control of the serial IRQ our self, as we use it also for other ; purposes, and can not use the API provided by Keil (We use mode 3). It's ; not part of the flash code, but a dirty hack to do as mentioned. A cleaner ; method would be to use the flash routines to re-flash the LJMP at 0x0023 to ; the serial IRQ handler, when one wants to use ISD51, and then flash it back ; again when done. I strongly recomend that for new designs, you use an external ; serial chip, preserving the internal one for debuggers like the Keil ISD51, ; unless you have some emulator or other hardware dependant debugging solution. ; ; isd51EntryHacked: pop the registeres pushed by the serial IRQ handler in "C", ; and jump to IRQ entry address for isd51. Used to enter ; isd51 without re-flashing the IRQ vector for it. This ; must correlate with *.LST file for the C IRQ function. ; EXTRN CODE (SerialInterrupt) isd51EntryHacked: POP ACC ; POP 2 bytes to get rid of POP ACC ; C callers return address POP AR7 ; POP the rest of the bytes POP AR6 ; pushed by the C IRQ handler POP AR5 POP AR4 POP AR3 POP AR2 POP AR1 POP AR0 POP PSW POP DPL POP DPH POP B POP ACC ; Don't pop return of C IRQ LJMP SerialInterrupt ; handler. ISD51 will do that ; when doing RETI END |
Topic | Author | Date |
PROGRAM BYTE IAP 89C51RD2 ACC !00 | 01/01/70 00:00 | |
RE: PROGRAM BYTE IAP 89C51RD2 ACC !00 | 01/01/70 00:00 | |
RE: PROGRAM BYTE IAP 89C51RD2 ACC !00 | 01/01/70 00:00 | |
RE: PROGRAM BYTE IAP 89C51RD2 ACC !00 | 01/01/70 00:00 | |
RE: PROGRAM BYTE IAP 89C51RD2 ACC !00 | 01/01/70 00:00 | |
RE: PROGRAM BYTE IAP 89C51RD2 ACC !00 | 01/01/70 00:00 | |
RE: PROGRAM BYTE IAP 89C51RD2 ACC !00 | 01/01/70 00:00 | |
RE: PROGRAM BYTE IAP 89C51RD2 ACC !00 | 01/01/70 00:00 | |
RE: PROGRAM BYTE IAP 89C51RD2 ACC !00 | 01/01/70 00:00 | |
RE: PROGRAM BYTE IAP 89C51RD2 ACC !00 | 01/01/70 00:00 | |
RE: FLASH OR EEPROM ??? | 01/01/70 00:00 | |
RE: FLASH OR EEPROM ??? | 01/01/70 00:00 | |
RE: FLASH OR EEPROM ??? | 01/01/70 00:00 | |
RE: FLASH OR EEPROM ??? | 01/01/70 00:00 | |
RE: FLASH OR EEPROM ??? | 01/01/70 00:00 | |
RE: FLASH OR EEPROM ??? | 01/01/70 00:00 | |
RE: FLASH OR EEPROM ???![]() | 01/01/70 00:00 |