Other Parts Discussed in Thread: EK-TM4C123GXL
Following is the code where i have configured the timer0 of tm4c123gh6pm in Input Edge Time Mode. I am triggering events using the on-board switch of ek-tm4c123gxl. Events are detected but when i press the button. But i am not able to read the current value of timer using TimerValueGet() API. Is there any other API that returns the current value of timer.
#include<stdint.h>
#include<stdbool.h>
#include"driverlib/sysctl.h"
#include"driverlib/gpio.h"
#include"driverlib/interrupt.h"
#include"driverlib/timer.h"
#include"driverlib/pin_map.h"
#include"inc/tm4c123gh6pm.h"
#include"inc/hw_memmap.h"
uint32_t a=0,b;
int main(void) {
SysCtlClockSet(SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN|SYSCTL_USE_PLL|SYSCTL_SYSDIV_5);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
GPIOPinTypeTimer(GPIO_PORTB_BASE, GPIO_PIN_6);
GPIOPinConfigure(GPIO_PB6_T0CCP0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
GPIOPinTypeGPIOInput(GPIO_PORTF_BASE,GPIO_PIN_4);
GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_4,GPIO_STRENGTH_4MA,GPIO_PIN_TYPE_STD_WPU);
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
TimerConfigure(TIMER0_BASE, TIMER_CFG_SPLIT_PAIR|TIMER_CFG_A_CAP_TIME_UP);
TimerLoadSet(TIMER0_BASE, TIMER_A, 65000);
TimerControlEvent(TIMER0_BASE, TIMER_A, TIMER_EVENT_POS_EDGE);
IntEnable(INT_TIMER0A);
TimerIntEnable(TIMER0_BASE,TIMER_CAPA_EVENT);
TimerEnable(TIMER0_BASE,TIMER_A);
while(1){
b=TimerValueGet(TIMER0_BASE,TIMER_A);
SysCtlDelay(100);
}
}
void timer0_isr(void)
{
a++;
TimerIntClear(TIMER0_BASE,TIMER_CAPA_EVENT);
}