#include <stdint.h>
#include <stdbool.h>
#include "inc/tm4c123gh6pm.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"
#include <stdbool.h>
#include "inc/tm4c123gh6pm.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"
void Timer0BIntHandler(void);
int main(void)
{
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
//不分频,使用振荡器,外部晶振16MHZ,MOSC作为振荡器源,系统时钟16MHZ
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
//使能GPIOF外设
GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_4);//PA4设置为输出
GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_4,GPIO_PIN_4);//向PA4写1
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
//使能TIMER0
//TimerConfigure(TIMER0_BASE, TIMER_CFG_ONE_SHOT);//单次计数模式
TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);//周期性计数模式
TimerLoadSet(TIMER0_BASE, TIMER_A, 0x01E84800);//
IntEnable(INT_TIMER0A);
//使能TIMER0A
TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
//TIMEOUT标志位触发中断
IntMasterEnable();
//master interrupt enable API for all interrupts
TimerEnable(TIMER0_BASE, TIMER_A);
TimerIntRegister(TIMER0_BASE,TIMER_A,Timer0BIntHandler);
while(1)
{
}
}
{
}
}
void Timer0BIntHandler(void)
{ //清除定时器中断标志
TimerIntClear(TIMER0_BASE, TIMER_TIMB_TIMEOUT);
GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_4,
(0x10^GPIOPinRead(GPIO_PORTA_BASE,GPIO_PIN_4)));
}