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

IAP + philips firmware call & C51 debugger

Trying to use the code shown in the following

http://www.keil.com/support/docs/2045.htm

Basically, shows you how to do In Application programming on a philips device.

I have set my target device to a p89c662 which supports this, but when I call the code inside the debugger (uVision pretending to be the device) it gets to the

CALL 0FFF0H ; call philips firmware line

and chokes with the error:

*** error 65: access violation at C:0xFF00 : no 'execute/read' permission

I'd like to test it before I go anywhere near the device itself, am I missing something or can the C51 enironment not replicate that particular function?

Parents Reply Children
  • Just a thought, but I wouldn't think the emulator would provide support for the firmware included in the Boot ROM -- but I could be mistaken.

    Your best bet is to use an #ifdef/#else clause to assemble a non-Flash version of the _ProgramDataByte function when using the emulator.

    Robert

  • Hi again Robert, quick question for you.

    Now got my control board and can write to the flash. But it appears that if I try to write to the same location, the write function appears to carry out an && function.

    for instance

    //main.c
    
    extern unsigned char ProgramDataByte (unsigned int addr, unsigned char v);
    
    void main (void)  {
    	ProgramDataByte (0x4000, 0x55);
    	ProgramDataByte (0x4000, 0x66);
    }
    
    // assembly
    
    #define AUXR1	0xA2
    XTAL_MHZ        EQU     12            ; Chip runs at 12MHz
    ?PR?_ProgramDataByte?ISA  SEGMENT CODE
    RSEG ?PR?_ProgramDataByte?ISA
    PUBLIC _ProgramDataByte         ; Entry Point for C Compiler
    ; unsigned char ProgramDataByte (unsigned int addr, unsigned char v);
    ; The C51 compiler passes addr in R6/R7 and v in R5
    _ProgramDataByte:       MOV   AUXR1, #20H
    			MOV   DPH,R6
                            MOV   DPL,R7
                            MOV   A,R5
                            MOV   R0,#XTAL_MHZ
                            MOV   R1,#02H        ; function code
                            CALL  0FFF0H         ; Call Philips firmware
                            MOV   R7,A           ; C51 expects return in R7
    			MOV   AUXR1, #NOT 20H
                            RET
                            END
    

    If I then look at the memory location I find I have 0x44, rather than 0x66 which I was expecting.

    I basically want to reprogram the byte without having to erase all the bytes in the block. Is that possible? (thought I'd ask give you said you worked with the 664)

    Many thanks

    Rob

  • When you write to flash, what you actually do is set some bits to 0. "Erasing" flash actually sets all bits to 1s. If you program the same byte twice without erasing in between, the first write will set some bits to zero, and then the second write will come along and set possibly some other bits to zero. The only way to set a flash bit to 1 is to erase the block.

    Hence, your observed "&& operation". 0x55 & 0x66 == 0x44. The write of 0x55 sets bit 1 to 0; the write of 0x66 can't get it back to a 1. The write of 0x66 sets bit 0 to 0. Both writes have bit 2 == 1, so it remains set after both writes.