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.

MSP432E401Y: Different Timer Behavior in Debug Session versus. Non-Debug Session

Part Number: MSP432E401Y


Hello,

We are seeing very strange behavior relating to the edge count timer function of the MSP432E4 microcontroller. The number of edges counted is correct when we program the microcontroller using the Debug session in Code Composer Studio (about 44000 edges within a 200ms time window). However, as soon as we leave the debug session (either clicking terminate in CCS or power cycling the MCU) the number of edges counted is incorrect, about 35 times less than what we expect (about 1200 edges counted). We can confirm that the input signal to the timer pin is not changing. All other functionality is present when not in a debug session. Below are the relevant functions the software engineer has set up and told me to include with this post. Being on the hardware side of this project, please let me know if there is something I can clarify with the software engineer and add on to this post.

The clock setup and timer setup functions are below. The sample period is the time window we want to count edges without overflowing, in our case 200ms:

void HVBoard::ClockSetUp()

{

    uint32_t SamplePeriod;

 

    SamplePeriod = 200000/Clock_tickPeriod; // 200 ms

 

    Clock_Params_init(&clkParams);

    clkParams.period = SamplePeriod;

    clkParams.startFlag = TRUE;

 

    /* Construct a periodic Clock Instance */

    Clock_construct(&clk0Struct, (Clock_FuncPtr)LevelSensingCounter, SamplePeriod, &clkParams);

}

 

void HVBoard::LevelSensingTimerSetUp()

{

    /* Enable the clock to the GPIO Port M and wait for it to be ready */

    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOM);

    while(!(SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOM)));

    //* Configure the GPIO PM6 as Timer 5 CCP0 pin (Edge Count Input Pin) */

    MAP_GPIOPinConfigure(GPIO_PM6_T5CCP0);

    MAP_GPIOPinTypeTimer(GPIO_PORTM_BASE, GPIO_PIN_6);

    /* Enable the Timer 5 */

    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER5);

    while(!(SysCtlPeripheralReady(SYSCTL_PERIPH_TIMER5)));

    /* Configure the Timer 5 to work in Edge Count Mode */

    MAP_TimerConfigure(TIMER5_BASE, TIMER_CFG_A_CAP_COUNT);

    /* Count positive edges */

    MAP_TimerControlEvent(TIMER5_BASE, TIMER_A, TIMER_EVENT_POS_EDGE);

    /* Load Timer 5 with the value to count */

    MAP_TimerLoadSet(TIMER5_BASE, TIMER_A, LS_MAX_COUNT);

}

 

void LevelSensingCounter()

{

    MAP_TimerDisable(TIMER5_BASE, TIMER_A);

    LevelSensingCount = MAP_TimerValueGet(TIMER5_BASE, TIMER_A);

    MAP_TimerLoadSet(TIMER5_BASE, TIMER_A, LS_MAX_COUNT);

    MAP_TimerEnable(TIMER5_BASE, TIMER_A);

}

Once Clock_construct() is created and enabled (clkParams.startFlag = TRUE;) it will call above function every time after counting SamplePeriod.

Please let us know what the problem may be. Thank you!

  • Hello,

    We found out what was causing the problem! There is a heartbeat LED function that uses ClockP_usleep(). When just having a solid LED there is no problem, but when using ClockP_usleep() to make the LED blink on and off we see the incorrect readings. Below is the function and setup. This is in the file where the software engineer sets up threads:

    static TF_THREAD_STRUCT tfUSBRxProcessThread;
    static tf_uint8         tfUSBRxProcessThreadStack[0x800];
    
    static TF_THREAD_STRUCT tfUSBTxProcessThread;
    static tf_uint8         tfUSBTxProcessThreadStack[0x200];
    
    static TF_THREAD_STRUCT hvBoardStatusThread;
    static tf_uint8         hvBoardStatusThreadStack[MAIN_HVBOARD_STATUS_STACK_SIZE];
    
    static TF_THREAD_STRUCT hvBoardCanaryLEDProcessThread;
    static tf_uint8         hvBoardCanaryLEDProcessThreadStack[0x200];

    void hvBoardCanaryLEDProcess (void * arg0, void * arg1)
    {
        while (true)
        {
           GPIO_Set(TestLEDPin);
    //       ClockP_usleep(900000);
    //       GPIO_Reset(TestLEDPin);
    //       ClockP_usleep(200000);
    //       GPIO_Set(TestLEDPin);
    //       ClockP_usleep(200000);
    //       GPIO_Reset(TestLEDPin);
    //       ClockP_usleep(200000);
    //       GPIO_Set(TestLEDPin);
    //       ClockP_usleep(200000);
    //       GPIO_Reset(TestLEDPin);
    //       ClockP_usleep(900000);
        }
    }

    void CreateThreads(void)
    {
    
        tfUSBRxProcessThread.threadStack = tfUSBRxProcessThreadStack;
        tfUSBRxProcessThread.threadStackSize = sizeof(tfUSBRxProcessThreadStack);
        tfUSBRxProcessThread.threadPriority = USB_Rx_Thread_Priority;
        TfOsThreadCreate(&tfUSBRxProcessThread,
                USBRxProcess,
                nullptr,
                nullptr,
                "USB Receive Thread");
    
        tfUSBTxProcessThread.threadStack = tfUSBTxProcessThreadStack;
        tfUSBTxProcessThread.threadStackSize = sizeof(tfUSBTxProcessThreadStack);
        tfUSBTxProcessThread.threadPriority = USB_TX_Thread_Priority;
        TfOsThreadCreate(&tfUSBTxProcessThread,
                USBTxProcess,
                nullptr,
                nullptr,
                "USB TX Thread");
    
        hvBoardStatusThread.threadStack = hvBoardStatusThreadStack;
        hvBoardStatusThread.threadStackSize = sizeof(hvBoardStatusThreadStack);
        hvBoardStatusThread.threadPriority = HVBoard_Status_Thread_Priority;
        TfOsThreadCreate(&hvBoardStatusThread,
                HVBoardStatus,
                nullptr,
                nullptr,
                "HV Board Status Thread");
    
        hvBoardCanaryLEDProcessThread.threadStack = hvBoardCanaryLEDProcessThreadStack;
        hvBoardCanaryLEDProcessThread.threadStackSize = sizeof(hvBoardCanaryLEDProcessThreadStack);
        hvBoardCanaryLEDProcessThread.threadPriority = HVBoard_CanaryLED_Thread_Priority;
        TfOsThreadCreate(&hvBoardCanaryLEDProcessThread,
                hvBoardCanaryLEDProcess,
                nullptr,
                nullptr,
                "HV Board Canary LED Thread");
    }

    There seems to be a prioritization issue possibly?

  • I think you are going on the right way, Congratulations

        Johann

**Attention** This is a public forum