2024-11-15 02:11 AM
My requirement is as follows.
When I power ON the STM32L4 series MCU, a string must be sent on to the UART terminal like "Power is ON". Now abruptly I will power OFF. Now at this instance, another string must be sent to UART terminal which is "Power is OFF". How to do this? Kindly let me know the solution if anyone has come across such a situation.
Thank you!
2024-11-15 02:18 AM
Not obvious.
Need to keep the MCU powered while sending string over UART.
Use external capacitor/super cap to power supply the MCU during the power down? + detect the power drop on power source to trigger the UART transmission?
2024-11-15 02:28 AM
@vbk22398 wrote:When I power ON the STM32L4 series MCU, a string must be sent on to the UART terminal like "Power is ON". N!
That bit's easy - just make sending that message the first thing you do!
@vbk22398 wrote:Now abruptly I will power OFF. Now at this instance, another string must be sent to UART terminal which is "Power is OFF". How to do this?
That requires two things:
2024-11-15 02:34 AM
@SofLit wrote:+ detect the power drop on power source to trigger the UART transmission?
How to do the above? I am completely out of ideas to implement your logic. Could you be a little elaborate. I have doubts like to which pin should I connect the external capacitor/super cap. What is the rating of capacitor? Are there any other options apart from capacitor. How to track the power down? Kindly elaborate.
Thank you!
2024-11-15 02:41 AM - edited 2024-11-15 02:49 AM
@vbk22398 wrote:
I have doubts like to which pin should I connect the external capacitor/super cap.
Check if the MCU features an internal comparator that will compare the power supply level to what expected. Otherwise need to add an external comparator that detects the power down which triggers over MCU EXTI the UART transfer.
@vbk22398 wrote:
What is the rating of capacitor? Are there any other options apart from capacitor.
The capacitor needs to be mounted on the power supply of the MCU. For the rating you need to find it yourself by test ..
Make some internet search on super cap usage, example: https://www.digikey.com/en/articles/how-to-use-a-single-supercapacitor-as-backup-power-for-a-5-volt-supply
PS: we are here to guide you and propose some guidelines not supposed to provide a complete solution.
Thanks
2024-11-15 02:52 AM - edited 2024-11-15 02:54 AM
@vbk22398 wrote:What is the rating of capacitor?
That will depend on your system - how much power it uses.
The capacitor needs to be large enough to store sufficient energy to guarantee to power your system for long enough to complete sending the message.
@vbk22398 wrote:
Are there any other options apart from capacitor. !
Sure: https://www.google.com/search?q=microcontroller+backup+power
@vbk22398 wrote:How to track the power down?
You need to give more details of your system:
It seems that you lack electronic design skills/knowledge - do you not have anyone to help with what is an electronic design project?
2024-11-15 03:07 AM
@vbk22398 wrote:Are there any other options apart from capacitor.
The obvious one would be a battery - which could be rechargeable ("secondary") or not ("primary")
2024-11-15 03:32 AM
But this can be also seen "upside down". Imagine a smarter terminal that understands periodic "heart beat" signals from the MCU. The first time it sees the signal, it prints "Power on". After it misses couple of signals it prints "power off" or whatever ))
2024-11-15 03:35 AM
> I have doubts like to which pin should I connect the external capacitor/super cap. What is the rating of capacitor? Are there any other options apart from capacitor. How to track the power down? Kindly elaborate.
This would be the job of the hardware designers.
Tell them that the power supply stage must be able to maintain the 3.3V supply for at least 100ms (or more) after mains off. State you average/max current requirement at this stage, and they should be able design it.
A properly sized electrolytic capacitor will do the job -> Q = I * t.
I had been working on a project were the main MCU stored about a dozen parameters into EEPROM during that remaining time.
2024-11-15 03:38 AM
@Ozone wrote:This would be the job of the hardware designers.
Indeed.
Also the job of the hardware designers to provide a signal which indicates "power lost" (or, conversely, "power good")