uplifting_mind
Newbie level 6
- Joined
- May 7, 2013
- Messages
- 11
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Location
- Slovakia
- Activity points
- 1,359
Hello,
I need complete program with interrupt from USART Rx and Tx. Rx interrupt is working fine, but with Tx I have problems. As I was awared, I must use a FIFO buffer for storing data from printf function and in interrupt handler I must send this data from FIFO to USART transmit register.
In my code, first step of this is working - data from printf are actualy going to FIFO buffer. But in second step, code in interrupt handler don´t send any data from FIFO to USART.
In order to tx interrupt I wrote this function, which is placing characters from printf to FIFO buffer. It is calling from fputc(int ch, FILE *f) function and works fine.
The next function I wrote is this one. It should be sending a characters from FIFO buffer to USART. It is calling from interrupt handler.
I was been awared that USART_SendData() can only be used once per TXE interrupt. So I tried to replace this piece of code by this one (from example code for STM32F10...):
It still don´t work. Can someone help me?
I need complete program with interrupt from USART Rx and Tx. Rx interrupt is working fine, but with Tx I have problems. As I was awared, I must use a FIFO buffer for storing data from printf function and in interrupt handler I must send this data from FIFO to USART transmit register.
In my code, first step of this is working - data from printf are actualy going to FIFO buffer. But in second step, code in interrupt handler don´t send any data from FIFO to USART.
In order to tx interrupt I wrote this function, which is placing characters from printf to FIFO buffer. It is calling from fputc(int ch, FILE *f) function and works fine.
Code:
void FIFO_PUT(char ch)
{
if(COUNT < FIFO_SIZE)
{
FIFO[COUNT] = ch;
COUNT ++;
}
}
The next function I wrote is this one. It should be sending a characters from FIFO buffer to USART. It is calling from interrupt handler.
Code:
void FIFO_GET(void)
{
char j;
char ch;
for (j=0;j<10; j++)
{
ch = FIFO[j];
USART_SendData(USART1, ch);
ch = 0;
}
}
I was been awared that USART_SendData() can only be used once per TXE interrupt. So I tried to replace this piece of code by this one (from example code for STM32F10...):
Code:
if (USART_GetITStatus(USART1, USART_IT_TXE) != RESET)
{
USART_SendData(USART1, FIFO[COUNT]);
if(COUNT == FIFO_SIZE)
{
/* Disable the USARTx Transmit interrupt */
USART_ITConfig(USART1, USART_IT_TXE, DISABLE);
}
}
It still don´t work. Can someone help me?