Black STM32F407ZG Board and LEDs

Post Reply
mklengel
Posts: 4
Joined: Sun Jan 03, 2021 9:48 pm

Black STM32F407ZG Board and LEDs

Post by mklengel »

I use this board:

STM32F407ZGT6 STM32 System ARM Core Board STM32F407 Development Board F407 Cortex-M4 Single-Chip Learning Board
https://www.aliexpress.com/item/4001089 ... 4c4dICMrQ7

Schematics
https://github.com/mcauser/BLACK_F407ZG ... matics.pdf

Image

Using VS Code and PlatformIO this seems to be the right board:
https://docs.platformio.org/en/v5.1.1/b ... 407zg.html

Flashing with a ST-Link V2 works without problems, but the typical Blinky program doesn't work as expected.
Instead of LED_D1 the LED_D2 blinks and vice versa. I don't understand what's wrong?! Any idea?

The LEDs are LED D1 (PF9) active low and LED D2 (PF10) active low.
LED_D1 and PF9 are connected, checked with impedance measurement.

main.cpp

Code: Select all

#include <Arduino.h>

void setup()
{
    // initialize LED digital pin as an output.
    pinMode(LED_D1, OUTPUT);
    //pinMode(LED_D2, OUTPUT);
}

void loop()
{
    // turn the LED off by making the voltage HIGH (active low)
    digitalWrite(LED_D1, HIGH);
    //digitalWrite(LED_D2, HIGH);

    delay(3000);

    // turn the LED on by making the voltage LOW (active low)
    digitalWrite(LED_D1, LOW);
    //digitalWrite(LED_D2, LOW);

    delay(1000);
}
by mlundin » Sat Apr 03, 2021 11:00 am
If you look in variant.cpp for this board at line 161, PF_10 is entered before PF_9 into the digtalPin[] array.
On the other hand in variant.h PF9 is declared before PF10, and after that LED_D1 and LED_D2 are declared as PF9 and PF10.

So the end effect is that LED_D1 = PF9 = 94 maps to digitalPin[94] = PF_10,
and LED_D2 = PF10 = 95 maps to digitalPin[95] = PF_9.
Go to full post
GonzoG
Posts: 403
Joined: Wed Jan 15, 2020 11:30 am
Answers: 27
Location: Prudnik, Poland

Re: Black STM32F407ZG Board and LEDs

Post by GonzoG »

It might be this board but there are few manufacturers that make them and there might be some differences.
LED_D1 and LED_D2 are just defined in board file as PF9 and PF10, it might be situation that when they wrote files for this board, they had different version, or just switched those 2 LEDs.
mklengel
Posts: 4
Joined: Sun Jan 03, 2021 9:48 pm

Re: Black STM32F407ZG Board and LEDs

Post by mklengel »

I thought about that, so I measured the connections between LED_D1 and PF9 and also LED_D2 and PF10.
They are connected exactly as in the attached screenshot (extract of the schematics in my first post).

LED_D3 is permanently on, showing power.
LED_D2 is attached to PF10 via R16 (I measured 510 Ω)
LED_D1 is attached to PF9 via R14 (I measured 510 Ω)
Bildschirmfoto 2021-04-03 um 00.23.01.png
Bildschirmfoto 2021-04-03 um 00.23.01.png (33.3 KiB) Viewed 9129 times
In addition the connection between the

PF9 header pin to the PF9 pin of the STM32F407ZGT6 and
PF10 header pin to the PF10 pin of the STM32F407ZGT6

can be seen in the following screenshot
Bildschirmfoto 2021-04-03 um 01.03.35.jpg
Bildschirmfoto 2021-04-03 um 01.03.35.jpg (53.36 KiB) Viewed 9129 times
and this picture shows the pinout of the STM32F407ZGT6
Bildschirmfoto 2021-04-03 um 01.04.21.jpg
Bildschirmfoto 2021-04-03 um 01.04.21.jpg (63.09 KiB) Viewed 9126 times
I measured the connections between the PF9 header pin and the PF9 pin and also the PF10 header pin to the PF10 pin of the STM32F407ZGT6. They seem to be correct (difficult to measure because the pins are very small).

I simply don't understand why LED_D2 is blinking in my Blinky example, it should be LED_D1.
Last edited by mklengel on Sun Apr 04, 2021 12:09 am, edited 2 times in total.
mlundin
Posts: 94
Joined: Wed Nov 04, 2020 1:20 pm
Answers: 6
Location: Sweden

Re: Black STM32F407ZG Board and LEDs

Post by mlundin »

If you look in variant.cpp for this board at line 161, PF_10 is entered before PF_9 into the digtalPin[] array.
On the other hand in variant.h PF9 is declared before PF10, and after that LED_D1 and LED_D2 are declared as PF9 and PF10.

So the end effect is that LED_D1 = PF9 = 94 maps to digitalPin[94] = PF_10,
and LED_D2 = PF10 = 95 maps to digitalPin[95] = PF_9.
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Black STM32F407ZG Board and LEDs

Post by fpiSTM »

Good catch @mlundin
We will fix that.
mklengel
Posts: 4
Joined: Sun Jan 03, 2021 9:48 pm

Re: Black STM32F407ZG Board and LEDs

Post by mklengel »

@mlundin: great! You have a sharp eye :-) Thx for the solution.

To give it a try: I changed the order of the lines 245 and 246 in
~/.platformio/packages/framework-arduinoststm32/variants/BLACK_F407XX/variant.cpp

Code: Select all

 PF_9,
 PF_10, // PF_10: LED D2, PF_9: LED D1 (active low)
and the correct LED_D1 is blinking.

For a similar board BLACK STM32F407VE the LEDs (LED_D2 and LED_D3) worked as expected.
In the same file as above ~/.platformio/packages/framework-arduinoststm32/variants/BLACK_F407XX/variant.cpp
the important lines 117 and 118 are in the right order

Code: Select all

PA_6,
PA_7, // PA_6: LED D2, PA_7: LED D3 (active LOW)
Regards
Michael
gervasd
Posts: 1
Joined: Tue Mar 29, 2022 7:02 am

Re: Black STM32F407ZG Board and LEDs

Post by gervasd »

It seems to me that LEDs everywhere add a little style and some beauty. What model of LEDs did you use to install on your computer? Unfortunately, I am not strong in electronics and physics to fully understand the circuits you described.
However, I know how to install LED strips. Last week I ordered a monochrome model on https://www.vont.com/product/smart-stri ... ip-lights/ and placed it in his office. I think that additional lighting would add some comfort to the room.
By the way, I haven't seen the board you described anywhere. Maybe it's some old model. Where can I buy it?
Post Reply

Return to “STM32F4 based boards”