Yahoo Groups archive

Lpc2000

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

Thread

Re: [gmane.comp.hardware.arm.lpc2100] Partial (Less than 512 bytes) Flash Programming

Re: [gmane.comp.hardware.arm.lpc2100] Partial (Less than 512 bytes) Flash Programming

2004-08-10 by Frank Sergeant

> Many group members have experimented with the IAP calls to write less 
> than 512 bytes of data. The follwing information and Q&A attempts to 
> address relevant concerns.

Regarding the discussion of writing 16 bytes at a time, is this for the
LPC2106 chip or for a different processor?

When calling the IAP routine to write 16 bits on an LPC2106, I get a
return code of 6, which per the manual is

    COUNT_ERROR    Byte count is not multiple of 4 or is
                   not a permitted value.

However, I *can* write 512 bytes at a time successfully.  (Yes, I am
preparing the sector in both cases.)

Are there some additional tricks to writing just 16 bytes at a time?

Perhaps I must copy any partial data from the 512-byte portion, extend
with my new 16 bytes, pad out to the end with 0xFF and then write 512
bytes (thus overwriting the beginning with what was already there, then
extending with my new data, then leaving the tail as all 0xFF)?

Is there a way to do it by calling the IAP routine with a length of 16
rather than with 512?


-- 
Frank

Re: [lpc2000] Re: [gmane.comp.hardware.arm.lpc2100] Partial (Less than 512 bytes) Flash Programming

2004-08-10 by Robert Adsett

At 07:51 PM 8/9/04 -0500, you wrote:
>Regarding the discussion of writing 16 bytes at a time, is this for the
>LPC2106 chip or for a different processor?
>
>When calling the IAP routine to write 16 bits on an LPC2106, I get a
>return code of 6, which per the manual is
>
>     COUNT_ERROR    Byte count is not multiple of 4 or is
>                    not a permitted value.

Bytes or bits? That would be a correct error message for 16 bits.

Robert

" 'Freedom' has no meaning of itself.  There are always restrictions,
be they legal, genetic, or physical.  If you don't believe me, try to
chew a radio signal. "

                         Kelvin Throop, III

Re: [gmane.comp.hardware.arm.lpc2100] Partial (Less than 512 bytes) Flash Programming

2004-08-10 by philips_apps

> Regarding the discussion of writing 16 bytes at a time, is this for 
> the LPC2106 chip or for a different processor?

It is for LPC 2104, 2105, 2106, 2114 2124 2119 2129 2194 2212 2214 
2292 2294 
 
> When calling the IAP routine to write 16 bits on an LPC2106, I get a
> return code of 6, which per the manual is
> 
>     COUNT_ERROR    Byte count is not multiple of 4 or is
>                    not a permitted value.

Minumum write size is 512 bytes.
 
> However, I *can* write 512 bytes at a time successfully.  (Yes, I am
> preparing the sector in both cases.)
> 
> Are there some additional tricks to writing just 16 bytes at a time?
> 
> Perhaps I must copy any partial data from the 512-byte portion, 
> extend with my new 16 bytes, pad out to the end with 0xFF and then 
> write 512 bytes (thus overwriting the beginning with what was 
> already there, then extending with my new data, then leaving the 
> tail as all 0xFF)?

Above mentioned approach will not work. You need to fill all bytes in 
the RAM buffer with 0xFF. Only change the 16 bytes you want to write. 
The modified 16 byte chunk must be aligned at 16 bytes boundary 
within the 512 bytes buffer. The corresponding 16 bytes in the Flash 
must  be 0xFF. If you want to write to a flash location that has 
already  been programmed then you must erase the sector.


> Is there a way to do it by calling the IAP routine with a length of 
> 16 rather than with 512?

No

Philips Apps

Re: [gmane.comp.hardware.arm.lpc2100] Partial (Less than 512 bytes) Flash Programming

2004-08-11 by Frank Sergeant

"philips_apps" <philips_apps@...> writes:

