We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi,
I'm trying to write an In-Application bootloader. Before writing to internal Flash it must be unlocked, then erased (selected page) then written to. - the unlock sequence works fine - the page erase works fine - the writing of data reports no error but data is not written
The internal oscillator is selected as is ordered by the specs. To write data a 16 bit value (half word) must be written to an address in the erased page.
I use an assembler function to execute this data write operation. (First argument is transported in R0, second in R1).
__asm void vFlashWrite(int iAdd,short sDta){ strh r1,[r0] //store (halfword) data from r1 to address in r0 bx lr //return } vFlashWrite(0x08000800,0x55aa);
...but still no data is written...
Anybody has any idea?
Thanks, Henk
>Please check ...the Flash Programing Manual...17863.pdf
Thanks, I allready did twice ;-)
As mostly it's some programming failure of the programmer (me).
To make this thread educational I will answer myself...
Step 1: Erasing the flash needs the PER bit in the CR register to be set. Step 2: Writing to flash needs the PG bit in the CR register to be set. But...don't forget to CLEAR the erase selection PER bit prior to step 2.
Now it works.
Thanks for listening anyway.
Henk