| 
 
| 在官网的程序上改的,不知道为何进不去中断?串口和CAN中断都进不去,怀疑时钟的问题? 
 /* Includes ------------------------------------------------------------------*/
 #include "91x_lib.h"
 #include "91x_fmi.h"
 /* Private typedef -----------------------------------------------------------*/
 /* Private define ------------------------------------------------------------*/
 #define TxBufferSize   (countof(TxBuffer) - 1)
 #define RxBufferSize   0xFF
 
 /* Private macro -------------------------------------------------------------*/
 #define countof(a)   (sizeof(a) / sizeof(*(a)))
 
 /* Private variables ---------------------------------------------------------*/
 UART_InitTypeDef UART_InitStructure;
 u8 TxBuffer[] = "UART Example1: UART - Hyperterminal communication using hardware flow control\n\r";
 u8 RxBuffer[RxBufferSize];
 u8 NbrOfDataToTransfer = TxBufferSize;
 u8 TxCounter = 0;
 u8 RxCounter = 0;
 u8 data =0;
 /* Private function prototypes -----------------------------------------------*/
 void SCU_Configuration(void);
 void GPIO_Configuration(void);
 
 /* Private functions ---------------------------------------------------------*/
 /*******************************************************************************
 * Function Name  : main
 * Description    : Main program
 * Input          : None
 * Output         : None
 * Return         : None
 *******************************************************************************/
 /*static void Delay(u32 nCount)
 {
 u32 j = 0;
 
 for(j = nCount; j != 0; j--);
 }
 */
 
 int main()
 {
 #ifdef DEBUG
 debug();
 #endif
 
 /* Configure the system clocks */
 SCU_Configuration();
 
 /* Configure the GPIO ports */
 GPIO_Configuration();
 
 /*  configuration -------------------------------------------------------*/
 /* UART2 configured as follow:
 - Word Length = 7 Bits
 - Two Stop Bit
 - No parity
 - BaudRate = 115200 baud
 - Hardware flow control enabled (RTS and CTS signals)
 - Receive and transmit enabled
 - Receive and transmit FIFOs are enabled
 - Transmit and Receive FIFOs levels have 8 bytes depth
 */
 UART_InitStructure.UART_WordLength = UART_WordLength_8D;
 UART_InitStructure.UART_StopBits = UART_StopBits_1;
 UART_InitStructure.UART_Parity = UART_Parity_No ;
 UART_InitStructure.UART_BaudRate = 9600;
 // UART_InitStructure.UART_HardwareFlowControl = UART_HardwareFlowControl_None;
 UART_InitStructure.UART_Mode = UART_Mode_Tx_Rx;
 UART_InitStructure.UART_FIFO = UART_FIFO_Disable ;
 // UART_InitStructure.UART_TxFIFOLevel = UART_FIFOLevel_1_2; /* FIFO size 16 bytes, FIFO level 8 bytes */
 // UART_InitStructure.UART_RxFIFOLevel = UART_FIFOLevel_1_2; /* FIFO size 16 bytes, FIFO level 8 bytes */
 
 UART_DeInit(UART2);
 UART_Init(UART2, &UART_InitStructure);
 
 // GPIO_WriteBit(GPIO4, GPIO_Pin_5, Bit_RESET);
 
 /* Enable the UART Receive interrupt*/
 UART_ITConfig(UART2, UART_IT_Receive, ENABLE);
 //     UART2->IMSC |= 0x0010;
 
 /* Enable VIC clock */
 //SCU_AHBPeriphClockConfig(__VIC, ENABLE);
 /*configure UART2 interrupt in VIC*/
 VIC_DeInit();
 VIC_InitDefaultVectors(); /* initialize VICs default vector registers*/
 VIC_Config(UART2_ITLine, VIC_IRQ, 0);
 /* Enable the UART2 */
 UART_Cmd(UART2, ENABLE);
 //     VIC1->VAiR[2]=(u32)UART2_IRQHandler;
 //      VIC1->INTSR &= ~4;
 //      VIC1->VCiR[2] |=0x20;
 // VIC1->VCiR[2] &=  0xFFFFFFE0;
 //    VIC1->VCiR[2] |=0x02;
 //      UART2->CR |= 0x0001;
 //       VIC1->INTER |= 4;
 GPIO_WriteBit(GPIO4, GPIO_Pin_5, Bit_RESET);
 /*enable UART2 interrupt for data reception*/
 VIC_ITCmd(UART2_ITLine,ENABLE);
 
 
 
 
 while (1)
 {
 
 data = UART_ReceiveData(UART2);
 if(data==0xaa)
 {
 GPIO_WriteBit(GPIO4, GPIO_Pin_5, Bit_SET);
 UART_SendData(UART2,data);
 while(UART_GetFlagStatus(UART2, UART_FLAG_Busy) == SET);
 
 GPIO_WriteBit(GPIO4, GPIO_Pin_5, Bit_RESET);
 }
 
 }
 }
 
 void SCU_Configuration(void)
 {
 SCU_MCLKSourceConfig(SCU_MCLK_OSC);   /* Default configuration */
 
 /*wait state insertion :This function should be executed from SRAM when*/
 /*booting from bank1 to avoid  Read-While-Write from the Same Bank.*/
 FMI_Config(FMI_READ_WAIT_STATE_2, FMI_WRITE_WAIT_STATE_0, FMI_PWD_ENABLE,\
 FMI_LVD_ENABLE, FMI_FREQ_HIGH);/*Insert 2 Wait States for read*/
 
 SCU_PLLFactorsConfig(192, 8, 2); /* PLL factors Configuration based on*/
 /* a OSC/Crystal value = 25Mhz*/
 SCU_PLLCmd(ENABLE);  /* PLL Enable and wait for Locking*/
 SCU_RCLKDivisorConfig(SCU_RCLK_Div1); /* RCLK @Osc/crystal Frequency*/
 SCU_HCLKDivisorConfig(SCU_HCLK_Div1); /* AHB @Osc/crystal Frequency*/
 SCU_FMICLKDivisorConfig(SCU_FMICLK_Div1);/* FMI @Osc/crystal Frequency*/
 SCU_PCLKDivisorConfig(SCU_PCLK_Div2); /* APB @Osc/crystal Frequency*/
 SCU_MCLKSourceConfig(SCU_MCLK_OSC);  /* MCLK @Osc/crystal Frequency*/
 /* Enable UART2 Clock */
 SCU_APBPeriphClockConfig(__UART2, ENABLE);
 
 /* Enable VIC clock */
 SCU_AHBPeriphClockConfig(__VIC, ENABLE);
 
 /* Enable GPIO2 Clock */
 SCU_APBPeriphClockConfig(__GPIO4, ENABLE);
 
 
 /* Enable GPIO5 Clock */
 SCU_APBPeriphClockConfig(__GPIO5, ENABLE);
 
 }
 
 /*******************************************************************************
 * Function Name  : GPIO_Configuration
 * Description    : Configures the different GPIO ports.
 * Input          : None
 * Output         : None
 * Return         : None
 *******************************************************************************/
 void GPIO_Configuration(void)
 {
 GPIO_InitTypeDef GPIO_InitStructure;
 
 /*Configure UART0_CTS P2.0*/
 //GPIO_DeInit(GPIO2);
 /*After DeInit function P2.0 = UART0_CTS (defaut configuration)*/
 
 GPIO_DeInit(GPIO5);
 /*Gonfigure UART0_Rx pin GPIO5.2*/
 GPIO_InitStructure.GPIO_Direction = GPIO_PinInput;
 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
 GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ;
 GPIO_InitStructure.GPIO_IPInputConnected = GPIO_IPInputConnected_Enable;
 GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1  ;
 GPIO_Init (GPIO5, &GPIO_InitStructure);
 
 //  GPIO_DeInit(GPIO3);
 /*Gonfigure UART0_Tx pin GPIO5.1*/
 GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput;
 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
 GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ;
 GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt3  ;
 GPIO_Init (GPIO5, &GPIO_InitStructure);
 
 
 GPIO_DeInit(GPIO4);
 /*Gonfigure UART0_RTS pin GPIO4.5*/
 GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput;
 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
 GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ;
 //GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Enable;
 GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt1  ;
 GPIO_Init (GPIO4, &GPIO_InitStructure);
 }
 
 | 
 |