I am using ARM STR9 board when I use UART_ITConfig(UART0,UART_IT_Receive,ENABLE);
and after that I use a while loop and print hello on the screen
problem is that programme jumps to ISR but it hangs there it does not comes back #include "91x_lib.h"
#include "stdio.h" #define TxBufferSize (countof(TxBuffer) - 1) #define RxBufferSize 0x0A #define countof(a) (sizeof(a) / sizeof(*(a))) 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; bool flag=0; static void Delay(u32 nCount) { u32 j = 0;
for(j = nCount; j != 0; j--); } void main(void) { GPIO_InitTypeDef GPIO_InitStructure; UART_InitTypeDef UART_InitStructure;
SCU_APBPeriphClockConfig(__UART0, ENABLE); SCU_APBPeriphClockConfig(__GPIO5, ENABLE); // SCU->GPIOOUT[9] = 0x5555;
SCU_APBPeriphClockConfig(__GPIO9, ENABLE); SCU->GPIOOUT[9] = 0xFFFF; GPIO9->DDR = 0xFF; GPIO9->DR[0x3FC] = 0xFF;
GPIO_DeInit(GPIO5); GPIO_InitStructure.GPIO_Direction = GPIO_PinInput; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1; GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Enable; GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1 ; GPIO_Init (GPIO5, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt3 ; GPIO_Init (GPIO5, &GPIO_InitStructure);
UART_DeInit(UART0); 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 = 115200; UART_InitStructure.UART_HardwareFlowControl = UART_HardwareFlowControl_None; UART_InitStructure.UART_Mode = UART_Mode_Tx_Rx; UART_InitStructure.UART_FIFO = UART_FIFO_Disable; UART_Init(UART0, &UART_InitStructure); UART_ITConfig(UART0,UART_IT_Receive,ENABLE); UART_Cmd(UART0, ENABLE);
SCU_AHBPeriphClockConfig(__VIC,ENABLE); VIC_DeInit(); //VIC Configuration // VIC_Config(UART0_ITLine,VIC_IRQ , 0); VIC_ITCmd(UART0_ITLine, ENABLE); while(1) { if(flag==0) printf("HELLO"); }
}
int SendChar (int ch) { UART_SendData(UART0, ch); while(UART_GetFlagStatus(UART0, UART_FLAG_Busy) != RESET); return (ch); }
int GetKey (void) {
} void UART0_IRQHandler(void) { flag=1; do { if((UART_GetFlagStatus(UART1, UART_FLAG_RxFIFOEmpty) != SET)&&(RxCounter < RxBufferSize)) { RxBuffer[RxCounter] = UART0->DR; // UART_SendData(UART0, RxBuffer[RxCounter++]); // printf("ABCD"); } flag=0; }while((RxBuffer[RxCounter-1] != '\r')&&(RxCounter != RxBufferSize)); UART_ITConfig(UART0, UART_IT_Receive,DISABLE); // VIC0->INTECR=0xFFFF;
can anyone suggest the code for interrupt driven uart for STR912 board