BlackPill STM32F411CE PA11 PA12 Digital Out Not Working

Post here first, or if you can't find a relevant section!
Post Reply
imk
Posts: 31
Joined: Fri Sep 24, 2021 9:26 pm

BlackPill STM32F411CE PA11 PA12 Digital Out Not Working

Post by imk »

Hello,
Environment Win10 Pro 64, IDE2 RC3 and IDE 1.8.16, STLink V3 Programmer
I have a simple Digital Output Pin test function that i am using to test Nine VL53LOX XShut pins and PA11 & PA12 do not toggle any ideas please?
I have turned off USB Support in IDE and even unplug the USB and powered the breadboard which the Black Pill is mounted on from external 3.3v.
So the only connection to the board is my oscilloscope to monitor the digital output pins.
Where PA11 is always low and PA12 is always high, but the rest of the pins toggle as expected.
I have also tried a different Black Pill in a different breadboard and results are same.


Many thanks in advance IMK

#define VL53LOX_1_XSHUT_PIN PB12
#define VL53LOX_2_XSHUT_PIN PB13
#define VL53LOX_3_XSHUT_PIN PB14
#define VL53LOX_4_XSHUT_PIN PB15
#define VL53LOX_5_XSHUT_PIN PA8
#define VL53LOX_6_XSHUT_PIN PA11
#define VL53LOX_7_XSHUT_PIN PA12
#define VL53LOX_8_XSHUT_PIN PA15
#define VL53LOX_9_XSHUT_PIN PB3

// --------------------------------------------------- VL53L0X_XShut_PinTest() -----------------------------------------------------
void VL53L0X_XShut_PinTest( void )
{
pinMode( VL53LOX_1_XSHUT_PIN , OUTPUT );
pinMode( VL53LOX_2_XSHUT_PIN , OUTPUT );
pinMode( VL53LOX_3_XSHUT_PIN , OUTPUT );
pinMode( VL53LOX_4_XSHUT_PIN , OUTPUT );
pinMode( VL53LOX_5_XSHUT_PIN , OUTPUT );
pinMode( VL53LOX_6_XSHUT_PIN , OUTPUT );
pinMode( VL53LOX_7_XSHUT_PIN , OUTPUT );
pinMode( VL53LOX_8_XSHUT_PIN , OUTPUT );
pinMode( VL53LOX_9_XSHUT_PIN , OUTPUT );

while( TRUE )
{
digitalWrite( VL53LOX_1_XSHUT_PIN , HIGH );
delay( 10 );
digitalWrite( VL53LOX_1_XSHUT_PIN , LOW );

digitalWrite( VL53LOX_2_XSHUT_PIN , HIGH );
delay( 10 );
digitalWrite( VL53LOX_2_XSHUT_PIN , LOW );

digitalWrite( VL53LOX_3_XSHUT_PIN , HIGH );
delay( 10 );
digitalWrite( VL53LOX_3_XSHUT_PIN , LOW );

digitalWrite( VL53LOX_4_XSHUT_PIN , HIGH );
delay( 10 );
digitalWrite( VL53LOX_4_XSHUT_PIN , LOW );

digitalWrite( VL53LOX_5_XSHUT_PIN , HIGH );
delay( 10 );
digitalWrite( VL53LOX_5_XSHUT_PIN , LOW );

digitalWrite( VL53LOX_6_XSHUT_PIN , HIGH );
delay( 10 );
digitalWrite( VL53LOX_6_XSHUT_PIN , LOW );

digitalWrite( VL53LOX_7_XSHUT_PIN , HIGH );
delay( 10 );
digitalWrite( VL53LOX_7_XSHUT_PIN , LOW );

digitalWrite( VL53LOX_8_XSHUT_PIN , HIGH );
delay( 10 );
digitalWrite( VL53LOX_8_XSHUT_PIN , LOW );

digitalWrite( VL53LOX_9_XSHUT_PIN , HIGH );
delay( 10 );
digitalWrite( VL53LOX_9_XSHUT_PIN , LOW );

delay( 10 );
} // end while forever

}
by ozcar » Tue Feb 08, 2022 8:10 pm
My first thought was to ask what core you are using, but from your other thread it seems you are using the official ST core.

It will make your code easier to view and copy if you use the code tag.

I took your code and tried it on one of those Black Pill F411 boards. This was using IDE 1.8.18 and ST core 2.2.0. I don’t have a V3 STLink, but I can’t see that making a difference. As you did not give a self-contained “sketch”, I added an empty startup(), changed the name of your test routine to loop, and as there was no definition of ‘TRUE”, changed the while statement. So entire “sketch” looks like this (using code tag):

