Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
LukeCY_Wei
Level 2
Level 2
25 sign-ins First like received 10 replies posted

Hi 

    My develop environment setup as below:

IDE: ADS(aurix development studio)

Library: iLLD

I used Infineon example code"Flash_Programming_1_KIT_TC275_LK" to erase/write Pflash, I found timer isr will stop around 40 seconds after erase/write PFlash operation, then timer isr will return to normal, have any advices?

Thanks.

 

 

 

int core0_main(void)
{
    IfxCpu_enableInterrupts();

    IfxScuWdt_disableCpuWatchdog(IfxScuWdt_getCpuWatchdogPassword());
    IfxScuWdt_disableSafetyWatchdog(IfxScuWdt_getSafetyWatchdogPassword());

    initms(1);

    while(1)
    {

        if(((TxTick)>5000)&&TestFlash==0)
        {
            TestFlash=1;
            writeProgramFlash();
        }

    }
    return (1);
}

 

 

 

 

 

void isrSTM1(void)
{
    IfxStm_increaseCompare(STM1, g_STMConf1.comparator, (uint32)g_ticksForMS);
    TxTick++;
}

void initms(short time)
{
    g_ticksForMS = IfxStm_getTicksFromMilliseconds(STM1,time);  //ms

    IfxStm_initCompareConfig(&g_STMConf1);           /* Initialize the configuration structure with default values   */

    g_STMConf1.triggerPriority = ISR_PRIORITY_STM1;   /* Set the priority of the interrupt                            */
    g_STMConf1.typeOfService = IfxSrc_Tos_cpu0;      /* Set the service provider for the interrupts                  */
    g_STMConf1.ticks = (uint32)g_ticksForMS;              /* Set the number of ticks after which the timer triggers an
                                                     * interrupt for the first time                                 */
    IfxStm_initCompare(STM1, &g_STMConf1);            /* Initialize the STM with the user configuration               */


}
void erasePFLASH(uint32 sectorAddr)
{
    /* Get the current password of the Safety WatchDog module */
    uint16 endInitSafetyPassword = IfxScuWdt_getSafetyWatchdogPasswordInline();

    /* Erase the sector */
    IfxScuWdt_clearSafetyEndinitInline(endInitSafetyPassword);      /* Disable EndInit protection                   */
    g_commandFromPSPR.eraseSectors(sectorAddr, PFLASH_NUM_SECTORS); /* Erase the given sector                       */
    IfxScuWdt_setSafetyEndinitInline(endInitSafetyPassword);        /* Enable EndInit protection                    */

    /* Wait until the sector is erased */
    g_commandFromPSPR.waitUnbusy(FLASH_MODULE, PROGRAM_FLASH_0);
}
void writePFLASH(uint32 startingAddr)
{
    uint32 page;                                                /* Variable to cycle over all the pages             */
    uint32 offset;                                              /* Variable to cycle over all the words in a page   */

    /* Get the current password of the Safety WatchDog module */
    uint16 endInitSafetyPassword = IfxScuWdt_getSafetyWatchdogPasswordInline();

    /* Write all the pages */
    for(page = 0; page < PFLASH_NUM_PAGE_TO_FLASH; page++)              /* Loop over all the pages                  */
    {
        uint32 pageAddr = startingAddr + (page * PFLASH_PAGE_LENGTH);   /* Get the address of the page              */

        /* Enter in page mode */
        g_commandFromPSPR.enterPageMode(pageAddr);

        /* Wait until page mode is entered */
        g_commandFromPSPR.waitUnbusy(FLASH_MODULE, PROGRAM_FLASH_0);

        /* Write 32 bytes (8 double words) into the assembly buffer */
        for(offset = 0; offset < PFLASH_PAGE_LENGTH; offset += 0x8)     /* Loop over the page length                */
        {
            g_commandFromPSPR.load2X32bits(pageAddr, DATA_TO_WRITE, DATA_TO_WRITE); /* Load 2 words of 32 bits each */
        }

        /* Write the page */
        IfxScuWdt_clearSafetyEndinitInline(endInitSafetyPassword);      /* Disable EndInit protection               */
        g_commandFromPSPR.writePage(pageAddr);                          /* Write the page                           */
        IfxScuWdt_setSafetyEndinitInline(endInitSafetyPassword);        /* Enable EndInit protection                */

        /* Wait until the page is written in the Program Flash memory */
        g_commandFromPSPR.waitUnbusy(FLASH_MODULE, PROGRAM_FLASH_0);
    }
}

 

 

 

 

 

