1
\$\begingroup\$

I am trying to use the STM32F103RB Nucleo board. I am learning how to do serial comms so started with the classic 'Hello world' printed to a serial monitor.

Eventually, I want to print data to the serial monitor, while receiving data via different UART pins. The Nucleo uses pins 16 & 17 (PA22 & PA3) as the default Tx/Rx pins. I started with them, and had no problem. The code was simple:

#include "mbed.h"

Serial pc(PA_2, PA_3);

int main() {
        pc.printf("Hello World \n");
}

Looking through the DATASHEET I can see that pins 42 & 43 (PA9 & PA10) can also be used for UART, with PA9 Tx, & PA10 Rx. I decided to change the pin definitions for Tx and Rx, so the code now looked like this:

#include "mbed.h"

Serial pc(PA_9, PA_10);

int main() {
        pc.printf("Hello World \n");
}

And this now doesn't work. Looking through THIS PAGE I don't see why that doesn't work. I have used 'Serial', given it a name (pc), then defined the Tx and Rx pins. I am using the mBed online environment if that makes a difference to anything.

Can anyone see if there is some simple mistakle or something I have overlooked when trying to do what should be a simple task?

If there is any more information required, please ask.

| improve this question | | | | |
\$\endgroup\$
  • \$\begingroup\$ Search for remap function in mbed. Take look here \$\endgroup\$ – rom1nux Nov 28 '19 at 13:10
  • \$\begingroup\$ @rom1nux I have come across that page already. The accepted answer says you should be able to do it the way I have tried (Serial serial([your_tx_pin], [your_rx_pin]) and then provides a broken link. So it isn't really much help \$\endgroup\$ – MCG Nov 28 '19 at 13:15
  • \$\begingroup\$ No David say "Find a remap pin function in the mbed or move away from the online compiler then you can do what you want..." In low level ST provide a way to "remap" pin but I don't know if it's available on the bundle you use. If not, build your own. \$\endgroup\$ – rom1nux Nov 28 '19 at 13:20
  • 1
    \$\begingroup\$ But how are you connectimg the new pins to your PC??? The USB serial on the Nucleo only connects to the default pins. If you are using something else, explain exactly what and the exact connections. Also put a loop around your test and probe with a scope or cheap USB logic analyzer. \$\endgroup\$ – Chris Stratton Nov 28 '19 at 14:34
  • 1
    \$\begingroup\$ @ChrisStratton Never mind, it seems TeraTerm had decided to disconnect from the COM port without informing me. When I went to check, it had switched to a different port. Re-started it again, and it's now displaying the correct message. If you wouldn't mind writing an answer explaining the default pins and the removal of the links etc then I will gladly upvote/accept it. What a silly thing to overlook! \$\endgroup\$ – MCG Nov 28 '19 at 15:07
2
\$\begingroup\$

Along with SWD flashing, the debug interface chip on the Nucleo provides a USB<>serial functionality to allow the target chip to communicate with a PC.

But this functionality is hard wired to the default UART pins of the target.

If you wish to use different UART pins, you will need something to connect those to your PC as well or instead - either an external 3v3 USB-UART, or to somehow rewire the on board one.

The signals to the on-board one are routed via resistors which can be removed, and there are header footprints which could help with re-routing. For the 64-pin STM32 Nucleo, these can be seen in the schematic (circled in red).

enter image description here

| improve this answer | | | | |
\$\endgroup\$
  • \$\begingroup\$ I have included a picture of the relevant part of the Nucleo schematic, circling the resistors and the header pin, for the 64-pin version. Feel free to roll back if you wish. \$\endgroup\$ – MCG Nov 28 '19 at 15:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.