Page 1 of 1

How to use PC14/PC15 as GPIO on STM32F407VGT6

Posted: Tue Feb 20, 2024 11:20 pm
by troyangelo
I have a custom board with an STM32F407VGT6 that I have trying to get ports PC14/15 to work as output ports. I am using STM32Arduino with PlatformIO IDE. Setting pinMode and then doing digitalWrite has no effect on those two ports. I suspect it has to do with the fact that those pins are also used for the LSE clock input, however I am not using LSE, so I assume it is disabled as mentioned in the datasheet. Interestingly, using STM32CubeIDE generated code works fine, however I can't figure out what the STM32CubeIDE code is doing that the STM32Arduino code is missing.

Anyone has any idea or thoughts on how I can get these ports working as normal GPIO outputs using STM32Arduino ?

Re: How to use PC14/PC15 as GPIO on STM32F407VGT6

Posted: Wed Feb 21, 2024 5:18 am
by fpiSTM
Which board you select to build?
Code?

Re: How to use PC14/PC15 as GPIO on STM32F407VGT6

Posted: Wed Feb 21, 2024 8:35 am
by troyangelo
I have tried the following board variants:

[env:diymore_f407vgt]
[env:disco_f407vg]

Re: How to use PC14/PC15 as GPIO on STM32F407VGT6

Posted: Wed Feb 21, 2024 1:19 pm
by ag123
PC14 OSC32_IN
PC15 OSC32_OUT
is normally used for a 32 khz crystal for the RTC.
it is probably not a good idea to use them as gpio ports. e.g. there is likely a 'not gate' connecting PC14 to PC15 with some extra stuff.
that 'not gate' is literally used as an amplifier, given sufficient conditions e,g, capacitors / inductors / resonator / crystal etc it may oscillate

Re: How to use PC14/PC15 as GPIO on STM32F407VGT6

Posted: Thu Feb 22, 2024 9:01 am
by fpiSTM
I've tested with a disco F407, LSE is not fitted so PC14 and PC15 are free.
Using default blink sketch using those pins and it works.
Maybe pio do some extra config preventing to use them...
Test with Arduino IDE.

Re: How to use PC14/PC15 as GPIO on STM32F407VGT6

Posted: Mon Feb 26, 2024 9:21 am
by troyangelo
Finally got it to work! Based on 'fpiSTM' post that they got it work on the discovery board. I uploaded my code to a disco F407 and it worked immediately (luckily, I had bought one when I started working on my F407 project... it really came in handy, it's always good to have the manufacturer's dev kit as a reference). After getting it to work on the Disco F407, I still could not figure out what was wrong with my custom board. Then I realized that while I had updated the build variant env, I forgot to also update the board parameter in platformio.ini (such a simple mistake caused me days of headache).

;[env:diymore_f407vgt]
[env:disco_f407vg]
;[env:generic_f407vg]
platform = ststm32
board = disco_f407vg
framework = arduino

Thank you all for your help and suggestions.