Sorry I do not understand how the 4 SDK examples can help me. I looked at all four and the CTimer is setup as a timer and not a counter. I need a 32 bit hardware counter from an external pin. Maybe this cannot be done.
In the four programs, GetDefaultConfig is called to set the defaults before changing anything.
In all of the programs the config.mode is not changed to one of the edge modes.
/*! @brief List of Timer modes */
typedef enum _ctimer_timer_mode
{
kCTIMER_TimerMode = 0U, /* TC is incremented every rising APB bus clock edge */
kCTIMER_IncreaseOnRiseEdge, /* TC is incremented on rising edge of input signal */
kCTIMER_IncreaseOnFallEdge, /* TC is incremented on falling edge of input signal */
kCTIMER_IncreaseOnBothEdge /* TC is incremented on both edges of input signal */
} ctimer_timer_mode_t;
void CTIMER_GetDefaultConfig(ctimer_config_t *config)
{
assert(config);
/* Initializes the configure structure to zero. */
memset(config, 0, sizeof(*config));
/* Run as a timer */
config->mode = kCTIMER_TimerMode;
/* This field is ignored when mode is timer */
config->input = kCTIMER_Capture_0;
/* Timer counter is incremented on every APB bus clock */
config->prescale = 0;
}
simple_match.c
CTIMER_GetDefaultConfig(&config);
CTIMER_Init(CTIMER, &config);
simple_match_interrupt.c
CTIMER_GetDefaultConfig(&config);
CTIMER_Init(CTIMER, &config);
simple_pwm.c
CTIMER_GetDefaultConfig(&config);
timerClock = srcClock_Hz / (config.prescale + 1);
CTIMER_Init(CTIMER, &config);
simple_pwm_interrupt.c
CTIMER_GetDefaultConfig(&config);
timerClock = srcClock_Hz / (config.prescale + 1);
CTIMER_Init(CTIMER, &config);
What am I missing?
Thanks