Hello,
Iam trying to operate Timer in one shot mode, turn on the on-board led after 1sec.
I wrote the code as follows:
I made the period is 1 sec so after time-out interrupt initialized, I turn on the led in the ISR.
#include <stdint.h>
#include <stdbool.h>
#include "inc/tm4c1294ncpdt.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/sysctl.h"
#include "driverlib/interrupt.h"
#include "driverlib/gpio.h"
#include "driverlib/timer.h"
//////////////////////////////////////////////////////////////////////////
int count = 0;
int main(void)
{
uint32_t ui32Period;
uint32_t ui32SysClkFreq;
//SET SYSTEM CLK
ui32SysClkFreq = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000);
//ENABLE PERIPHERALS
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
//CONFIGURE PERIPHERALS
GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE,GPIO_PIN_1);
TimerConfigure(TIMER0_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_ONE_SHOT);
//SET THE PERIOD OF THE TIMER
ui32Period = ui32SysClkFreq;
TimerLoadSet(TIMER0_BASE, TIMER_A, ui32Period -1);
//ENABLE INTERRUPTS
IntEnable(INT_TIMER0A);
TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
IntMasterEnable();
//ENABLE TIMERS
TimerEnable(TIMER0_BASE, TIMER_A);
while(1)
{
}
}
//ISR
void Timer0IntHandler(void)
{
// Clear the timer interrupt flag
TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
GPIOPinWrite(GPIO_PORTN_BASE,GPIO_PIN_1,0x2);
}
Thanks in advance.
Regards,
Badr.