2014-04-11 09:27 AM
In my programm I use uart4 with 115200 baud. I want to receive data from devices - so I configure UART in RxMode. I enebled only one interrupt source for it
USART_ITConfig(UART4, USART_IT_RXNE, ENABLE); My interrupt handler looks like this:void UART4_IRQHandler(void) { Uart_SR = UART4->SR; Uart_CR1 = UART4->CR1; Uart_CR2 = UART4->CR2; Uart_CR3 = GPS_USART->CR3; if(USART_GetITStatus(UART4_USART, USART_IT_RXNE) != RESET) { char symb; symb = USART_ReceiveData(UART4) & 0xFF; DummyCntr1++; } if(USART_GetITStatus(UART4, USART_IT_TXE) != RESET) { /* Write one byte to the transmit data register */ DummyCntr4++; } DummyCntr5++; }Some time
the data was successfully
received.
But
then
something strange
happens
.All
CPU time
UART4interrupt handler
is executed
(except for
higher-priority
interrupts handlers
)
, while the
interrupt flags
are reseted.
Uart_SR, Uart_CR1, Uart_CR2, Uart_CR3 variables transmitted via CAN, and there values are: 0x1D8, 0x2024, 0x0, 0x0respectively
. Also DummyCntr's transmitted and only DummyCntr5 grows up. So in CR1 only RXNEIE bit installed, in SR RXNE bit is cleared - why interrupt handler executed? What have I missed? #uart-interrupt-stm32f42014-04-11 10:06 AM
Does seem a bit odd
if(USART_GetITStatus(UART4_USART, USART_IT_RXNE) != RESET) Why UART4_USART rather than UART4?2014-04-12 11:41 AM
You're absolutely right
, but it isnot the fault of
the program -
I was wrong
edited the
code
of
the program
in the post
: I tried toreplace
the program
macros
by their values
​​.The program
has
a macro
like this#define GPS_USART UART4
I just
replaced the
macro name
with its value
.So
really
, the line lookslike this:
if(USART_GetITStatus (GPS_USART, USART_IT_RXNE)! = RESET)