在startup.c中已注册Timer0AIntHandler中断,但调试时进不了中断
#include "C:/StellarisWare/inc/hw_ints.h"
#include "C:/StellarisWare/inc/hw_memmap.h"
#include "C:/StellarisWare/inc/hw_types.h"
// #include "C:/StellarisWare/driverlib/debug.h"
#include "C:/StellarisWare/driverlib/interrupt.h"
#include "C:/StellarisWare/driverlib/sysctl.h"
#include "C:/StellarisWare/driverlib/timer.h"
#include "C:/StellarisWare/grlib/grlib.h"
#include "C:/Program Files/IAR SystemsEmbedded Workbench 6.0 Kickstart/arm/examples/TexasInstruments/Stellaris/boards/dk-lm3s9b96/drivers/kitronix320x240x16_ssd2119_8bit.h"
#include "C:/Program Files/IAR SystemsEmbedded Workbench 6.0 Kickstart/arm/examples/TexasInstruments/Stellaris/boards/dk-lm3s9b96/drivers/set_pinout.h"
#include "C:/Program Files/IAR SystemsEmbedded Workbench 6.0 Kickstart/arm/examples/TexasInstruments/Stellaris/driverlib/gpio.h"
#include "C:/StellarisWare/driverlib/ssi.h"
#include "C:/StellarisWare/inc/hw_ssi.h"
#include "C:/StellarisWare/driverlib/can.h"
#include "C:/StellarisWare/inc/hw_can.h"
#include "C:/StellarisWare/driverlib/udma.h"
#include "C:/StellarisWare/inc/hw_gpio.h"
#include "C:/StellarisWare/driverlib/gpio.h"
// 定时器的中断服务函数
void Timer0AIntHandler(void)
{
unsigned char ucVal;
unsigned long ulStatus;
ulStatus = TimerIntStatus(TIMER0_BASE, true); // 读取中断状态
TimerIntClear(TIMER0_BASE, ulStatus); // 清除中断状态,重要!
if (ulStatus & TIMER_TIMA_TIMEOUT) // 如果是Timer超时中断
{
ucVal = GPIOPinRead(GPIO_PORTD_BASE, GPIO_PIN_4 ); // 反转LED
GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_4, ~ucVal);
}
}
main(void)
{
//jtagWait();
//
//
//设置系统时钟为50Mhz
SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
SysCtlClockGet();
PinoutSet();
SysCtlPeripheralReset(SYSCTL_PERIPH_TIMER0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); // 使能Timer模块
TimerConfigure(TIMER0_BASE, TIMER_CFG_16_BIT_PAIR | // 配置Timer为16位周期定时器
TIMER_CFG_A_PERIODIC);
GPIOPinTypeTimer(TIMER0_BASE,TIMER_A);//GPIO_PIN_4,GPIO_DIR_MODE_OUT);
GPIODirModeSet(GPIO_PORTD_BASE, GPIO_PIN_4, GPIO_DIR_MODE_OUT);
GPIOPadConfigSet(GPIO_PORTD_BASE, GPIO_PIN_4, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_4, 0xff);
TimerLoadSet(TIMER0_BASE, TIMER_A, 300000); // 设置Timer初值,定时500ms
TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT); // 使能Timer超时中断
IntEnable(INT_TIMER0A); // 使能Timer中断
IntMasterEnable(); // 使能处理器中断
TimerEnable(TIMER0_BASE, TIMER_A); // 使能Timer计数
while(1)
{}
}
此帖出自
小平头技术问答
你才是楼主
一周热门 更多>