int main(void)
{
//sys config
SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_USE_PLL
|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
SysCtlDelay(200);
//GPIO config
GPIOPinTypeTimer(GPIO_PORTB_BASE, GPIO_PIN_7);
GPIOPinConfigure(GPIO_PB7_T0CCP1);
GPIODirModeSet(GPIO_PORTB_BASE,GPIO_PIN_7,GPIO_DIR_MODE_IN);
//Timer config
TimerConfigure(TIMER0_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_B_CAP_TIME_UP);
TimerControlEvent(TIMER0_BASE, TIMER_B, TIMER_EVENT_POS_EDGE);
//Int config
IntEnable(INT_TIMER0B);
TimerIntEnable(TIMER0_BASE, TIMER_CAPB_EVENT);
IntMasterEnable();
TimerEnable(TIMER0_BASE, TIMER_B);
while(1);
}
void Timer0B_Int_Handler()
{
TimerIntClear(TIMER0_BASE, TIMER_CAPB_EVENT);
GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_2, GPIO_PIN_2);
GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_3, GPIO_PIN_3);
SysCtlDelay(SysCtlClockGet() /10);
}
已经在startup_ccs.c中添加声明了中断函数。
yukun he:
手动给PB7接入3.3V高电平,无法进入中断。。。
yukun he:
搞好了,中断可以进去了,详见csdn博客 http://blog.csdn.net/a826319028/article/details/27370905