I am very new to TIVA, and microprocessors in general, so I apologize is my question seems very basic. I have read the related workshop material and seen some example code but I still don't understand why my code is not working. I am feeding a PWM signal into GPIO Pin B6. I tried configuring two timers in capture mode, Timer0A is supposed to trigger an ISR at a rising edge, and TIMER0B is supposed to trigger an ISR at a falling edge. I have changed the corresponding startup file the way it is explained in the workshop, and I was able to make the workshop example work, however I can't seem to get the timer working in capture mode. When I debug, I can see the data in my GPIO PB6 register changing, but the ISR's are never called. Here is my code.
#include <stdint.h>
#include <stdbool.h>
#include <math.h>
#include <stdio.h>
#include <inttypes.h>
#include "driverlib/pin_map.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_gpio.h"
#include "inc/hw_qei.h"
#include "inc/hw_ssi.h"
#include "driverlib/sysctl.h"
#include "driverlib/interrupt.h"
#include "driverlib/timer.h"
#include "driverlib/fpu.h"
#include "driverlib/gpio.h"
#include "driverlib/debug.h"
#include "driverlib/pwm.h"
#include "driverlib/pin_map.h"
#include "driverlib/qei.h"
#include "driverlib/ssi.h"
#include "driverlib/rom.h"
#include "driverlib/systick.h"
#include "driverlib/uart.h"
#include "utils/uartstdio.h"
#include "inc/tm4c123gh6pm.h"
#include "driverlib/adc.h"
#include "driverlib/rom_map.h"
void RisingEdgeInt(void){
TimerIntClear(TIMER0_BASE, TIMER_CAPA_EVENT);
// Read the current state of the GPIO pin (blue LED) and
// write back the opposite state
if(GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_2))
{
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 0);
}
else
{
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 4);
}
}
void FallingEdgeInt(void){
TimerIntClear(TIMER0_BASE, TIMER_CAPB_EVENT);
// write back the opposite state
if(GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_2))
{
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 0);
}
else
{
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 4);
}
}
/*
* main.c
*/
int main(void) {
SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
MAP_GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_6, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
GPIOPinConfigure(GPIO_PB6_T0CCP0);
GPIOPinTypeTimer(GPIO_PORTB_BASE, GPIO_PIN_6);
//Enable GPIO clock
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
//Configure GPIO pins as output
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_TIMER0))
{
}
TimerConfigure(TIMER0_BASE, TIMER_CFG_A_CAP_TIME);
TimerConfigure(TIMER0_BASE, TIMER_CFG_B_CAP_TIME);
TimerControlEvent(TIMER0_BASE, TIMER_A, TIMER_EVENT_POS_EDGE);
TimerControlEvent(TIMER0_BASE, TIMER_B, TIMER_EVENT_NEG_EDGE);
TimerIntEnable(TIMER0_BASE, TIMER_CAPA_EVENT);
TimerIntEnable(TIMER0_BASE, TIMER_CAPB_EVENT);
TimerIntRegister(TIMER0_BASE, TIMER_A, RisingEdgeInt);
TimerIntRegister(TIMER0_BASE, TIMER_B, FallingEdgeInt);
TimerIntClear(TIMER0_BASE, TIMER_CAPA_EVENT);
TimerIntClear(TIMER0_BASE, TIMER_CAPB_EVENT);
//Enables the processor to respond to interrupts
IntMasterEnable();
IntEnable(INT_TIMER0A);
IntEnable(INT_TIMER0B);
//Start the timer
TimerEnable(TIMER0_BASE, TIMER_A);
TimerEnable(TIMER0_BASE, TIMER_B);
while(true){}
return 0;
}