cancel
Showing results for 
Search instead for 
Did you mean: 

stm32f427 uart4 interrupts generated without flags

glory_man
Associate II
Posted on April 11, 2014 at 18:27

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

UART4

interrupt 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, 0x0

respectively

. 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-stm32f4
2 REPLIES 2
Posted on April 11, 2014 at 19:06

Does seem a bit odd

if(USART_GetITStatus(UART4_USART, USART_IT_RXNE) != RESET)

Why UART4_USART rather than UART4?
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
glory_man
Associate II
Posted on April 12, 2014 at 20:41

You're absolutely right

, but it is

not the fault of

the program -

I was wrong

edited the

code

of

the program

in the post

: I tried to

replace

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 looks

like this:

if(USART_GetITStatus (GPS_USART, USART_IT_RXNE)! = RESET)