cancel
Showing results for 
Search instead for 
Did you mean: 

NOT able to write one byte in internal flash memory

saikumar
Associate III

in stm32h743

1---->  Im trying to write only one byte in this address 0x8100000 . but it is writing 32 bytes in the memory . so why  not support to  write only one byte in internal flash memory.

2----->  And im trying to start writing  some data from these addresess ..ex . (0x8100000 or 0x8100020 ,  0x8100040,0x8100060....... (theses addresess are base addreses where im start to writing ) )  like multiple of 32  . so my data is susccessfully writing in the internal flash memeory . But if i try to start the writing on not multiple of 32 addresess ..ex (0x8100001, 0x8100002, 0x8100002A, 0x8100210......... ( similarly theses addresess are base addreses where im start to writing ) )  . so my data is not writing in the memory and all the byte are become 0xFF in that sector . 

------ > this is the function im  using for write data into internal flash memory 

  HAL_StatusTypeDef  HAL_FLASH_Program(uint32_t TypeProgram, uint32_t FlashAddress, uint32_t DataAddress);

 

And i request to give me some solutions  on this problem ,  thanks  ..

1 ACCEPTED SOLUTION

Accepted Solutions
Danish1
Lead II

Please read the Reference Manual for your stm32.

The section on Embedded FLASH memory makes it clear that programming is done in units of 256 bits, i.e. 32 bytes, as you have observed.

This is a "design compromise" ST have chosen to do.

Their options were:

  • Scrap every chip they make that has a faulty FLASH memory bit. This would vastly reduce the number of chips they make per batch hence push the price up enormously
  • Make FLASH cells larger, to reduce the risk of individual bits failing. This would make the chips much larger, pushing up their cost. (Remember there are 16 million bits of FLASH storage)
  • Add error-correction-coding. For each 256 bits of FLASH, add a further 10 or so bits of FLASH that get programmed at the same time. This gives enough information so that even if a single bit is wrong in the now 266 bits, hardware can work out what the bits should have been.
    The cost is a small increase in FLASH area. But also that you can only program the 256 bits in one hit - not by individual bytes - because once a bit is programmed in the error-correction-bits, it can't be erased without erasing the whole page

You might ask why not do error-correction-coding on a byte level. The problem then is that you'd need about 4 error-correction-bits per 8 bits for 8 bits of the byte. Which in total is many more error-correction bits, pushing the price up almost as much as if they just made each cell larger.

View solution in original post

1 REPLY 1
Danish1
Lead II

Please read the Reference Manual for your stm32.

The section on Embedded FLASH memory makes it clear that programming is done in units of 256 bits, i.e. 32 bytes, as you have observed.

This is a "design compromise" ST have chosen to do.

Their options were:

  • Scrap every chip they make that has a faulty FLASH memory bit. This would vastly reduce the number of chips they make per batch hence push the price up enormously
  • Make FLASH cells larger, to reduce the risk of individual bits failing. This would make the chips much larger, pushing up their cost. (Remember there are 16 million bits of FLASH storage)
  • Add error-correction-coding. For each 256 bits of FLASH, add a further 10 or so bits of FLASH that get programmed at the same time. This gives enough information so that even if a single bit is wrong in the now 266 bits, hardware can work out what the bits should have been.
    The cost is a small increase in FLASH area. But also that you can only program the 256 bits in one hit - not by individual bytes - because once a bit is programmed in the error-correction-bits, it can't be erased without erasing the whole page

You might ask why not do error-correction-coding on a byte level. The problem then is that you'd need about 4 error-correction-bits per 8 bits for 8 bits of the byte. Which in total is many more error-correction bits, pushing the price up almost as much as if they just made each cell larger.