This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

FLASH PROGRAMMING IN p89v51RD2

HELLO

Please can anyone help me with the IAP of P89V51RD2 for programming multiplt locations in flash memory.

Thank you

Parents
  • sir

    I have programmed the microcontroller but i m unable to program multiple address locations.

    can u please tell me how can i IAP the IC and please tell me how to program to multiple locations.

    Let us say i have stored a value in flash address 1f00 and then i want to sotre another value in 1f50 and so on

    how can i do it.

Reply
  • sir

    I have programmed the microcontroller but i m unable to program multiple address locations.

    can u please tell me how can i IAP the IC and please tell me how to program to multiple locations.

    Let us say i have stored a value in flash address 1f00 and then i want to sotre another value in 1f50 and so on

    how can i do it.

Children
  • "i'm unable to program multiple address locations"

    But why are you "unable"?

    What is preventing you?

    What, exactly, have you tried?

    What, exactly, were the results?

    What documentation and other support resources have you studied?

  • Have you forgotten to erase the flash sector before programming again?

  • sir,

    i have stored the address value in the DPTR and then after the completion of the writing it will increment the DPTR to the next location.

  • Is that the correct procedure - as specified in the documentation?

    Clearly, just "storing the address value in the DPTR" is not, on its own, sufficient to do anything!

    So, what else, exactly, do you do?

    Why do you say you are "unable to program"?

    What is preventing you?

    What, exactly, have you tried?

    What, exactly, were the results?

    "after the completion of the writing it will increment the DPTR to the next location"

    What is "it"?

    What is the significance of this statement? How does it relate to your problem?

    Remember: nobody here knows anything about you or your project. We cannot read your mind.

    If you don't give proper details of what you're doing, what results your're getting, etc - how do you expect anyone to be able to help you??

  • sir,

    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

    this is what is my program

    now i m only using testarea1 and 2 to save my data how do i have multiple data in consecutive locations of the flash memory

    hope ths is clear

  • Are you reading datasheets as carefully as you read the posting instructions for this site?

    Didn't you notice the notes directly above the message text box, giving information how to post source code?

    Or maybe you did write every line starting from the left column and never with more than one space in a row for indent or separation?

  • 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!