2014-08-27 08:19 AM
Hello Everyone,
I am working on an STM32L152 based platform and trying place some data inside internal flash. As you may know, when a page is erased, in stm32L1, each bit is set to 0x00 instead of 0xFF. After erasing a page, I am trying to set each bit of a flash word respectively. Here is my test code:void
*dest = (
void
*) 0x08030000;
uint32_t max = (uint32_t) ~0;
uint32_t value = 0;
HAL_FlashErase(dest, 1); /* STM32 Lib Function Wrapper */
while
(value < max) {
value = (value << 1) | 1;
HAL_FlashWriteWord(dest, value); /* Yet another wrapper function */
printf
(
''value: %u | flash: %u\n''
, value , *(
volatile
uint32_t *) dest);
}
When I have a look at the output, always I see inconsistent/incorrect values. Here is the short part of the output:
value: 1 | flash: 1
value: 3 | flash: 3
value: 7 | flash: 15 /* Not same */
value: 15 | flash: 15
value: 31 | flash: 31
value: 63 | flash: 127 /* Not same again */
What could be the underlying reason for this?
Thanks in advance.
2014-08-27 08:27 AM
What could be the underlying reason for this?
''Up to 128 KB Flash with ECC''2014-08-27 08:38 AM
Hello clive1,
In the datasheet, I see this instead: ''256 KB Flash with ECC''. Regards2014-08-27 08:44 AM
Depends on the part you're talking about, and you weren't insufficiently specific.
The flash line is wider than you think it is, and it's not designed to be written a bit at a time. You might see similar ''odd'' behaviour with MLC flash too.