cancel
Showing results for 
Search instead for 
Did you mean: 

Usart Polling

primagen23
Associate II
Posted on April 13, 2012 at 13:28

Hi,

why i have to enable USART1->CR1 |= USART_CR1_RXNEIE; for polling

In Example of ST Lib i dont see such thing. I thought for polling i dont need this?
3 REPLIES 3
emalund
Associate III
Posted on April 13, 2012 at 14:50

get rid of your interruptifobia

why on earth would you want to poll?

Erik
Posted on April 13, 2012 at 15:55

why i have to enable USART1->CR1 |= USART_CR1_RXNEIE; for polling

 

In Example of ST Lib i dont see such thing. I thought for polling i dont need this?

You don't
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
primagen23
Associate II
Posted on May 03, 2012 at 10:58

get rid of your interruptifobia

why on earth would you want to poll?

Erik ok im trying to get rid of the phobia... below the solution for irq. i enabled at init the RXNEIE. And set Prior to 2.

void
USART2_handler(
void
)
{
if
(USART2->SR & USART_SR_RXNE){
if
(uart2_input_handler != NULL)
{
uart2_input_handler((
int
)(USART2->DR & 0xFF));
/*Bytewise*/
}
}
if
((USART2->SR & USART_SR_TXE) !=0){
USART2->CR1 ^= USART_CR1_TXEIE;
//Disable
}
}
void
u2_putchar(
char
c)
{
USART2->DR = (c & 0xFF);
USART2->CR1 |= USART_CR1_TXEIE;
//Enable 
}