Skip to content

Calling Serial.end() on STM32L073RZTx results in high power consumption #119

Closed
@CropWatchDevelopment

Description

@CropWatchDevelopment

Please, before reporting any issue

Any questions/feedback/suggestions should be discussed on the stm32duino forum:

⚠ 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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidThis doesn't seem right

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions