Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

USART Tx interrupt (STM32)

Status
Not open for further replies.

uplifting_mind

Newbie level 6
Newbie level 6
Joined
May 7, 2013
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Slovakia
Visit site
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.
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?
 

I think Jayanth post no 1 gives you answer - there is interrupt driven UART is written by 'devil' at Posted: 3/13/2013 6:42 PM ...... I think that should work..... try that my through was you need to modify -
Code:
 USART_ITConfig(USART1, USART_IT_TXE, DISABLE); // original
// Modified to 
 USART_ITConfig(USART1, USART_IT_TXE, ENABLE); // as you need to made TXE enable interrupt
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top