Other Parts Discussed in Thread: TM4C129CNCZAD, , SEGGER
Hello,
we have an issue using the ‘Timer Compare Action Mode’ on the TM4C microcontroller and hope you can support us. The connected output pin is not affected at compare match time.
Ambient conditions:
- Target controller: TM4C129CNCZAD
- Currently used controller: TM4C129XNCZAD on DK-TM4C129X evaluation board
- Compiler: IAR Embedded Workbench for ARM 9.10.2.39460
Use case:
To control our physical process, we need several timers in combination with timer compare action mode to switch digital outputs at defined times in the future without processor action.
- Timer A and B are use individual in 16-bit mode
- Timers are configured as periodic with a timer interval load of 0xFFFF. Timers are free running and cannot be reinitialized during normal operation.
- Digital output must only be switched at compare time. Timer timeout must not affect the digital output. The physical process is asynchronous to the timer period.
Used configuration:
- TCACT in GPTMTnMR register is set to a non-zero value to configure the pin switching.
- TnAMS bit is set to zero: Capture or compare mode is enabled.
- For switching the output GPTMTnMATCHR register is set with the time for next switching.
- Timer interrupt is configured for timer-match interrupt
- GPIOs are connected to the timer using the MUX.
Issue / current behaviour:
- Timer match interrupt correctly occurs at compare match time. à OK
- The corresponding output is not switched at compare match time. à not OK
- The corresponding output is switched at timer timeout. à not OK
- All non-zero values of TCACT do not lead to an output pin action at compare match time.
Code extract:
void Timer1IntHandler(void) { // this port switch is only for testing the timer match ISR GPIOPinWrite(GPIO_PORTQ_BASE, GPIO_PIN_3, GPIO_PIN_3); TimerIntClear(TIMER1_BASE, TIMER_TIMA_MATCH); GPIOPinWrite(GPIO_PORTQ_BASE, GPIO_PIN_3, 0); } int main(void) { // // Run from the PLL at 120 MHz. // Note: SYSCTL_CFG_VCO_240 is a new setting provided in TivaWare 2.2.x and // later to better reflect the actual VCO speed due to SYSCTL#22. // ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_240), 120000000); // // Configure the device pins. // PinoutSet(); // // Enable the peripherals used by this example. // SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1); // // Enable processor interrupts. // IntMasterEnable(); TimerConfigure(TIMER1_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_PERIODIC | TIMER_CFG_A_ACT_TOGGLE); TimerLoadSet(TIMER1_BASE, TIMER_A, 0xFFFF); TimerMatchSet(TIMER1_BASE, TIMER_A, 30000); IntEnable(INT_TIMER1A); TimerIntEnable(TIMER1_BASE, TIMER_TIMA_MATCH); GPIOPinConfigure(GPIO_PD2_T1CCP0); GPIOPinTypeTimer(GPIO_PORTD_BASE, GPIO_PIN_2); // configure output for ISR testing GPIOPinTypeGPIOOutput(GPIO_PORTQ_BASE, GPIO_PIN_3); GPIOPinWrite(GPIO_PORTQ_BASE, GPIO_PIN_3, 0); // // Enable the timers. // TimerEnable(TIMER1_BASE, TIMER_A); // // Loop forever while the timers run. // while(1) { } }
We have the following questions:
- Is it possible to configure Timer Compare Action Mode in such a way that only compare match affects the corresponding output pin? Timer timeout must not affect the output pin.
- What error was made in the code sample so that the desired behaviour is not achieved.
Thank you very much for your support.
Best regards,
Markus Karas