[Dude] STM32L053C8 and Arduino framework

Hi,

I am interesting in develop a board that it use a STM32L053C8 microcontroller. Could i use the Arduino framework with this microcontroller?

I have could see that the STM32L053R8 could be program using Arduino framework but i dont know if the C version is possible.

Thanks,
Regards.

We do have support for the 32L0538DISCOVERY which can be programmed with mbed-os and STM32Cube.

But neither the STM32Duino Core nor the Maple core support do have support for a STM32L053C8. However, as I learned myself recently, it’s relatively easy to add new board to the STM32Duino core. I can make a pullrequest for that board.

Do you just use the bare chip or do you have it on some Nucleo/Discovery board?

Hi,

Thanks for your reply. Actually i have the STM32L053C8 integrated in my own board and i am checking the STM32Cube. I am not using Nucleo/Discovery board.

It is my first time with this stm32 and i am starting to know. Maybe it could be better choose the R version instead of C version.

Actually, i am using an internal clock (HSI).

Could you have create the new board for STM32L053C8? What do you need to do it?

Thanks,
Best Regards,

But you want to use Arduino, right? (Which is C++!)

Nothing really, it’s all written in the guide what to do. I can put up a quick PlatformIO demo in like an hour.

1 Like

Hi,

Yes, i want use Arduino and if it possible, using platformio.

Thanks so much.
Regards,

Hey,

could you please try the following.

  • update PlatformIO to the most recent development version, using pio upgrade --dev (needs a PIO 4 beta version, check with pio --version), (when using VSCode, open a PIO Terminal and type the commands in, restart afterwards)
  • create a project, any board / microcontroller will suffice
  • change the project’s platformio.ini to
[env:genericSTM32L053C8]
platform = https://github.com/maxgerhardt/platform-ststm32.git#develop
platform_packages = framework-arduinostm32 @ https://github.com/maxgerhardt/framework-arduinostm32.git
board = genericSTM32L053C8
framework = arduino
; only for debugging: Disable optimize for speed,
; optimize for debug instead
build_unflags = -Os
build_flags = -g3 -ggdb  -Og
  • add a src\main.cpp file
#include <Arduino.h>

int ledPin = PB7;
int blinkLength = 250;

void setup() {
	pinMode(ledPin, OUTPUT);
	//USART2, TX = PA2, RX = PA3
	Serial.begin(115200);
}

void loop() {
	Serial.println("Blinky");
	digitalWrite(ledPin, 0);
	delay(blinkLength);
	digitalWrite(ledPin, 1);
	delay(blinkLength);
}
  • change PB7 to the actual pin of the LED
  • upload by attaching an ST-Link to the chip’s SWD pins or use a different upload_protocol option in the platformio.ini (can be “jlink”, “stlink”, “blackmagic”, “serial”, “dfu”, only stlink tested)
  • re-initialize the project (“Rebuild Intellisense Index” or pio init --ide=<ide-you-use>) for updated IDE integration
  • compile project (Run button or pio run)
  • should result in
arm-none-eabi-objcopy -O binary .pio\build\genericSTM32L053C8\firmware.elf .pio\build\genericSTM32L053C8\firmware.bin
Memory Usage -> http://bit.ly/pio-memory-usage
DATA:    [=         ]  13.5% (used 1108 bytes from 8192 bytes)
PROGRAM: [===       ]  25.5% (used 16720 bytes from 65536 bytes)
 [SUCCESS] Took 16.19 seconds 
  • pio run -t upload or the upload button in your IDE to upload.

Hi,

Thanks for your effort.

I am following your instructions and i get this error when i was building:

#include “stm32l0xx_hal_conf.h”

      ^~~~~~~~~~~~~~~~~~~~~~

compilation terminated.

*** [.pio\build\genericSTM32L053C8\FrameworkArduino\IPAddress.cpp.o] Error 1

*** [.pio\build\genericSTM32L053C8\FrameworkArduino\Print.cpp.o] Error 1

========================== [ERROR] Took 3.26 seconds ==========================

Thanks, the error was on my side. Sneakily, the package I want to replace is called framework-arduinoststm32 and not framework-arduinostm32. Tiny difference.

Please try with this platformio.ini:

[env:genericSTM32L053C8]
platform = https://github.com/maxgerhardt/platform-ststm32.git#develop
platform_packages = framework-arduinoststm32 @ https://github.com/maxgerhardt/framework-arduinostm32-modded.git
board = genericSTM32L053C8
framework = arduino
; only for debugging: Disable optimize for speed,
; optimize for debug instead
build_unflags = -Os
build_flags = -g3 -ggdb  -Og

Hi,

Yes, works ok.

Led pin change but the Serial comunicaction not work.

Thanks,

Regards,

Have you connected the TX pin of the MCU (PA_2) to the RX pin of your serial adapter? Have you established a common GND between them?

Hi,

Yes, they are connected and communication tested using CubeMX, but when i try with your example, not work.
Thanks,

Regards,

Could you run pio platform update, pio run -t clean and then a recompile and upload again. I’ve changed it to use USART1 with TX on PA9. (commit). Could you try attach your serial adapter’s RX to that pin, and GND to GND, with a baud of 115200.

Hi,

This pins are used, could you change to LPUart (PB10, PB11)?

Thanks,

Regards,

Then please use

main.cpp

#include <Arduino.h>

int ledPin = PB7;
int blinkLength = 250;

void setup() {
	pinMode(ledPin, OUTPUT);
	SerialLP1.begin(115200);
}

void loop() {
	SerialLP1.println("Blinky");
	digitalWrite(ledPin, 0);
	delay(blinkLength);
	digitalWrite(ledPin, 1);
	delay(blinkLength);
}

and add

build_flags = -D ENABLE_HWSERIALLP1

at the end of the platformio.ini.

Hi,

Works well, i can receive the uart messages.

The comunication protocols should be configured using the build flags? If i want use the UART2, how can i configure?

I need learn more about how platformio works.

Thanks,
Regards.