cancel
Showing results for 
Search instead for 
Did you mean: 

Can't program custom board, PB3 and PB4 are not working as GPIO

Demiañ
Associate II

Hi!

I have problems programing my custom board, I'm using a STM32F446RCT6, and I couldn't  establish a connection with my board, neither from STM32CubeIDE nor STM32CubeProgrammer.
after a lot of time trying to debug the problem I found out that actually I can establish a connection (an program) the board, but only if I'm pressing two very specific buttons.

The buttons were designed as general purpose buttons, but it seems they are connected to PB3 (JTDO) and PB4 (NJRST). We thought this pins could be configured as GPIO as well, but it seems something in the way those pins work is causing trouble.

In the reference manual it states:
"
The debug pins are in AF pull-up/pull-down after reset:

PA15: JTDI in pull-up
PA14: JTCK/SWCLK in pull-down
PA13: JTMS/SWDAT in pull-up
PB4: NJTRST in pull-up
PB3: JTDO in floating state
"
I'm assuming this is the problem; but I don't know if there is a way to configure PB3 and PB4 as GPIOs from the start in order to program the board correctly.

Demia_0-1743829812756.png

Demia_1-1743829841696.png

Tank you in advance!

10 REPLIES 10
mƎALLEm
ST Employee

Hello,

For STM32F4 hardware reference better to refer to the AN4488

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

The STM32F446RCT6 supports SWD.

If you're short of pins, why use JTAG ?

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

As far as I know I'm not using JTAG; on STM32CubeIDE, on the SYS window it is selected SWD. 

Thanks for the advice, I'm reading the AN4488:

Demia_1-1744077332875.png

It states that once JTAG is released by the user software, those pins can be used as GPIO's. But I can't achieve that on my board. I think my problem is that JNTRST is wired to 3.3V and JTDO/TRACESWO is wired to GND, so the board thinks those pins are not being released. 

Is there a way to solve this from software?

Chris21
Senior II

From the Reference Manual:

33.4.4 Using serial wire and releasing the unused debug pins as GPIOs
To use the serial wire DP to release some GPIOs, the user software must change the GPIO
(PA15, PB3 and PB4) configuration mode in the GPIO_MODER register. This releases
PA15, PB3 and PB4 which now become available as GPIOs.

Thanks a lot.

Just to be sure, to change GPIO_MODER register I need to change pinout configuration on SRM32CubeIDE?

Demia_0-1744061347005.png

Cause I've tried it, but my board is still not working. 

When I say that I cannot program my board what I mean is that, in STM32CubeProgramer I get this message when I try to connect:

Demia_1-1744061476516.png


And that in STM32CubeIDE I get this message when I try to run debug:

Demia_2-1744061559283.png

 



Chris21
Senior II

 

I was answering this "a way to configure PB3 and PB4 as GPIOs", which does not have to do with programming.

 

Looking at your statement "configure PB3 and PB4 as GPIOs from the start in order to program the board correctly.", I don't think that makes sense.  To program you would want the pins in their default state, operating as JTAG / SWD.

 

Okay, maybe there is something I'm not understanding; I want to use only SWD, that's why I want to disable JTAG.

I wanted to change the configuration of PB3 and PB4 because I though that would solve the issue; but it seems it is not working. 

Do you think this make sense? Maybe the problem is something else I don't see, but I though about PB4 and PB3, because the only way I was able to program or connect to the board was pressing the buttons connected with PB3 and PB4.

Chris21
Senior II

 

Normally your programming device / application has a configurable setting that you can specify SWD or JTAG, you should not have to do anything with the firmware to program the micro.

By "JTDO/TRACESWO is wired to GND" do you mean pulled down (through a resistor)?

This: "I can establish a connection (an program) the board, but only if I'm pressing two very specific buttons." sounds like an important clue.