cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L152 Flash Access

emeydanli
Associate II
Posted on August 27, 2014 at 17:19

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.
3 REPLIES 3
Posted on August 27, 2014 at 17:27

What could be the underlying reason for this? 

''Up to 128 KB Flash with ECC''

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
emeydanli
Associate II
Posted on August 27, 2014 at 17:38

Hello clive1,

In the datasheet, I see this instead: ''256 KB Flash with ECC''.

Regards

Posted on August 27, 2014 at 17:44

Depends on the part you're talking about, and you weren't insufficiently specific.

http://www.st.com/web/catalog/mmc/FM141/SC1544/SS1374/LN1041/PF248824?sc=internet/mcu/product/248824.jsp

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.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..