EmbeddedRelated.com
Forums
Memfault Beyond the Launch

Writing UCFG1 with IAP routines?

Started by markvanelst January 25, 2006
Hello,

I am writing a bootloader for the P89LPC922. I use IAP lite to write
to the program memory and this works fine. I want to reprogram UCFG1
(RPE) before updating the firmware to prevent unwanted reset requests
during updating. How can I program UCFG1 with IAP?
I tried the IAP sources on www.esacademy.com, but they don't seem to
work :(
Can you help me with the esacademy sources or do you have another
solution? Thanks in advance for your help

Kind regards,
Mark



Hello Mark,

Before writing the UCFG1 register you have to give the CCP Clear
Configuration Protection command (see example below).

shift_out(WR_FMCON); // write to FMCON
shift_out(CCP); // write clear config protection
shift_out(WR_FMDATA); // write FMDATA command
shift_out(CLR_CCP_KEY); // write command
do // loop while status is busy
{
shift_out(RD_FMCON); // read FMCON command
read_data = shift_in(); // shift in data from FMCON
}
while(read_data & 0x80); // check for done status MSB

Regards,
Paul --- In lpc900_users@lpc9..., "markvanelst" <markvanelst@y...>
wrote:
>
> Hello,
>
> I am writing a bootloader for the P89LPC922. I use IAP lite to write
> to the program memory and this works fine. I want to reprogram UCFG1
> (RPE) before updating the firmware to prevent unwanted reset
requests
> during updating. How can I program UCFG1 with IAP?
> I tried the IAP sources on www.esacademy.com, but they don't seem to
> work :(
> Can you help me with the esacademy sources or do you have another
> solution? Thanks in advance for your help
>
> Kind regards,
> Mark
>


Hi Mark,

I agree with Pauls comments and feel that you have protected the 
configuration values with the config protection bits in the BOOTSTAT 
register.

These are both active high ('1' is enabled) and their functionality 
is:
BootStat.7 DCCP - Disable Clear Config Protection
BootStat.6 CWP - Config Write Protect

You can use the CWP bit to protect the config area from inadvertant 
writes.

However, there is a gotchya that you need to be aware of.

If you have also set DCCP then the CCP command will only be sucessful 
in the ICP and parallel programming (if the device supports it) mode.

So, what value have you got in BootStat?

Phoebe

--- In lpc900_users@lpc9..., "paul_seerden" 
<paul_seerden@y...> wrote:
>
> Hello Mark,
> 
> Before writing the UCFG1 register you have to give the CCP Clear 
> Configuration Protection command (see example below).
> 
> shift_out(WR_FMCON);            // write to FMCON
> shift_out(CCP);                 // write clear config protection
> shift_out(WR_FMDATA);           // write FMDATA command
> shift_out(CLR_CCP_KEY);         // write command
> do                              // loop while status is busy
> {
>     shift_out(RD_FMCON);        // read FMCON command
>     read_data = shift_in();     // shift in data from FMCON
> }
> while(read_data & 0x80);        // check for done status MSB
> 
> Regards,
> Paul
> 
> 
> --- In lpc900_users@lpc9..., "markvanelst" 
<markvanelst@y...> 
> wrote:
> >
> > Hello,
> > 
> > I am writing a bootloader for the P89LPC922. I use IAP lite to 
write 
> > to the program memory and this works fine. I
want to reprogram 
UCFG1 
> > (RPE) before updating the firmware to prevent
unwanted reset 
> requests 
> > during updating. How can I program UCFG1 with IAP?
> > I tried the IAP sources on www.esacademy.com, but they don't seem

to 
> > work :(
> > Can you help me with the esacademy sources or do you have another 
> > solution? Thanks in advance for your help
> > 
> > Kind regards,
> > Mark
> >
>
	

Memfault Beyond the Launch