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.

Tiva C WTimer0 Capture not work



Hi,

I would like to configure the TIMER0 to capture multiple pulses. I use the TIMER A as capture and TIMER B as normal counter to generate an interrupt in 200ms. The interrupt occurs but I can't read the value of TIMER A, It doesn't change. 

Here follows my code:

--------------------------------------------------------------------------------------------------------------------------------------------------------
#include "conf.h"
int main(void)
{
SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
PortFunctionInit();
TimerFunctionInit();
while(1){
}
}
--------------------------------------------------------------------------------------------------------------------------------------------------------
Here, the conf.h file:
--------------------------------------------------------------------------------------------------------------------------------------------------------

#ifndef __CONF_H__
#define __CONF_H__

#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_gpio.h"
#include "inc/hw_types.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_memmap.h"
#include "inc/hw_gpio.h"
#include "sysctl.h"
#include "pin_map.h"
#include "rom_map.h"
#include "gpio.h"
#include "adc.h"
#include "pwm.h"
#include "qei.h"
#include "timer.h"

#define PWM_FREQ 12000
#define PWM_PRDO 80000000/PWM_FREQ

extern void PortFunctionInit(void);

extern void ADCFunctionInit(void);

extern void PWMFunctionInit(void);
extern void TimerFunctionInit(void);
extern void interrupt ADC0_0_Int(void);
extern void interrupt TIMER0_B_Int(void);

#endif // __CONF_H__

And here, other functions:

void TimerFunctionInit()
{
//TIMER0
TimerClockSourceSet(WTIMER0_BASE, TIMER_CLOCK_SYSTEM);
TimerConfigure(WTIMER0_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_CAP_TIME | TIMER_CFG_B_PERIODIC);
TimerControlEvent(WTIMER0_BASE, TIMER_A, TIMER_EVENT_NEG_EDGE);

TimerLoadSet(WTIMER0_BASE, TIMER_B, 80000000/5);

TimerIntRegister(WTIMER0_BASE, TIMER_B, TIMER0_B_Int);

TimerIntEnable(WTIMER0_BASE, TIMER_TIMB_TIMEOUT);
TimerEnable(WTIMER0_BASE, (TIMER_A | TIMER_B));

}

void PortFunctionInit(void)
{

SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_QEI0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
SysCtlPeripheralEnable(SYSCTL_PERIPH_WTIMER0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2);

GPIOPinConfigure(GPIO_PB7_T0CCP1);
GPIOPinTypeTimer(GPIO_PORTB_BASE, GPIO_PIN_7);

GPIOPinConfigure(GPIO_PB6_T0CCP0);

GPIOPinTypeTimer(GPIO_PORTB_BASE, GPIO_PIN_6);

}

--------------------------------------------------------------------------------------------------------------------------------------------------------