Skip to main content
Visitor II
April 4, 2025
Question

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

  • April 4, 2025
  • 5 replies
  • 951 views

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!

    This topic has been closed for replies.

    5 replies

    Technical Moderator
    April 5, 2025

    Hello,

    For STM32F4 hardware reference better to refer to the AN4488

    DemiañAuthor
    Visitor II
    April 7, 2025

    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?

    Super User
    April 5, 2025

    The STM32F446RCT6 supports SWD.

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

    DemiañAuthor
    Visitor II
    April 6, 2025

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

    Graduate
    April 7, 2025

    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.

    DemiañAuthor
    Visitor II
    April 7, 2025

    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

     



    Graduate
    April 7, 2025

     

    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.

     

    DemiañAuthor
    Visitor II
    April 8, 2025

    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.

    Graduate
    April 8, 2025

     

    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.

    DemiañAuthor
    Visitor II
    April 8, 2025

    Yes, (PB3) JTDO/TRACESWO is being pulled down through a 10k resistor and (PB4) NJTRST is being pulled up through a 10k resistor as well.

    This is because we wanted to use those pins for general purpose buttons.