Skip to main content
vivek
Associate III
September 14, 2019
Question

stm32f105 usart interrupt generated only once times.

  • September 14, 2019
  • 2 replies
  • 731 views

when program started interrupt is called but its read only one character and repeatedly read same character.most time getting garbage value.

RXNE Flag also set. my application is to handle data send by ATMEGA16 in while condition.

program:

void USART2_IRQHandler(void)

{

//Local variable

unsigned char data=0,i=0;

unsigned char TEMP[5];

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

{

data = USART2->DR;

if(i<5)

{

TEMP[i]=data;

i++;

}

}

}

This topic has been closed for replies.

2 replies

Tesla DeLorean
Guru
September 14, 2019

The holding buffer and index presumably need to be static variables.

Auto variables will hold junk from the stack.​

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
vivek
vivekAuthor
Associate III
September 18, 2019

yes now its work.but sometime i got single character