Question
STM32F4 FreeRTOS UART interrupt
Posted on April 15, 2014 at 22:30
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 0x To be more precise.. when the card isapproximated
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?
extern
unsigned
char
tagValue[12];
extern
xSemaphoreHandle xUsartRead;
void
USART1_IRQHandler(
void
) {
unsigned
char
sign =
'\0'
;
uint8_t k = 0;
if
(USART_GetITStatus(USART1, USART_IT_RXNE)) {
if
(USART_GetFlagStatus(USART1, USART_FLAG_RXNE)){
sign = USART_ReceiveData(USART1);
if
(sign == 0x02) {
while
(k < 12) {
if
(USART_GetFlagStatus(USART1, USART_FLAG_RXNE))
tagValue[k++] = USART_ReceiveData(USART1);
}
portBASE_TYPE xHigherPriorityTaskWoken;
xHigherPriorityTaskWoken = pdFALSE;
xSemaphoreGiveFromISR(xUsartRead, &xHigherPriorityTaskWoken);
portEND_SWITCHING_ISR(xHigherPriorityTaskWoken);
}
}
}
}
#freertos-uart-interrupt #usart