Hello friends,
I am doing experiments to check the differences between an Arduino standard board and a STM32 standard board using the ArduinoIDE.
In a first test, I verified and uploaded the sample program "Blink" to the STM32L476RG board:
void setup () {
pinMode (LED_BUILTIN, OUTPUT);
}
void loop () {
digitalWrite (LED_BUILTIN, HIGH);
delay (1000);
digitalWrite (LED_BUILTIN, LOW);
delay (1000);
}
The program worked correctly.
After that, I changed the variable LED_BUILTIN to pin PA-5, which corresponds to LED1 embedded in the board:
void setup () {
pinMode (PA_5, OUTPUT);
}
void loop () {
digitalWrite (PA_5, HIGH);
delay (500);
digitalWrite (PA_5, LOW);
delay (500);
}
This time, the program did not work.
I'm trying to get some flexibility when porting programs going beyond sample programs, but it seems that things are not so simple ...
Trying to port Arduino programs to STM32 boards.
Trying to port Arduino programs to STM32 boards.
- Attachments
-
- Pinagem-small.jpg (95.49 KiB) Viewed 11309 times
Re: Trying to port Arduino programs to STM32 boards.
Remove the underscores from the pin names.
Re: Trying to port Arduino programs to STM32 boards.
If you want to use the PinName (PA_5) you will need to convert to a DigitalPin.
Then you can use the digitalWriteFast function that takes a PinName as a parameter:
or simpler:
Code: Select all
pinMode(pinNametoDigitalPin(PA_5), OUTPUT);
Code: Select all
digitalWriteFast(PA_5, HIGH);
delay(500);
digitalWriteFast(PA_5, LOW);
delay(500);
Code: Select all
digitalToggleFast(PA_5);
delay(500);
Re: Trying to port Arduino programs to STM32 boards.
The both ways worked fine, thank you very much, friends!
Re: Trying to port Arduino programs to STM32 boards.
Why just not use PA5?
Re: Trying to port Arduino programs to STM32 boards.
Yes, the simplest way is the one you mentioned. However, it is interesting to see that there is more than one way to do the same thing, following the syntax that appears in "pins_arduino.h".
Re: Trying to port Arduino programs to STM32 boards.
Right "arduino" syntax is PA5
PA_5 naming used internally and not for "public"
PA_5 naming used internally and not for "public"
Re: Trying to port Arduino programs to STM32 boards.
Perfect, stas2z!
With the help of friends, I will gradually understand these particularities.
Thanks!
With the help of friends, I will gradually understand these particularities.
Thanks!