HELLO
Please can anyone help me with the IAP of P89V51RD2 for programming multiplt locations in flash memory.
Thank you
FCF EQU 0B1h ORG 0 ljmp Reset ;---- interrupt vectors ;none here ;---- "main" Reset: ;if we try to rewrite an already programmed byte without previously erasing it, this will fail: MOV DPTR, #TestArea1 MOV A, #55h CALL FLASH_PROGRAM_BYTE ;this is how a sector has to be erased prior bytes in it are being rewritten: MOV DPTR, #TestArea2 CALL FLASH_ERASE_SECTOR MOV DPTR, #TestArea2 MOV A, #0AAh CALL FLASH_PROGRAM_BYTE Stop: SJMP Stop ;---- data area, 128-byte sectors ;make sure that there is no code in the whole sector, ;as upon updating the data the whole sector gets erased ORG 0080h TestArea1: db 0, 0 ORG 0100h TestArea2: db 0, 0 ;end of TestArea2 at 017F ORG 0180h ;rest of code may go here ;---- FLASH API - must be located anywhere ABOVE 2000h ORG 03F00h ;programs a single byte in FLASH ;DPTR=addres, A=content of byte to be programmed ;the position to be programmed must be previously erased FLASH_PROGRAM_BYTE: PUSH IE ;DISABLE INTERRUPTS CLR EA MOV R1,#02 ;SETUP OPERATION CODE -- write byte 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 ;erases a 128-byte sector in FLASH ;DPTR=address of first byte of sector to be erased FLASH_ERASE_SECTOR: PUSH IE ;DISABLE INTERRUPTS CLR EA MOV R1,#08 ;SETUP OPERATION CODE -- erase sector 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 ;----- that's all, folks END hope now this is fine
For the NXP P89V51RD2 IAP, please check the following documents and example code:
www.efton.sk/.../p89v51rd2 iap.pdf www.efton.sk/.../iap.zip www.efton.sk/.../index.htm
Jan has done a great work!