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!