void writeProgramFlash()
{
    boolean interruptState = IfxCpu_disableInterrupts(); /* Get the current state of the interrupts and disable them*/

    /* Copy all the needed functions to the PSPR memory to avoid overwriting them during the flash execution */
    copyFunctionsToPSPR();

    /* Erase the Program Flash sector before writing */
    g_commandFromPSPR.eraseFlash(0xA0100000);

    /* Write the Program Flash */
    g_commandFromPSPR.writeFlash(0xA0100000);

    IfxCpu_restoreInterrupts(interruptState);            /* Restore the interrupts state                            */

}

 

 

 

0 Likes
1 Solution
Giraffe1492
Level 5
Level 5
25 sign-ins 25 likes received 10 solutions authored
It seems that you are experiencing an issue with the timer ISR stopping for around 40 seconds after erasing/writing PFlash operation. This might be due to the fact that the flash operations are time-consuming and might be affecting the timer ISR.
One possible solution is to use a higher priority interrupt for the timer ISR. You can change the priority of the interrupt by modifying the `ISR_PRIORITY_STM1` value in the `initms()` function. For example, you can set it to a higher priority value (lower numerical value) like this:
```html g_STMConf1.triggerPriority = 1; /* Set the priority of the interrupt */ ```
Another approach is to use a different timer module for the timer ISR, which is not affected by the flash operations. You can refer to the [AURIX™ Microcontroller User Manual](https://www.infineon.com/dgdl/Infineon-AURIX_TC27x-UM-v1.6-UM-v01_00-EN.pdf?fileId=db3a30433a0f3b010...) for more information on available timer modules and their configurations.
Please note that these are just suggestions, and you might need to adjust the code according to your specific requirements and hardware setup.https://www.infineon.com/cms/en/product/microcontroller/32-bit-industrial-microcontroller-based-on-a...
https://www.infineon.com/cms/en/product/microcontroller/32-bit-industrial-microcontroller-based-on-a...

 

View solution in original post

1 Reply
Giraffe1492
Level 5
Level 5
25 sign-ins 25 likes received 10 solutions authored
It seems that you are experiencing an issue with the timer ISR stopping for around 40 seconds after erasing/writing PFlash operation. This might be due to the fact that the flash operations are time-consuming and might be affecting the timer ISR.
One possible solution is to use a higher priority interrupt for the timer ISR. You can change the priority of the interrupt by modifying the `ISR_PRIORITY_STM1` value in the `initms()` function. For example, you can set it to a higher priority value (lower numerical value) like this:
```html g_STMConf1.triggerPriority = 1; /* Set the priority of the interrupt */ ```
Another approach is to use a different timer module for the timer ISR, which is not affected by the flash operations. You can refer to the [AURIX™ Microcontroller User Manual](https://www.infineon.com/dgdl/Infineon-AURIX_TC27x-UM-v1.6-UM-v01_00-EN.pdf?fileId=db3a30433a0f3b010...) for more information on available timer modules and their configurations.
Please note that these are just suggestions, and you might need to adjust the code according to your specific requirements and hardware setup.https://www.infineon.com/cms/en/product/microcontroller/32-bit-industrial-microcontroller-based-on-a...
https://www.infineon.com/cms/en/product/microcontroller/32-bit-industrial-microcontroller-based-on-a...