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.

CCS/MSP432P401R: TI-RTOS: Process Sync when erasing flash memory

Part Number: MSP432P401R

Tool/software: Code Composer Studio

Hi all,

I am testing erasing flash memory with "flash_mass_erase.c" in example. it works fine by itself in CCS.

To put it in my RTOS application, I amended two things:

  1. change main() to memwr_cmd() to make it callable function

  2. add sem_post(&semUART0) statement for process sync.

In the first run, I can find that BANK 1 SEGMENT 30 (0x3E000~0x3EFFF) and BANK 1 SEGMENT 31 (0x3F000~0x3FFFF) have correct value as expected.

    

In the first run, memwr_cmd() runs well.

In the second run, process sync has some problem.  I have another processes with same scheme and they runs very well.

#define BANK1_S30 0x3E000

/* Statics */
uint8_t patternArray[8192];

void memwr_cmd(void)
{
    /* Since this program has a huge buffer that simulates the calibration data,
     * halting the watch dog is done in the reset ISR to avoid a watchdog
     * timeout during the zero
     */

    /* Setting our MCLK to 48MHz for faster programming */
    MAP_PCM_setCoreVoltageLevel(PCM_VCORE1);
    FlashCtl_setWaitState(FLASH_BANK0, 1);
    FlashCtl_setWaitState(FLASH_BANK1, 1);
    MAP_CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_48);

    /* Initializing our buffer to a pattern of 0xA5 */
    memset(patternArray, 0xA5, 8192);

    //![Simple Flash Config]
    /* Unprotecting User Bank 1, Sectors 30 and 31  */
    MAP_FlashCtl_unprotectSector(FLASH_MAIN_MEMORY_SPACE_BANK1,
            FLASH_SECTOR30 | FLASH_SECTOR31);

    /* Trying a mass erase. Since we unprotected User Bank 1,
     * sectors 31 and 32, this should erase these sectors. If it fails, we
     * trap inside an infinite loop.
     */
    if(!MAP_FlashCtl_performMassErase())
        while(1);
    //![Simple Flash Config]

    /* Trying to program the filler data. If it fails, trap inside an infinite
       loop */
    if(!MAP_FlashCtl_programMemory (patternArray, (void*) BANK1_S30, 8192))
        while(1);

    /* Setting  sector 31 back to protected  */
    MAP_FlashCtl_protectSector(FLASH_MAIN_MEMORY_SPACE_BANK1,FLASH_SECTOR31);

    /* Performing the mass erase again. Now, since we protected Sector31, only
     * Sector 30 (0x3E000 - 0x3EFFF) should be erased. Set a breakpoint
     * after this call to observe the memory in the debugger.
     */
    if(!MAP_FlashCtl_performMassErase())
        while(1);

    sem_post(&semUART0);

    /* Deep Sleeping when not in use */
    while (1)
    {
        MAP_PCM_gotoLPM3();
    }
}

I guess this issue might be related with Deep Sleeping, but I am stuck with this.

Any help and advise would be appreciated.

HaeSeung

 

 

**Attention** This is a public forum