Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: LPC2000 Flash protection example wanted

2005-12-19 by Karl Olsen

--- In lpc2000@yahoogroups.com, "phlpcmicro" <joseph.goldburg@a...> 
wrote:

> I am looking for code examples on how to set Code Protection on.
> 
> Eg  address  0x1FC   = 0x87654321
> 
> For GCC, Keil and IAR
> 
> 
> Eg Does this look right?
> // write to address macro
> #define REG(addr) (*(static unsigned long *)(addr))
> 
> REG(0x1FC) = 0x87654321;
> 
> Or  would it be better loaded in the startup file.

You cannot do it in that way.  The address is in flash which cannot 
be written like RAM.

With GCC, you can do it like this, in startup.s (it compiles, not 
tested at runtime):

Vectors:
  B  Reset_Handler
  B  Undef_Panic
  B  SWI_Panic
  B  PAbort_Panic
  B  DAbort_Panic
  NOP
  B  IRQ_Panic
  B  FIQ_Panic

.org 0x01FC
  .word  0x87654321

In this way, you waste the 476 bytes between the vectors and the 
magic word.  You can put some other code between the vectors and 
the .org to waste less.

Karl Olsen

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.