This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP432P401R: MAP_FlashCtl_programMemory

Part Number: MSP432P401R


Hello,

Quick questiin. Can I use MAP_FlashCtl_programMemory() function like this:

I've unprotected all sectors that I want to program and called MAP_FlashCtl_performMassErase()..

I want to program for example whole MAIN BANK0 with some data, can I do this:

length = 4096;

tmp = 0;

do{

tmp =  MAP_FlashCtl_programMemory(src, dest, length);  

}while(!tmp);

and so on in some for until I program MAIN BANK0..

I know that I can't program memory if I don't erase it first, so if this function fails at first attempt will it fail every other time or will it only program memory where it failed the first time and skip memory that it program at first attempt, or do I need to erase that sector every time it fails to program it ? 

Regards,

Ugljesa Popovic

  • Hello Ugljesa Popovic,

    Ugljesa Popovic said:
    I know that I can't program memory if I don't erase it first, so if this function fails at first attempt will it fail every other time or will it only program memory where it failed the first time and skip memory that it program at first attempt, or do I need to erase that sector every time it fails to program it ? 

    Correct, you will need to erase the flash before programing it. But for this case,

    Ugljesa Popovic said:
    I've unprotected all sectors that I want to program and called MAP_FlashCtl_performMassErase()..
    the API will not get to the flashing portion because the section is still protected. So will get an error because the section is protected.

    Another way to this, is to verify that the flash was erased before trying to program it and you can do this with the MAP_FlashCtl_verifyMemory API

    Hopefully this helps.

      Davud

  • Hello DavidL,
    Thanks for replay.
    Just to be clear because I'am not sure if your saying that indeed I need to erase before program or saying yes you need to erase sector you've tried to program if MAP_FlashCtl_programMemory(src, dest, length) fails to program it so you don't get stack in do-while loop ? :D
    And thanks for the second part of answer didn't know that sectors are protected again after massErase.

    Regarding to MAP_FlashCtl_verifyMemory API. If i verify that flash is erased will MAP_FlashCtl_programMemory() for sure be successful because whole reason I'am doing this in do-while is because I don't know other reasons way would program memory fail if flash is erased and sector is unprotected ?

    Regards.

  • Hello,

      Sorry for the confusion.

    Ugljesa Popovic said:
    Just to be clear because I'm not sure if your saying that indeed I need to erase before program or saying yes you need to erase sector you've tried to program if MAP_FlashCtl_programMemory(src, dest, length) fails to program it so you don't get stack in do-while loop ? :D

    You will need to erase before program, but because you "unprotected all sectors that you wanted to program and then called MAP_FlashCtl_performMassErase", you will be only programming the erased sectors. In other words, the "MAP_FlashCtl_programMemory" will fail when it tries to program the protected sectors = non-erased sectors.

    Ugljesa Popovic said:
    And thanks for the second part of answer didn't know that sectors are protected again after massErase.

    Sorry for the confusion, the sectors will stay unprotected after the erase. That is why "MAP_FlashCtl_programMemory" will only program the unprotected sectors.

    Ugljesa Popovic said:
    Regarding to MAP_FlashCtl_verifyMemory API. If i verify that flash is erased will MAP_FlashCtl_programMemory() for sure be successful because whole reason I'am doing this in do-while is because I don't know other reasons way would program memory fail if flash is erased and sector is unprotected ?

    Not necessarily, in some cases there could an internal error related to program or erase endurance and the API will return a failure.

    Best regards,

      David

  • Hello,

    I closed this topic because I didn't wont to bother you anymore but I'am not fully satisfied with answer :D
    I know that I have to unprotect sectors and erase before program, I am using massErase on purpose because I don't wont to erase sector by sector and I know that program memory will fail if he tries to program protected sector. My main question, and you can look at first post on that do-while loop again, is :
    Watching now one unprotected previously erased sector that I want to program. Program memory API starts to program sector and lets say that it failed at the half of the sector for some reason. Because it failed there is no condition to exit loop and programMemory is called again.
    Will now programMemory API fail every time because half of sector is not erased or will this API "skip" half of this sector, seeing that data that he has to program is same as in flash, and continue programming second half of the sector with corresponding data ?

    Regards.

**Attention** This is a public forum