lpcware

Multitask error @uart example

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by wortel on Mon Feb 14 05:02:38 MST 2011
In the UART example it is possible to end in a endless loop when using priority interrupts and/or FreeRtOS.

This is the part:


      /* THRE status, contain valid data */
      while ( !(UART1TxEmpty & 0x01) );   
      LPC_UART1->THR = *BufferPtr;
      UART1TxEmpty = 0;    /* not empty in the THR until it shifts out */
it should be like this:


      /* THRE status, contain valid data */
      while ( !(UART3TxEmpty & 0x01) );
      UART3TxEmpty = 0;    /* not empty in the THR until it shifts out */
      LPC_UART3->THR = *BufferPtr;
Else it is possible to have the character send already, where the interrupt services that the Empty bit gets Empty = 1;, and where later on the running code then clears the bit. Resulting in a endless loop the next time that you will send a char, since the interrupt was already done.

Is it OK that I post this error? Or isn't it appropriated.

Outcomes