Code: Select all

#define VL53LOX_1_XSHUT_PIN PB12
#define VL53LOX_2_XSHUT_PIN PB13
#define VL53LOX_3_XSHUT_PIN PB14
#define VL53LOX_4_XSHUT_PIN PB15
#define VL53LOX_5_XSHUT_PIN PA8
#define VL53LOX_6_XSHUT_PIN PA11
#define VL53LOX_7_XSHUT_PIN PA12
#define VL53LOX_8_XSHUT_PIN PA15
#define VL53LOX_9_XSHUT_PIN PB3

void setup()
{
  
}

// --------------------------------------------------- VL53L0X_XShut_PinTest() -----------------------------------------------------
void loop( void )
{
pinMode( VL53LOX_1_XSHUT_PIN , OUTPUT );
pinMode( VL53LOX_2_XSHUT_PIN , OUTPUT );
pinMode( VL53LOX_3_XSHUT_PIN , OUTPUT );
pinMode( VL53LOX_4_XSHUT_PIN , OUTPUT );
pinMode( VL53LOX_5_XSHUT_PIN , OUTPUT );
pinMode( VL53LOX_6_XSHUT_PIN , OUTPUT );
pinMode( VL53LOX_7_XSHUT_PIN , OUTPUT );
pinMode( VL53LOX_8_XSHUT_PIN , OUTPUT );
pinMode( VL53LOX_9_XSHUT_PIN , OUTPUT );

while( 1 )
{
digitalWrite( VL53LOX_1_XSHUT_PIN , HIGH );
delay( 10 );
digitalWrite( VL53LOX_1_XSHUT_PIN , LOW );

digitalWrite( VL53LOX_2_XSHUT_PIN , HIGH );
delay( 10 );
digitalWrite( VL53LOX_2_XSHUT_PIN , LOW );

digitalWrite( VL53LOX_3_XSHUT_PIN , HIGH );
delay( 10 );
digitalWrite( VL53LOX_3_XSHUT_PIN , LOW );

digitalWrite( VL53LOX_4_XSHUT_PIN , HIGH );
delay( 10 );
digitalWrite( VL53LOX_4_XSHUT_PIN , LOW );

digitalWrite( VL53LOX_5_XSHUT_PIN , HIGH );
delay( 10 );
digitalWrite( VL53LOX_5_XSHUT_PIN , LOW );

digitalWrite( VL53LOX_6_XSHUT_PIN , HIGH );
delay( 10 );
digitalWrite( VL53LOX_6_XSHUT_PIN , LOW );

digitalWrite( VL53LOX_7_XSHUT_PIN , HIGH );
delay( 10 );
digitalWrite( VL53LOX_7_XSHUT_PIN , LOW );

digitalWrite( VL53LOX_8_XSHUT_PIN , HIGH );
delay( 10 );
digitalWrite( VL53LOX_8_XSHUT_PIN , LOW );

digitalWrite( VL53LOX_9_XSHUT_PIN , HIGH );
delay( 10 );
digitalWrite( VL53LOX_9_XSHUT_PIN , LOW );

delay( 10 );
} // end while forever

}
For me it works as expected. On all the pins that you use, I get the same 10ms pulse (but of course out of phase with each other). That was with USB Support None selected in the IDE.

If instead I select either of the CDC options for USB Support in the IDE, then I get the same as you, PA11 stays low, and PA12 high. So it does appear to be related to USB.

As the code you gave was obviously not complete, maybe there is something else in there that causes it. Try with just the code as above in this post and see if that works. If not, then I don’t know – maybe turn on “show verbose output” in the IDE preferences and see if that gives any clues.
Go to full post
1201 Alarm
ozcar
Posts: 143
Joined: Wed Apr 29, 2020 9:07 pm
Answers: 5

Re: BlackPill STM32F411CE PA11 PA12 Digital Out Not Working

Post by ozcar »

My first thought was to ask what core you are using, but from your other thread it seems you are using the official ST core.

It will make your code easier to view and copy if you use the code tag.

I took your code and tried it on one of those Black Pill F411 boards. This was using IDE 1.8.18 and ST core 2.2.0. I don’t have a V3 STLink, but I can’t see that making a difference. As you did not give a self-contained “sketch”, I added an empty startup(), changed the name of your test routine to loop, and as there was no definition of ‘TRUE”, changed the while statement. So entire “sketch” looks like this (using code tag):

