Hello!
I'm trying to configure Timer 2 A and pin PF4 (T2CCP0) to work in capture mode. All i have to do is to capture 110 Hz frequency! The problem: When it runs the cmd TimerConfigure(TIMER2_BASE,TIMER_CFG_16_BIT_PAIR | TIMER_CFG_A_CAP_TIME); my stellaris get stuck in a interrupt routine called FaultISR.
Thx!
Here goes my codes
tBoolean Configura_Captura(void)
{
// T2CCP0 -> PF4 -> Timer 2 A
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
GPIOPinTypeTimer(GPIO_PORTF_BASE, GPIO_PIN_4);
GPIOPinConfigure(GPIO_PF4_T2CCP0);
GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_4,GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
TimerConfigure(TIMER2_BASE,TIMER_CFG_16_BIT_PAIR | TIMER_CFG_A_CAP_TIME);
TimerControlEvent(TIMER2_BASE,TIMER_A,TIMER_EVENT_POS_EDGE); //setup capture
TimerLoadSet(TIMER2_BASE,TIMER_A,0x0);
TimerIntEnable(TIMER2_BASE,TIMER_CAPA_EVENT);
TimerEnable(TIMER2_BASE,TIMER_A);
IntMasterEnable();
IntEnable(INT_TIMER2A);
return true;
}
Interruption routine
unsigned long static atual, anterior, periodo = 0;
void Timer2AIntHandler(void)
{
TimerIntClear(TIMER2_BASE,TIMER_CAPA_EVENT); //reset capture A interrupt flag
atual = TimerValueGet(TIMER2_BASE,TIMER_A); //read the capture value
periodo = atual - anterior;
anterior = atual;
}
my inclues.h file
#ifndef _INCLUDES_H_
#define _INCLUDES_H_
#include "inc/hw_types.h"
#include "inc/hw_memmap.h"
#include "inc/hw_ints.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "driverlib/timer.h"
#include "driverlib/pin_map.h"
#include "driverlib/interrupt.h"
#include "driverlib/uart.h"
#endif
my main function
int
main(void)
{
// 40 MHz system clock
SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
Configura_PWM(1000,500); // Configures my PWM
Configura_Captura();
IntMasterEnable();
Toca_PWM(1000); // while(1) inside here
}