Uart Rx interrupt ISR stopped after receive data at the first time.

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
LoRi_3951816
Level 1
Level 1
First like received First like given

Uart Rx interrupt ISR stopped after receive data at the first time. Attach code, please check and tell me what's the problem.

thanks a lot!

0 Likes
1 Solution
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

I would re-write GetRecv() like below

============================

uint32_t GetRecv()

{

    uint8_t  ch; /* changed to uint8_t */

    uint32_t size = 0;

    uint32_t real_size = 0;

    uint8_t  tmpBuffer[256];

     while(UART_SpiUartGetRxBufferSize()) {

          tmpBuffer[real_size++] = UART_UartGetChar() ;

          if (real_size >= sizeof(tmpBuffer)) {

               break ;

          }

     }

     if (real_size > 0) {

          size = WriteRingBuffer(tmpBuffer, real_size, &s_RingBuffer);

     }

     return size ;

}

============================

If it does not work, I'm sorry (in advance).

moto

View solution in original post

5 Replies
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

Check UART P4 examples in this thread and link inside

Re: UART Input String Parsing

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

I would re-write GetRecv() like below

============================

uint32_t GetRecv()

{

    uint8_t  ch; /* changed to uint8_t */

    uint32_t size = 0;

    uint32_t real_size = 0;

    uint8_t  tmpBuffer[256];

     while(UART_SpiUartGetRxBufferSize()) {

          tmpBuffer[real_size++] = UART_UartGetChar() ;

          if (real_size >= sizeof(tmpBuffer)) {

               break ;

          }

     }

     if (real_size > 0) {

          size = WriteRingBuffer(tmpBuffer, real_size, &s_RingBuffer);

     }

     return size ;

}

============================

If it does not work, I'm sorry (in advance).

moto

Thank you very much for your guidance. I tried it and the result looks good. Thanks again!

I check the code you post, there is little difference that add a condition before call UART_UartGetChar() , Is it because the function is called too often that the interrupt is unresponsive?

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

UART_UartGetChar() returns 0 when no more char is available or an error arose.

But I feel accessing an empty buffer or when an error arose is not a good idea,

so I check the number of data available before accessing the buffer.

moto

0 Likes