MKE04Z128VLD4 UART Receive Data Register Full Flag

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MKE04Z128VLD4 UART Receive Data Register Full Flag

Jump to solution
706 Views
jun1
Contributor V

Hi.

If the Receiver Overrun Flag is set when receiving the UART, the received data will be lost.
Is it possible that the Receive Data Register Full Flag is not set and only the Receiver Overrun Flag is set?
I have a question because the following code was in the UART sample program of the SDK.
Thank you.


SDK:SDK_2.8.0_MKE04Z128xxx4\boards\frdmke06z\driver_examples\uart\interrupt

void DEMO_UART_IRQHandler(void)
{
      uint8_t data;

     /*  Is it possible that the Receive Data Register Full Flag is not set and only the Receiver Overrun Flag is set? */
     if ((kUART_RxDataRegFullFlag | kUART_RxOverrunFlag) & UART_GetStatusFlags(DEMO_UART)) 
     {
              data = UART_ReadByte(DEMO_UART);

              /* If ring buffer is not full, add data to ring buffer. */
              if (((rxIndex + 1) % DEMO_RING_BUFFER_SIZE) != txIndex)
              {
                          demoRingBuffer[rxIndex] = data;
                          rxIndex++;
                          rxIndex %= DEMO_RING_BUFFER_SIZE;
              }
    }
     SDK_ISR_EXIT_BARRIER;
}

 

0 Kudos
1 Solution
689 Views
myke_predko
Senior Contributor III

@jun1 

Interesting question and I have no idea why that comment is in the SDK example code.  

Looking at the code, the answer should be "no" as long as interrupts are active.  It's possible that previous, unread data in the ring buffer is overwritten.  I do use the UART interrupt receive SDK (with EDMA transmit) code so I do have experience with it on other Kinetis devices (K2x, K3x and K6x) and would never expect this to happen.  

The only case I can think of where the overrun flag is set at all in the example code is if interrupts were disabled for a long period of time (ie when clearing/programming many sectors of Flash and not enabling interrupts periodically) with UART data still coming in.  I should point out that the Data Register Full Flag should also be active in this case.  

I've just looked at the examle SDK code for the devices I'm working with (not the MKE04Z128VLD4) and the IRQ handler code is identical, but doesn't have that comment.  

Maybe somebody with experience with the UART for this part can comment but to me the answer should be "no".  

myke

View solution in original post

0 Kudos
1 Reply
690 Views
myke_predko
Senior Contributor III

@jun1 

Interesting question and I have no idea why that comment is in the SDK example code.  

Looking at the code, the answer should be "no" as long as interrupts are active.  It's possible that previous, unread data in the ring buffer is overwritten.  I do use the UART interrupt receive SDK (with EDMA transmit) code so I do have experience with it on other Kinetis devices (K2x, K3x and K6x) and would never expect this to happen.  

The only case I can think of where the overrun flag is set at all in the example code is if interrupts were disabled for a long period of time (ie when clearing/programming many sectors of Flash and not enabling interrupts periodically) with UART data still coming in.  I should point out that the Data Register Full Flag should also be active in this case.  

I've just looked at the examle SDK code for the devices I'm working with (not the MKE04Z128VLD4) and the IRQ handler code is identical, but doesn't have that comment.  

Maybe somebody with experience with the UART for this part can comment but to me the answer should be "no".  

myke

0 Kudos