Adding to Jan Waclawek comments, this is what I 
did for CMON51 in a NXP P89V51RD2 to write a byte 
to flash using the IAP routines:

//Write a byte in to the flash using the IAP routines of the p89v51rd2.
void FlashByte (unsigned int address, unsigned char value)
{
         if(address>=MONITOR_LOC) return; //Don't overwrite the monitor
         FCF=0; //Flash routines are in flash block 0
         _asm
                 mov R1, #0x02
                 ;DPH memory address MSB
                 ;DPL memory address LSB
                 mov     a,_FlashByte_PARM_2
                 lcall 0x1ff0
         _endasm;
         FCF=BSEL; //Go back to flash block 1
         //get rid of sdcc warnings
         value;
}

At 01:33 PM 20/01/2009, you wrote:

>Oh, the quality of NXP documentation on the '51 derivatives is decaying, to
>be very polite...
>
>You must first enable the boot ROM (which is otherwise "hidden" to allow
>full 64kB of FLASH code space). Yes, NXP "forgot" to put this small piece of
>information into the datasheet.
>See for example http://forum.flashmagictool.com/index.php?topic=3478.0 ,
>last sentence.
>
>Make sure no interrupt will happen during IAP programming. The best policy
>is to disable interrupts during IAP calls.
>
>Please come back with your results, either here, or, better, to 8052.com
>Forum.
>
>JW
>
>
>----- Original Message -----
>From: Gudjon I. Gudjonsson <gud...@gudjon.org>
>To: <sdcc-user@lists.sourceforge.net>
>Sent: Tuesday, January 20, 2009 9:13 PM
>Subject: [Sdcc-user] In-application programming on p89v664
>
>
> > Hi
> >    Thanks for the answers to the last question about the function call to
>an
> > absolute address. I am trying to use the iap routines for the NXP p89v664
> > device. The first test is just to get the manufacturers ID but it doesn't
> > work.
>
> > To simplify the code I just check if I can pass by the lcall instruction.
>With
> > the lcall instruction I get 'a' to my terminal but no 'b' but if I comment
>it
> > out, I get 'ab'
>
> > while(1) {
> > c=serial_getchar();
> > serial_putchar('a');
> > _asm
> > mov R1,  #0x00
> > mov dptr, #0x0000
> > lcall 0xfff0
> > _endasm;
> > serial_putchar('b');
> > }
>
> > I have tested many possible changes to the code but without success.
>
> > Hope I'm not off topic and many thanks.
> > Gudjon
>
> > Ps. The relevant part from the p89v664 datasheet is below:
>
> > All calls are made through a common interface, PGM_MTP. The
> > programming functions are selected by setting up the microcontroller’s
> > registers before making a call to PGM_MTP at FFF0H.
>
> > IAP function IAP call parameters
> > Read Id      Input parameters:
> >              R1 = 00H or 80H (WDT feed)
> >              DPH = 00H
> >              DPL = 00H = mfgr id
> >              DPL = 01H = device id 1
> >              DPL = 02H = device id 2
> >              DPL = 03H = 6x/12x bit (bit 7 = 1 = 6x)
> >              DPL = 80H = ISP version number
> >              Return parameter(s):
> >              ACC = requested parameter
>
>
>
>
>------------------------------------------------------------------------------
>This SF.net email is sponsored by:
>SourcForge Community
>SourceForge wants to tell your story.
>http://p.sf.net/sfu/sf-spreadtheword
>_______________________________________________
>Sdcc-user mailing list
>Sdcc-user@lists.sourceforge.net
>https://lists.sourceforge.net/lists/listinfo/sdcc-user


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to