We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi, I am using the STR912FA and I am trying to implement the UART communication using interrupts. I am using the interrupt only for receiving data, but for some reason I never get an interrupt when writing a character in the hyperterminal ... The transmition works ok using the printf to the hyperterminal. Does someone see something wrong in my code? Thanks a lot!
This is my UART initialization:
// UART Module 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_DeInit(UART0); UART_Init(UART0, &UART_InitStructure); UART_Cmd(UART0, ENABLE); UART_ITConfig(UART0, UART_IT_Receive, ENABLE); VIC_DeInit(); VIC_Config(UART0_ITLine, VIC_IRQ, 2); VIC_ITCmd(UART0_ITLine, ENABLE);
This is the interrupt (That I never get):
void UART0_IRQHandler(void) { /*clear receive interrupt flag*/ UART_ClearITPendingBit(UART0, UART_IT_Receive); //UART_ClearITPendingBit(UART0, UART_IT_Transmit); /*send back the received character*/ while(UART_GetFlagStatus(UART0, UART_FLAG_TxFIFOFull) != RESET); UART_SendData(UART0, UART_ReceiveData(UART0)); }
This is my byte transmition (works):
int MyLowLevelPutchar(int x) { UART_SendData(UART0, x); while(UART_GetFlagStatus(UART0, UART_FLAG_TxFIFOFull) == SET); return x; }