cancel
Showing results for 
Search instead for 
Did you mean: 

How to program ''single byte'' to STM32 internal flash?

guanghui li
Associate
Posted on July 06, 2017 at 04:17

Hi, all!

    I want to program single byte to internal flash, but the standard peripheral library only support 'word' and 'half word', is it possible to program single byte, please?

For example:

mailto:0x11@0x08010000,

0x22@0x08010001

My operation as follow:

// for first byte

1. erase page

2. read test_half_word from 0x08010000

3. test_half_word &= 0xFF00

4. test_half_word |= 0x11

5. write test_half_word to 0x08010000

// for second byte

6. read test_half_word from 0x08010000

7. test_half_word &= 0x00FF

8. test_half_word |= 0x22

9. write test_half_word to 0x08010000

Result: the first byte programmed successfully, but the second byte failed.

I think the value of 0x08010000 is 0xFF, it should be programmed, but I'm wrong. Could you help me, please?

(By the way, the ram buffer of 1KB can solve the problem ,but not suitable for my project)

1 REPLY 1
Posted on July 06, 2017 at 13:31

Combine the bytes and write as a half-word. You fail to mention a specific STM32 part, but most have a wide flash line containing ecc bits.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..