cancel
Showing results for 
Search instead for 
Did you mean: 

Hardware flow control on stm32f4 with usart and interrupts, how?

Sietse
Associate III
Posted on November 07, 2014 at 11:13

Hello list,

Hardware flow control is not working here with stm32f4 discovery board and usart2. I use interrupts to fill a fifo and a background loop to empty the fifo. Interrupts are disabled if the fifo is almost full and enabled again when almost empty. I assume that if interrupts are disabled and characters keep coming, that nRTS will be permanently asserted, but that does not happen! When interrupts are enabled and character read, I see the short nRTS assertions on a scope. Here the important parts of my code.

void USART2_IRQHandler(void)
{
int i;
i= USART_GetITStatus(USART2, USART_IT_RXNE);
if(i != RESET)
{ if (fifo_free(&usart2fifo) < 3) {
USART_ITConfig(USART2, USART_IT_RXNE, DISABLE);
usart2off = 1;
}
i=USART_ReceiveData(USART2);
fifo_put(&usart2fifo, i & 0xFF);
}
}

int usart2readchar(void) {
char c;
while (!fifo_get(&usart2fifo,(uint8_t *)&c));
if (usart2off) {
if (fifo_free(&usart2fifo) > (FIFO_SIZE-20)) {
usart2off = 0;
USART_ITConfig(USART2, USART_IT_RXNE, ENABLE);
}
}
return c;
}

Is this the correct way of doing this? What am I doing wrong? Thanks in advance, Sietse #stm32f4-usart-hw-flow-control
0 REPLIES 0