Code: Select all

#define VL53LOX_1_XSHUT_PIN PB12
#define VL53LOX_2_XSHUT_PIN PB13
#define VL53LOX_3_XSHUT_PIN PB14
#define VL53LOX_4_XSHUT_PIN PB15
#define VL53LOX_5_XSHUT_PIN PA8
#define VL53LOX_6_XSHUT_PIN PA11
#define VL53LOX_7_XSHUT_PIN PA12
#define VL53LOX_8_XSHUT_PIN PA15
#define VL53LOX_9_XSHUT_PIN PB3

void setup()
{
  
}

// --------------------------------------------------- VL53L0X_XShut_PinTest() -----------------------------------------------------
void loop( void )
{
pinMode( VL53LOX_1_XSHUT_PIN , OUTPUT );
pinMode( VL53LOX_2_XSHUT_PIN , OUTPUT );
pinMode( VL53LOX_3_XSHUT_PIN , OUTPUT );
pinMode( VL53LOX_4_XSHUT_PIN , OUTPUT );
pinMode( VL53LOX_5_XSHUT_PIN , OUTPUT );
pinMode( VL53LOX_6_XSHUT_PIN , OUTPUT );
pinMode( VL53LOX_7_XSHUT_PIN , OUTPUT );
pinMode( VL53LOX_8_XSHUT_PIN , OUTPUT );
pinMode( VL53LOX_9_XSHUT_PIN , OUTPUT );

while( 1 )
{
digitalWrite( VL53LOX_1_XSHUT_PIN , HIGH );
delay( 10 );
digitalWrite( VL53LOX_1_XSHUT_PIN , LOW );

digitalWrite( VL53LOX_2_XSHUT_PIN , HIGH );
delay( 10 );
digitalWrite( VL53LOX_2_XSHUT_PIN , LOW );

digitalWrite( VL53LOX_3_XSHUT_PIN , HIGH );
delay( 10 );
digitalWrite( VL53LOX_3_XSHUT_PIN , LOW );

digitalWrite( VL53LOX_4_XSHUT_PIN , HIGH );
delay( 10 );
digitalWrite( VL53LOX_4_XSHUT_PIN , LOW );

digitalWrite( VL53LOX_5_XSHUT_PIN , HIGH );
delay( 10 );
digitalWrite( VL53LOX_5_XSHUT_PIN , LOW );

digitalWrite( VL53LOX_6_XSHUT_PIN , HIGH );
delay( 10 );
digitalWrite( VL53LOX_6_XSHUT_PIN , LOW );

digitalWrite( VL53LOX_7_XSHUT_PIN , HIGH );
delay( 10 );
digitalWrite( VL53LOX_7_XSHUT_PIN , LOW );

digitalWrite( VL53LOX_8_XSHUT_PIN , HIGH );
delay( 10 );
digitalWrite( VL53LOX_8_XSHUT_PIN , LOW );

digitalWrite( VL53LOX_9_XSHUT_PIN , HIGH );
delay( 10 );
digitalWrite( VL53LOX_9_XSHUT_PIN , LOW );

delay( 10 );
} // end while forever

}
For me it works as expected. On all the pins that you use, I get the same 10ms pulse (but of course out of phase with each other). That was with USB Support None selected in the IDE.

If instead I select either of the CDC options for USB Support in the IDE, then I get the same as you, PA11 stays low, and PA12 high. So it does appear to be related to USB.

As the code you gave was obviously not complete, maybe there is something else in there that causes it. Try with just the code as above in this post and see if that works. If not, then I don’t know – maybe turn on “show verbose output” in the IDE preferences and see if that gives any clues.
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: BlackPill STM32F411CE PA11 PA12 Digital Out Not Working

Post by ag123 »

do not select USB (CDC) Serial, PA11, PA12 is used for USB
ozcar
Posts: 143
Joined: Wed Apr 29, 2020 9:07 pm
Answers: 5

Re: BlackPill STM32F411CE PA11 PA12 Digital Out Not Working

Post by ozcar »

Imk was obviously already suspicious that it could be USB conflict. I don’t know what “turning off USB support in IDE” (as mentioned in original post) could mean other than to select USB Support None under tools. If I select that it works OK, I only tried selecting CDC to check/confirm that could cause the problem, and it does.

I don’t have the same IDE version though, or there is something else different in the environment, or perhaps in the whole sketch imk compiled???
Post Reply

Return to “General discussion”