Skip to main content
Visitor II
March 27, 2024
Solved

Flash memory programming

  • March 27, 2024
  • 2 replies
  • 2925 views

Hello everyone, iam using nucleo-U575ZI-Q board and trying to do Flash programming. I want to write the data in to the flash and read the data from the flash. I've written the code but something is going wrong with it. Could someone please help me in finishing my task. I will attach my code below. 

Thank you 

    This topic has been closed for replies.
    Best answer by Ayoub Cheggari

    Hello,

    Can you give more details about your issue? Is it not erasing, writing or reading?

    2 replies

    Graduate II
    March 28, 2024

    Hello,

    Can you give more details about your issue? Is it not erasing, writing or reading?

    _JITH_Author
    Visitor II
    March 28, 2024

    Something is going wrong with "Writing" .Data which I want to store in to the flash is not being stored at that address location....help me out plz.

    Thank you for your valuable response...

    Graduate II
    March 28, 2024

    Unfortunately "something wrong" isn't a particular helpful observation

    Check for errors in function returns.

    Clear the erase structure.

    I'm not convinced the math here is correct. I'd assume the page size is in bytes, not word

    int numberofwords= (sizeof(DATA_32)/4)+((sizeof(DATA_32) %4)!=0);
    EraseInitStruct.NbPages = (numberofwords/FLASH_PAGE_SIZE)+1;

     

    EraseInitStruct.NbPages = (numberofbytes + FLASH_PAGE_SIZE - 1)/FLASH_PAGE_SIZE; // Would round bytes to actual pages properly

    Graduate II
    March 28, 2024

    Your rx_data buffer looks entirely inadequate for the amount of data to be read back as 32-bit words and termination word.

    Have a HardFault_Handler() that can report actionable data.

    Add diagnostic output so you understand what's happening, what's failing and what errors you get.