SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
GPIOPinTypeUART(GPIO_PORTD_BASE, GPIO_PIN_4 | GPIO_PIN_5);
GPIOPinConfigure(GPIO_PD4_U6RX);
GPIOPinConfigure(GPIO_PD5_U6TX);
UARTConfigSetExpClk(UART6_BASE, SysCtlClockGet(),115200,(UART_CONFIG_WLEN_8|UART_CONFIG_STOP_ONE|UART_CONFIG_PAR_NONE));
//UART Init
IntEnable(INT_UART6); //enable the UART interrupt
UARTIntEnable(UART6_BASE, UART_INT_RX|UART_INT_RT); //only enable RX interrupts
IntRegister(INT_UART6, UART6IntHandler);
//100=1us 200000=2ms
uint32_t TheSysClock;
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER3);
TheSysClock = SysCtlClockGet();
TimerConfigure(TIMER3_BASE , TIMER_CFG_PERIODIC);
TimerLoadSet(TIMER3_BASE, TIMER_A, (TheSysClock-1)/500); //500=2ms TheSysClock是1s还是3s
TimerEnable(TIMER3_BASE,TIMER_A);
IntEnable(INT_TIMER3A);
TimerIntEnable(TIMER3_BASE, TIMER_TIMA_TIMEOUT);
IntMasterEnable();
IntRegister(INT_TIMER3A, IntTimer3Handler);
// IntPriorityGroupingSet(NVIC_PriorityGroup_0);
//IntPrioritySet(INT_TIMER0A, 0x00);
Susan Yang:
您的图片未能成功上传,能否请您重新上传一下?
另外能否详细说明一下您现在的问题并给出具体的错误信息?
xyz549040622:
你是不是没有把中断函数在启动文件中注册呢?
xyz549040622:
回复 user5316406:
需要,你需要把IntTimer3Handler在启动文件中注册才可以的,类似下面这样的注册
#pragma DATA_SECTION(g_pfnVectors, ".intvecs") void (* const g_pfnVectors[])(void) = {(void (*)(void))((uint32_t)&__STACK_TOP),// The initial stack pointerResetISR,// The reset handlerNmiSR,// The NMI handlerFaultISR,// The hard fault handlerIntDefaultHandler,// The MPU fault handlerIntDefaultHandler,// The bus fault handlerIntDefaultHandler,// The usage fault handler0,// Reserved0,// Reserved0,// Reserved0,// ReservedIntDefaultHandler,// SVCall handlerIntDefaultHandler,// Debug monitor handler0,// ReservedIntDefaultHandler,// The PendSV handlerIntDefaultHandler,// The SysTick handlerIntDefaultHandler,// GPIO Port AIntDefaultHandler,// GPIO Port BIntDefaultHandler,// GPIO Port CIntDefaultHandler,// GPIO Port DIntDefaultHandler,// GPIO Port EIntDefaultHandler,// UART0 Rx and TxIntDefaultHandler,// UART1 Rx and TxIntDefaultHandler,// SSI0 Rx and TxIntDefaultHandler,// I2C0 Master and SlaveIntDefaultHandler,// PWM FaultIntDefaultHandler,// PWM Generator 0IntDefaultHandler,// PWM Generator 1IntDefaultHandler,// PWM Generator 2IntDefaultHandler,// Quadrature Encoder 0IntDefaultHandler,// ADC Sequence 0IntDefaultHandler,// ADC Sequence 1IntDefaultHandler,// ADC Sequence 2IntDefaultHandler,// ADC Sequence 3IntDefaultHandler,// Watchdog timerTimer0IntHandler,// Timer 0 subtimer AIntDefaultHandler,// Timer 0 subtimer BTimer1IntHandler,// Timer 1 subtimer AIntDefaultHandler,// Timer 1 subtimer BIntDefaultHandler,// Timer 2 subtimer AIntDefaultHandler,// Timer 2 subtimer BIntDefaultHandler,// Analog Comparator 0IntDefaultHandler,// Analog Comparator 1IntDefaultHandler,// Analog Comparator 2IntDefaultHandler,// System Control (PLL, OSC, BO)IntDefaultHandler,// FLASH ControlIntDefaultHandler,// GPIO Port FIntDefaultHandler,// GPIO Port GIntDefaultHandler,// GPIO Port HIntDefaultHandler,// UART2 Rx and TxIntDefaultHandler,// SSI1 Rx and TxIntDefaultHandler,// Timer 3 subtimer AIntDefaultHandler,// Timer 3 subtimer BIntDefaultHandler,// I2C1 Master and SlaveIntDefaultHandler,// Quadrature Encoder 1IntDefaultHandler,// CAN0IntDefaultHandler,// CAN10,// Reserved0,// ReservedIntDefaultHandler,// HibernateIntDefaultHandler,// USB0IntDefaultHandler,// PWM Generator 3IntDefaultHandler,// uDMA Software TransferIntDefaultHandler,// uDMA ErrorIntDefaultHandler,// ADC1 Sequence 0IntDefaultHandler,// ADC1 Sequence 1IntDefaultHandler,// ADC1 Sequence 2IntDefaultHandler,// ADC1 Sequence 30,// Reserved0,// ReservedIntDefaultHandler,// GPIO Port JIntDefaultHandler,// GPIO Port KIntDefaultHandler,// GPIO Port LIntDefaultHandler,// SSI2 Rx and TxIntDefaultHandler,// SSI3 Rx and TxIntDefaultHandler,// UART3 Rx and TxIntDefaultHandler,// UART4 Rx and TxIntDefaultHandler,// UART5 Rx and TxIntDefaultHandler,// UART6 Rx and TxIntDefaultHandler,// UART7 Rx and Tx0,// Reserved0,// Reserved0,// Reserved0,// ReservedIntDefaultHandler,// I2C2 Master and SlaveIntDefaultHandler,// I2C3 Master and SlaveIntDefaultHandler,// Timer 4 subtimer AIntDefaultHandler,// Timer 4 subtimer B0,// Reserved0,// Reserved0,// Reserved0,// Reserved0,// Reserved0,// Reserved0,// Reserved0,// Reserved0,// Reserved0,// Reserved0,// Reserved0,// Reserved0,// Reserved0,// Reserved0,// Reserved0,// Reserved0,// Reserved0,// Reserved0,// Reserved0,// ReservedIntDefaultHandler,// Timer 5 subtimer AIntDefaultHandler,// Timer 5 subtimer BIntDefaultHandler,// Wide Timer 0 subtimer AIntDefaultHandler,// Wide Timer 0 subtimer BIntDefaultHandler,// Wide Timer 1 subtimer AIntDefaultHandler,// Wide Timer 1 subtimer BIntDefaultHandler,// Wide Timer 2 subtimer AIntDefaultHandler,// Wide Timer 2 subtimer BIntDefaultHandler,// Wide Timer 3 subtimer AIntDefaultHandler,// Wide Timer 3 subtimer BIntDefaultHandler,// Wide Timer 4 subtimer AIntDefaultHandler,// Wide Timer 4 subtimer BIntDefaultHandler,// Wide Timer 5 subtimer AIntDefaultHandler,// Wide Timer 5 subtimer BIntDefaultHandler,// FPU0,// Reserved0,// ReservedIntDefaultHandler,// I2C4 Master and SlaveIntDefaultHandler,// I2C5 Master and SlaveIntDefaultHandler,// GPIO Port MIntDefaultHandler,// GPIO Port NIntDefaultHandler,// Quadrature Encoder 20,// Reserved0,// ReservedIntDefaultHandler,// GPIO Port P (Summary or P0)IntDefaultHandler,// GPIO Port P1IntDefaultHandler,// GPIO Port P2IntDefaultHandler,// GPIO Port P3IntDefaultHandler,// GPIO Port P4IntDefaultHandler,// GPIO Port P5IntDefaultHandler,// GPIO Port P6IntDefaultHandler,// GPIO Port P7IntDefaultHandler,// GPIO Port Q (Summary or Q0)IntDefaultHandler,// GPIO Port Q1IntDefaultHandler,// GPIO Port Q2IntDefaultHandler,// GPIO Port Q3IntDefaultHandler,// GPIO Port Q4IntDefaultHandler,// GPIO Port Q5IntDefaultHandler,// GPIO Port Q6IntDefaultHandler,// GPIO Port Q7IntDefaultHandler,// GPIO Port RIntDefaultHandler,// GPIO Port SIntDefaultHandler,// PWM 1 Generator 0IntDefaultHandler,// PWM 1 Generator 1IntDefaultHandler,// PWM 1 Generator 2IntDefaultHandler,// PWM 1 Generator 3IntDefaultHandler// PWM 1 Fault };