- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm writing code for a PSoC6 and I'm using the PDL SCB_UART for debugging. In the application, I go to DeepSleep as often as I can to save battery power.
When I am dumping debug data to the SCB_UART many times the PSoC goes into DeepSleep mode before the Transmit Data is completely sent. This causes partial data in the terminal as well as framing errors.
I can perform a CyDelay() with some time to eliminate this, but I'd prefer to query if the Transmit is fully complete before going to DeepSleep. The CyDelay is open loop and has to be calibrated to work across all data. I'm looking for a closed loop method.
I've tried
while((UART_GetNumLeftToTransmit() > 0)){} // Wait until ALL Tx byte sent.
No luck.
I've also tried
while((UART_GetNumInTxFifo() > 0)){} // Wait until ALL Tx byte sent.
Still no luck.
I've also tried
while((UART_GetTransmitStatus() & CY_SCB_UART_TX_DONE) != true){} // Wait until ALL Tx byte sent.
This was worst than the first two.
I think in the first 2 cases, it only reports 0 when there are no bytes in the FIFO but the last data is in the serial buffer.
Any suggestions?
Len
"Engineering is an Art. The Art of Compromise."
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi LePo_1062026,
You can use the function Cy_SCB_UART_DeepSleepCallback that handles the transition of the SCB UART into and out of Deep Sleep mode. It prevents the device from entering Deep Sleep mode if the UART is transmitting data or has any data in the RX FIFO.
Please refer to the PDL driver under PDL API Reference -> SCB -> UART -> Functions -> Low power callbacks
You need to register this call back function to Cy_SysPm_RegisterCallback.
Refer to the app note PSoC 6 MCU Low-Power Modes and Power Reduction Techniques Appendix C on how to register a call back function for low power mode transition.
https://www.cypress.com/file/385936/download
Hope this helps!
Regards,
Bragadeesh
Bragadeesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi LePo_1062026,
You can use the function Cy_SCB_UART_DeepSleepCallback that handles the transition of the SCB UART into and out of Deep Sleep mode. It prevents the device from entering Deep Sleep mode if the UART is transmitting data or has any data in the RX FIFO.
Please refer to the PDL driver under PDL API Reference -> SCB -> UART -> Functions -> Low power callbacks
You need to register this call back function to Cy_SysPm_RegisterCallback.
Refer to the app note PSoC 6 MCU Low-Power Modes and Power Reduction Techniques Appendix C on how to register a call back function for low power mode transition.
https://www.cypress.com/file/385936/download
Hope this helps!
Regards,
Bragadeesh
Bragadeesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Bragadeesh,
Thank you! I'm currently researching your recommendation for proper implementation. It sounds like exactly what I need.
Is there a PSoC6 example that uses the UART and establishes the callback you speak of before going into deepsleep?
Len
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Bragadeesh,
I've been able to use Cy_SCB_UART_DeepSleepCallback() as a callback function. I now don't appear to have UART framing errors when going to sleep.
I do appreciate the elegance of the callback registering technique but it does make it more complicated. Not intuitive to the novice user. Would it make more sense that PDL components have a default API call to the SysPM manager libs that the user can use. this would simplify setup of the register as long as the user doesn't need special considerations.
Thanks.
Len
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi LePo_1062026,
We are glad that you got it working!
We understand your concern. We will create an enhancement request to improve our documentation to provide better experience to our customers.
Thank you for choosing Cypress products!
Regards,
Bragadeesh
Bragadeesh