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.

TM4C1294NCPDT: Issues with TIMER_CFG_A_ACT_SETCLRTO

Part Number: TM4C1294NCPDT

I have an interesting issue with the timer on a TM4C that I have been trying to resolve.

TIMER_CFG_A_ACT_TOGGLE works exactly as expected, but TIMER_CFG_A_ACT_SETCLRTO does nothing. The output stays low. After trying TIMER_CFG_A_ACT_SETTOGTO andTIMER_CFG_A_ACT_CLRTOGTO, it appears that the action on timeout is working correctly, but the immediate set and clear do not work.

#include <stdint.h>
#include <stdbool.h>

#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/timer.h"
#include "inc/hw_memmap.h"

int main(void)
{
    SysCtlClockFreqSet(SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480, 120000000);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOM);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER5);

    while (!SysCtlPeripheralReady(SYSCTL_PERIPH_TIMER5));
    while (!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOM));
    GPIOPinTypeTimer(GPIO_PORTM_BASE, GPIO_PIN_6);
    GPIOPinConfigure(GPIO_PM6_T5CCP0);

    while(1)
    {
        TimerConfigure(TIMER5_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_ONE_SHOT | TIMER_CFG_A_ACT_SETTO);
        TimerLoadSet(TIMER5_BASE, TIMER_A, 2400);
        TimerEnable(TIMER5_BASE, TIMER_A);
        SysCtlDelay(400000);
    }

	return 0;
}

  • In the example code you posted you did not choose an immediate action, you used "TIMER_CFG_A_ACT_SETTO".
  • Hi Bob

    I have tried several different options for the code. When I copied and pasted it happened to be TIMER_CFG_A_ACT_SETTO. Here are the behaviors I am seeing for the different options:

    TIMER_CFG_A_ACT_SETTO: Sets on timeout

    TIMER_CFG_A_ACT_TOGGLE: Toggles on timeout.

    TIMER_CFG_A_ACT_SETTOGTO: Toggles on timeout, but the set immediately never happens.

    TIMER_CFG_A_ACT_CLRSETTO: Sets on timeout the first time, but never clears on the next pass through the loop.

    The pattern seams to be that the timeout action works correctly, but not the immediate action.

    I've got a scope with logic analyzer and I've tried toggling a GPIO pin to signal when the call to TimerEnable happens and when the change in CCP output happens.

  • I did some more testing, and it looks like I'm getting a single pulse on startup during the first pass through the loop, but not on subsequent passes.

    Is there some reset I have to do on the timer?

    I'm trying to create asynchronous pulses, which is why PWM doesn't work for me.
  • Took a more fine read of the datasheet details:

    13.4.1 One-Shot/Periodic Timer Mode The GPTM is configured for One-Shot and Periodic modes by the following sequence:

    1. Ensure the timer is disabled (the TnEN bit in the GPTMCTL register is cleared) before making any changes.

    2. Write the GPTM Configuration Register (GPTMCFG) with a value of 0x0000.0000.

    It appears that item two has to be done for each invocation of one-shot mode.

    I just used TimerConfigure(TIMER5_BASE, 0) to reset, but it will also overwrite TAMR and TBMR. One could access the GPTMCFG register directly if so desired.