4 Replies Latest reply on Nov 22, 2011 3:47 AM by udayanu_

    FreeRTOS, Sleep Modes, And The PSoC 5



      I am having difficulty implenting low power modes combined with using the FreeRTOS platform and the PSoC 5. Specifically, UART comms are getting corrupted.


      I have a task which receives messages to send to the UART. When it receives a message, it prevents the uC from sleeping, wakes the uart up, and then sends the message using the API (Uart_PutSring()). It then waits until the message is sent before allowing the micro to sleep and sleeping the uart itself.


      Some messages are getting through un-corrupted, others are a horrible mess...


      Here is a code snippet of the UART task...




      //! @brief Main debug uart task


      //! @param *pvParameters Void pointer (not used)


      //! @note Not thread-safe. Do not call from any task, this function is a task that


      //! is called by the FreeRTOS kernel


      //! @public


      void vDebugUart_MainTask(void *pvParameters)




      // Sleep uart






      uint8 *message;






      // Wait for a message pointer to arrive in the queue


      xQueueReceive(xDebugUartTxQueue, &message, portMAX_DELAY);




      #if(DEBUG_LEDS == 1)








      // Message must of been received, so now prevent micro from sleeping and send






      // Wakeup UART












      // Wait until UART has completely finished sending the message


      // (both the hardware buffer and the byte sent flag are set)


      while(!(UART_DEBUG_ReadTxStatus() & (UART_DEBUG_TX_STS_FIFO_EMPTY | UART_DEBUG_TX_STS_COMPLETE))); //(software wait)


      //while(!(UART_DEBUG_ReadTxStatus() & UART_DEBUG_TX_STS_COMPLETE));




      // Sleep uart






      // Now it is safe to unlock the micro to allow for sleeping




      // Finished, now loop for next message








      Cheers, Geoff