This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

当同时打开同一个定时器的AB中断时为什么只有A能进入中断,B不能

/*
 * user.c
 *
 *  Created on: 2018年8月6日
 *      Author: Peng
 */

#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>

#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/timer.h"
#include "inc/hw_memmap.h"
#include "inc/hw_timer.h"
#include "inc/tm4c123gh6pm.h"
#define LED_R(n)	(n?GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_1,GPIO_PIN_1):GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_1,~GPIO_PIN_1))
#define LED_B(n)	(n?GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_2,GPIO_PIN_2):GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_2,~GPIO_PIN_2))
#define LED_G(n)	(n?GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_3,GPIO_PIN_3):GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_3,~GPIO_PIN_3))


void TIMER1A_Interrupt(void);
void TIMER1B_Interrupt(void);
int main(void)
{
	uint32_t	TheSysClock=0;
	uint8_t		R_flag=0;
	SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
	TheSysClock=SysCtlClockGet();

	//使能F引脚
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
	SysCtlDelay(TheSysClock/3000);
	//配置三色LED引脚为输出
	GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);
	SysCtlDelay(TheSysClock/3000);
	LED_R(1);
	LED_B(1);
	LED_G(1);
	SysCtlDelay(TheSysClock/3000);
	LED_R(0);
	LED_B(0);
	LED_G(0);
	SysCtlDelay(TheSysClock/3000);

	//定时器使能
	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);

	//TIMER1A B中断注册
	TimerIntRegister(TIMER1_BASE,TIMER_A,TIMER1A_Interrupt);
	TimerIntRegister(TIMER1_BASE,TIMER_B,TIMER1B_Interrupt);
	//TIMER1A B中断配置


	TimerConfigure(TIMER1_BASE,TIMER_CFG_A_PERIODIC);
	TimerLoadSet(TIMER1_BASE,TIMER_A,TheSysClock/2-1);	//500ms
	TimerConfigure(TIMER1_BASE,TIMER_CFG_B_PERIODIC);
	TimerLoadSet(TIMER1_BASE,TIMER_B,TheSysClock/4-1);	//250ms
	TimerEnable(TIMER1_BASE, TIMER_BOTH);


	IntEnable(INT_TIMER1B);
	TimerIntEnable(TIMER1_BASE, TIMER_TIMB_TIMEOUT);
	IntEnable(INT_TIMER1A);
	TimerIntEnable(TIMER1_BASE, TIMER_TIMA_TIMEOUT);
	IntMasterEnable();
	while(1)
	{
		SysCtlDelay(TheSysClock/3/2);
		LED_R(R_flag);
		R_flag = ~R_flag;
	}
}


void TIMER1A_Interrupt(void)
{
	static uint8_t B_flag=0;
	// Clear the timer interrupt
	TimerIntClear(TIMER1_BASE, TIMER_TIMA_TIMEOUT);
	B_flag=~B_flag;
	LED_B(B_flag);
}

void TIMER1B_Interrupt(void)
{
	static uint8_t G_flag=0;
	// Clear the timer interrupt
	TimerIntClear(TIMER1_BASE, TIMER_TIMB_TIMEOUT);
	G_flag=~G_flag;
	LED_G(G_flag);
}