2013-01-09 01:56 AM
Good morning, i'm using a STM32F0discovery board, i'm developing an application that read and write informations on UART2 port, i'm using only TX and RX pins (PA2 and PA3).
Well, at this time my application ask me what i want to write, than i insert an input string and the mcu sends it on UART correctly.Now i need to know how i can develop the reception procedure using reception interrupt, because i don't know when the other side sends the informations.In other words i need to develop a function that when the UART receives something on RX pin than the micro stores it in a string and show me what it receives.Do you have suggestions or guidelines, please?Thanks. #uart-rx-interrupt-routine2013-01-09 04:41 AM
Like you wrote on ''tags'' you should create USART2 interrupt routine
USART_ITConfig(USART2, USART_IT_RXNE, ENABLE); in which you will store data to buffer: void USART2_IRQHandler(void) { if(USART_GetITStatus(USART2, USART_IT_RXNE) != RESET) { /* Read one byte from the receive data register */ RxBuffer2[RxCounter2++] = USART_ReceiveData(USART2); if(RxCounter2 == NbrOfDataToRead1) { /* Disable the USART2 Receive interrupt */ USART_ITConfig(USART2, USART_IT_RXNE, DISABLE); } } } Full code can be found in USART/Interrupt program in examples...2013-01-09 09:27 AM
You want to implement some sort of ring/fifo or line buffering, accumulating characters in the interrupt, and then parsing your commands or incoming data.