How to use PC14/PC15 as GPIO on STM32F407VGT6

Post here all questions related to STM32 core if you can't find a relevant section!
Post Reply
troyangelo
Posts: 3
Joined: Tue Feb 20, 2024 9:29 am

How to use PC14/PC15 as GPIO on STM32F407VGT6

Post 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 ?
User avatar
fpiSTM
Posts: 1723
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

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

Post by fpiSTM »

Which board you select to build?
Code?
troyangelo
Posts: 3
Joined: Tue Feb 20, 2024 9:29 am

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

Post by troyangelo »

I have tried the following board variants:

[env:diymore_f407vgt]
[env:disco_f407vg]
ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

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

Post 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
User avatar
fpiSTM
Posts: 1723
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

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

Post 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.
troyangelo
Posts: 3
Joined: Tue Feb 20, 2024 9:29 am

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

Post 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.
Post Reply

Return to “General discussion”