Hello everybody! How are you doing?
I hope you're well
I'm developing an application that store user data in the internal flash memory. I'm using routines from AN3942, which are:
char Flash_SectorErase(unsigned long *FlashPtr)
char Flash_ByteProgram(unsigned long *FlashStartAdd,unsigned long *DataSrcPtr,unsigned long NumberOfBytes)
Well, first of all, I've notice that argument NumberOfBytes, should be NumberOfDWord, because the Flash_ByteProgram routine write as many 4bytes as NumberOfBytes... So let's say that you want to write 4 bytes at address 0x2000 then function call should be:
Flash_ByteProgram(0x2000, data_ptr, 1)
Please, try it your self and let me know. I've notice that because the routine writes 4 times the length I want to write.
On the other hand, I can't program an address, and then erase it and progam it again...
Flash_Erase(0x2000)Flash_ByteProgram(0x2000, "TEST", 1)then when some event happens, I callFlash_Erase(0x2000)Flash_ByteProgram(0x2000, "LONG", 1)
After programming "TEST" I go check the address 0x2000 and there it is, "TEST" is written at that address.
Then I put a breakpoint when the event happens and call Flash_Erase. This routine returns error code 0 (no error), but I look at address 0x2000 and "TEST" is still there... I assume, when erased, 0xFF 0xFF 0xFF 0xFF should be there instead... After Flash_Erase, Flash_ByteProgram is executed, again error code is 0, but the new value it's not written...
What could be happenning?
Just want to let you know that I do not run it step by step... I set the breakpoint, and the let it run when breakpoint is reached.... It didn't work (flash wasnt re-programmed) so then I ran stepping over the routines just to see what do they returned.
Thanks in advance! I hope you can help me here