AnsweredAssumed Answered

STM32F4 FreeRTOS UART interrupt

Question asked by bo_root on Apr 15, 2014
Latest reply on Apr 22, 2014 by bo_root
Using:
       
  • STM32F407VG
  •    
  • FreeRTOS 7.6.0

I am trying to read value of RFID card via UART interrupt. Problem is that data read by UART is somehow corrupted. If i don't use FreeRTOS this code works, which makes it even more strange.

The RFID communicates using rs232 and transmits a 12-byte ASCII string.  The first byte (start byte) in my case is always 0x02.

To be more precise.. when the card is approximated to the reader interrupt is normally triggered, but when i try to read this 12-byte ASCII i never get start byte (0x02), instead of that in most of the cases i get 0x80, so reading is never successfully. What am i doing wrong?

01.extern unsigned char tagValue[12];
02.extern xSemaphoreHandle xUsartRead;
03. 
04.void USART1_IRQHandler(void) {
05.    unsigned char sign = '\0';
06.    uint8_t k = 0;
07.         
08.    if(USART_GetITStatus(USART1, USART_IT_RXNE)) {
09.        if(USART_GetFlagStatus(USART1, USART_FLAG_RXNE)){          
10.            sign = USART_ReceiveData(USART1);
11.            if (sign == 0x02) {
12.                while(k < 12) {                                         
13.                    if(USART_GetFlagStatus(USART1, USART_FLAG_RXNE))
14.                        tagValue[k++] = USART_ReceiveData(USART1);
15.                }
16.                 
17.                 
18.                portBASE_TYPE xHigherPriorityTaskWoken;
19.                xHigherPriorityTaskWoken = pdFALSE;
20.                xSemaphoreGiveFromISR(xUsartRead, &xHigherPriorityTaskWoken);
21.         
22.                portEND_SWITCHING_ISR(xHigherPriorityTaskWoken);
23.            }
24.        }  
25.    }
26.}

Outcomes