Hi!
I'm currently working on a simple frequency counter which should count positive edges within a second wide timegate. The time gate signal is coming from an external device and triggers a gpio interrupt which is just working fine. The external edges are produced by the PWM0 module and teh frequency is between 11 and 12 Hz.
I configured wide timer #3 as an input edge counter. I'm a bit confused here but my idea is to read the timer value (the counted edges) using the TimerValueGet(...) function of TIVAWare in the 1 sec interrupt handler:
* readout timer value (edge count in this mode)
*edges = timer value - previous timer value
*previous timer value = timer value
I'm always getting zeroes here so I tried just to check out the timer value which gives me 0x000000FF and slowly decrementing by one after every 21 sec. Here is my code:
void Init_Capture_Timer(void){
/*
* Enable Capture Timer peripherial
*/
SysCtlPeripheralEnable(CAPTURE_TIMER_PH);
/*
* Configure 24 bit capture timer
*/
TimerConfigure(CAPTURE_TIMER_BASE, (TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_CAP_COUNT));
/*
* Capture on positive edges
*/
TimerControlEvent(CAPTURE_TIMER_BASE, TIMER_A, TIMER_EVENT_POS_EDGE);
/*
* Load and Match registers
*/
TimerLoadSet(CAPTURE_TIMER_BASE, TIMER_A, 0xFFFF);
TimerMatchSet(CAPTURE_TIMER_BASE, TIMER_A, 0);
/*
* Setup the interrupts for the timer timeouts.
*/
//IntEnable(CAPTURE_TIMERA_INT);
//TimerIntEnable(CAPTURE_TIMER_BASE, TIMER_CAPA_MATCH);
}
void Enable_Capture_Timer(void){
TimerEnable(CAPTURE_TIMER_BASE, TIMER_A);
}