AnsweredAssumed Answered

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

Question asked by guanghui li on Jul 6, 2017

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: 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)