Description
Please, before reporting any issue
- Make sure you are using the latest Arduino_Core_STM32 version.
https://github.com/stm32duino/Arduino_Core_STM32/releases/latest - Make sure the issue is not already reported/fixed on GitHub or discussed on the stm32duino forum
- Submit a GitHub issue only for reporting a problem related to the repository.
- Avoid to submit a GitHub issue for project troubleshooting.
Any questions/feedback/suggestions should be discussed on the stm32duino forum:
- questions on the STM32 Core
- bugs/enhancements on the STM core: Bugs and enhancements
⚠ When reporting any issue, please try to provide all relevant information to help on its resolution.
Describe the bug
After calling begin() on HardwareSerial ports, running end() does not fully stop, and clean up the serial port.
Steps to reproduce the behavior:
Flash first code example, see a power useage of 25uA
Flash 2nd code sample, see power usepage of ~300uA
Expected behavior
The 1st example's current consumption should equal that of the 2nd
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: Linux Mint
- IDE version: PlatformIO
- Upload method: [e.g. SWD] STLINK v2's SWD
Hardware (please complete the following information):
- Board Name: STM32L073RZTx
- Extra hardware used if any: PowerProfiler 2
Additional context
Add any other context about the problem here.
Code example 1, Power consumption ~25uA:
#include <Arduino.h>
#include "STM32LowPower.h"
// Create HardwareSerial objects
HardwareSerial Serial1(USART1);
HardwareSerial Serial2(USART2);
HardwareSerial Serial4(USART4);
void setup()
{
// // Initialize serial ports for a short period
// Serial2.begin(115200);
// Serial1.begin(9600);
// Serial4.begin(9600);
// // // End the serial ports
// Serial2.end();
// Serial1.end();
// Serial4.end();
LowPower.begin();
LowPower.deepSleep(20000);
}
void loop()
{
// Nothing to do here
}
Code Example 2, Calls both Begin() and End() however, this example runs at ~500uA:
#include <Arduino.h>
#include "STM32LowPower.h"
// Create HardwareSerial objects
HardwareSerial Serial1(USART1);
HardwareSerial Serial2(USART2);
HardwareSerial Serial4(USART4);
void setup()
{
// Initialize serial ports for a short period
Serial2.begin(115200);
Serial1.begin(9600);
Serial4.begin(9600);
// // End the serial ports
Serial2.end();
Serial1.end();
Serial4.end();
LowPower.begin();
LowPower.deepSleep(20000);
}
void loop()
{
// Nothing to do here
}
FINALLY,
running this example rund at around 1mA:
#include <Arduino.h>
#include "STM32LowPower.h"
// Create HardwareSerial objects
HardwareSerial Serial1(USART1);
HardwareSerial Serial2(USART2);
HardwareSerial Serial4(USART4);
void setup()
{
// Initialize serial ports for a short period
Serial2.begin(115200);
Serial1.begin(9600);
Serial4.begin(9600);
// // // End the serial ports
// Serial2.end();
// Serial1.end();
// Serial4.end();
LowPower.begin();
LowPower.deepSleep(20000);
}
void loop()
{
// Nothing to do here
}