> > Regarding the discussion of writing 16 bytes at a time, is this for 
> > the LPC2106 chip or for a different processor?
 
> It is for LPC 2104, 2105, 2106, 2114 2124 2119 2129 2194 2212 2214 
> 2292 2294 

Ok, so the discussion applied to the chip I'm using, an LPC2106.
  
> Minumum write size is 512 bytes.

Ok, that agrees with the way I read the manual.  I guess I read the
earlier posting with too much wishful thinking.

> Above mentioned approach will not work. You need to fill all bytes in 
> the RAM buffer with 0xFF. Only change the 16 bytes you want to write. 
> The modified 16 byte chunk must be aligned at 16 bytes boundary 
> within the 512 bytes buffer. The corresponding 16 bytes in the Flash 
> must  be 0xFF. If you want to write to a flash location that has 
> already  been programmed then you must erase the sector.

Ok, I think I understand now.  Thank you.


-- 
Frank

Re: [gmane.comp.hardware.arm.lpc2100] Partial (Less than 512 bytes) Flash Programming

2004-08-14 by chazeltopman

--- In lpc2000@yahoogroups.com, Frank Sergeant <frank@p...> wrote:
> "philips_apps" <philips_apps@y...> writes:
> 
> > > Regarding the discussion of writing 16 bytes at a time, is this for 
> > > the LPC2106 chip or for a different processor?
>  
> > It is for LPC 2104, 2105, 2106, 2114 2124 2119 2129 2194 2212 2214 
> > 2292 2294 
> 
> Ok, so the discussion applied to the chip I'm using, an LPC2106.
>   
> > Minumum write size is 512 bytes.
> 
> Ok, that agrees with the way I read the manual.  I guess I read the
> earlier posting with too much wishful thinking.
> 
> > Above mentioned approach will not work. You need to fill all bytes in 
> > the RAM buffer with 0xFF. Only change the 16 bytes you want to write. 
> > The modified 16 byte chunk must be aligned at 16 bytes boundary 
> > within the 512 bytes buffer. The corresponding 16 bytes in the Flash 
> > must  be 0xFF. If you want to write to a flash location that has 
> > already  been programmed then you must erase the sector.
> 
> Ok, I think I understand now.  Thank you 

 Here's an explanation in Forth which should make the algorithms
 clear.  This allows writing to a 16 byte aligned area when it is
 all 0xFF with just one write.  If the area is not clear, then it
 is copied, erased, modified and written.  This is just for writing
 16 bit values (FL!) but can be torn apart and adapted as needed.

HEX
: DUMBFL!  ( n \ a -- )  \ use erase and move
   DUP A>S S>A  ( sector address )
   DUP HERE OVER A>Z CMOVE  ( copy sector )
   DUP DUP A>Z FLERASE  ( erase old copy )
   DUP >R  - HERE + !  ( modify )
   HERE R> DUP A>Z FLMOVE ;

: NALIGN  ( a \ n -- a' )  1 -  DUP >R  +  R> NOT AND ;

: FL!  ( n \ a -- )  \ minimize flash operations but allow write always
   -1  OVER 10 NALIGN  10 OVER + SWAP  DO  I @ AND  4 +LOOP  NOT
   IF  DUMBFL!     \ must erase first then write
   ELSE  1FF NOT  OVER AND DUP >R  HERE 200 CMOVE  \ copy out sector
         R@ -  HERE + !      \ change location
         HERE R> 200 FLMOVE  \ update flash
   THEN ;

 Other words referenced:
  A>S  ( a -- s )   \ change address to sector#
  S>A  ( s -- )   \ change sector to start address of sector
  A>Z  ( a -- n )   \ use address to get sector size
  FLERASE  ( a \ n -- )  \ erase n bytes from address a
  FLMOVE  ( a1 \ a2 \ u -- )  \ copy u bytes from a1 to a2

 I use this on both the 2106 and the 2129.

 Rob

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.