2022-02-03 02:30 AM
Hi
I am able to erase two pages (my array is length 256 ), now I want to write my array to a particular memory location.
Here set is the address which is 0x080E0000
p_source is my uint16_t array which I want to write to flash. And length is 256.
How do I pass my array and also write it in this function?
I'm unlocking in the main function, calling erase function, then calling this function then locking the flash.
void FLASH_Write_HAL(uint16_t *p_source, uint16_t* seg, uint16_t length)
{
uint32_t varToPass;
uint16_t wordcount=0;
int i;
for (i=0; i<length; i++){
varToPass = (uint32_t*) &p_source[i] ;
HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD,seg+wordcount,varToPass);
wordcount += 4;
// if (wordcount>=256){
// break;
// }
}
}
2022-02-03 04:32 AM
Can someone please help me?
2022-02-03 04:42 AM
Have you tried using FLASH_TYPEPROGRAM_BYTE instead of FLASH_TYPEPROGRAM_WORD with HAL_FLASH_Program() ?
I haven't used it yet, but it looks quite obvious...
Take a look at HAL_FLASH_Program() to understand how it works.
2022-02-03 05:07 AM
Unfortunately I can't use that for my controller, I also can't use FLASH_TYPEPROGRAM_HALFWORD as the last argument expects a 32 bit word to be passed as a variable
2022-02-03 05:53 AM
You get the level of service you pay for here..
So cast the array into a larger unit and write it as a block of data rather than individual array elements.
Data Representation..
2022-02-03 06:41 AM
Related/duplicate: