Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > PSoC® 5 > FreeRTOS, Sleep Modes, And The PSoC 5

Bookmark and Share
Cypress Developer CommunityTM
Forums | Videos | Blogs | Training | Rewards Program | Community Components



FreeRTOS, Sleep Modes, And The PSoC 5
Moderator:
ANCY

Post Reply
Follow this topic



FreeRTOS, Sleep Modes, And The PSoC 5

gbmhunter posted on 27 Oct 2011 9:50 PM PST
Top Contributor
23 Forum Posts

 Hi,

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

UART_DEBUG_Sleep();

 

uint8 *message;

for(;;)

{

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

xQueueReceive(xDebugUartTxQueue, &message, portMAX_DELAY);

#if(DEBUG_LEDS == 1)

DebugUart_FlashLed();

#endif

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

PowerMgmt_SleepLock();

// Wakeup UART

UART_DEBUG_Wakeup();

UART_DEBUG_PutString(message);

//vTaskDelay(200/portTICK_RATE_MS);

// 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

UART_DEBUG_Sleep();

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

PowerMgmt_SleepUnlock();

// Finished, now loop for next message

}

}

 

Cheers, Geoff




Re: FreeRTOS, Sleep Modes, And The PSoC 5

David Ron posted on 08 Nov 2011 04:35 AM PST
Top Contributor
24 Forum Posts

hey gbmhunter

 

you havent used SaveConfig() API before putting the device to sleep and RestoreConfig() API immediately after wake up. that could be a potential reason why the uart data is getting corrupted.



Re: FreeRTOS, Sleep Modes, And The PSoC 5

gbmhunter posted on 20 Nov 2011 07:52 PM PST
Top Contributor
23 Forum Posts

 The save clocks API call for the enitre device?



Re: FreeRTOS, Sleep Modes, And The PSoC 5

U2 posted on 21 Nov 2011 09:00 AM PST
Cypress Employee
589 Forum Posts

 This is the typical sequence for you to put PSoC to sleep properly, wake it up and restore it to normal operation.

  1. First save all the component configuration using the component_SaveConfig() API or component_Sleep() API (Some components may not have the sleep API). The Sleep API will actually be calling the component_Stop() API, followed by component_SaveConfig(). In case of UART, it is is sufficient to call UART_Sleep() API.
  2. Follow step 1 for all the components in your design which has some amount of configuration. Please go through individual component datasheet for for Sleep related information.
  3. Now call CyPmSaveClocks(). Saves all state of the clocking system that doesn’t persist during sleep/hibernate or that needs to be altered in preparation for sleep/hibernate. Shuts down all the digital and analog clock dividers. Switches the master clock over to the IMO and shuts down the PLL and MHz Crystal.
  4. Now enter sleep by calling CyPmSleep() API.
  5. Restore all clock configuration, CyPmRestoreClocks()
    • Restore the component configuration. In your case UART. UART_Wakeup(void). I hope this helps.

 

 



Re: FreeRTOS, Sleep Modes, And The PSoC 5

U2 posted on 22 Nov 2011 01:47 AM PST
Cypress Employee
589 Forum Posts

Hello,

I would recommend you to contact the cypress tech support team to look in to this issue and get it resolved. You can raise a request for the same here, https://secure.cypress.com/myaccount/?id=25&techSupport=1&CFID=807385&CFTOKEN=26807991

 






ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Spec No: None; Sunset Owner: KXP; Secondary Owner: VWA; Sunset Date: 01/01/20