How to reset the FPROT register

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to reset the FPROT register

682 Views
justwalt
Contributor I

I have a MC9s12Dx512 with a flash issue. We need to reset the FPROT register in FF0A-FF0D, but we don't want to do a sector erase that will wipe out our interrupt vector table. Is there a word write available in flash, or some easier method of resetting the FPROT register? Thanks.

Labels (1)
2 Replies

454 Views
RadekS
NXP Employee
NXP Employee

Hi Walt,

The FPROT register at address 0x104 may be modified in the special mode.

The security may be only increased (wider protected area) in normal mode.

If you want to change data at addresses 0xFF0A~0xFF0D in normal mode, the last sector must be unprotected and you have to manage read/modify/write procedure (save the content of the last sector, modify protection bytes, erase the last sector and write it back). This procedure is dangerous due to possible malfunction when external reset appears between sector erase and programmed reset vectors. Therefore, I cannot recommend that solution.

Recommendation: The addresses 0xFF0A~0xFF0D should contain FPROT values that will protect only the  flash area which we do not plan to ever modify. The additional protection (e.g. protection of application code) have to be managed by simply write into FPROT register during every MCU initialization.

I hope it helps you.

Have a great day,
Radek

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

454 Views
kef2
Senior Contributor IV

NVPROT is just a part of flash. You can't change it without mandatory erase step.

If you made NVPROT protecting it self, then you need to go to special single chip mode (using your BDM debugger), in which FPROT register is writeable without restrictions.

Normally, in case you are using some bootloader, you should program NVPROT to protect vectors area and whole bootloader. To protect application, app at startup or bootloader before jumping to app writes to FPROT register. FPROT, as you should know, is writeable all the time, but only towards protecting more flash. You can protect more flash at any time.

To allow bootloader reflashing app code you need to reset MCU (using COP reset, ILAD reset, etc) and tell bootloader somehow that it is not a sudden normal reset, but intentional reset to make FPROT=NVPROT, which should unprotect application flash.

Regards,

Edward

0 Kudos