cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L031 Programming and debugging using Tag Connect

LPetr.1
Senior

Hello. I am currently working with the STM32L031 Nucleo board:

https://www.st.com/resource/en/user_manual/um1956-stm32-nucleo32-boards-mb1180-stmicroelectronics.pdf

 

The board has integrated ST-LINK so it is quite easy and convenient to flash the device and debug the code. I also use the following code the be able to use printf statements to the console:

 

 

#ifdef __GNUC__
/* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf
   set to 'Yes') calls __io_putchar() */
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#endif /* __GNUC__ */


PUTCHAR_PROTOTYPE
{
  HAL_UART_Transmit(&huart2, (uint8_t *)&ch, 1, 0xFFFF);

  return ch;
}

 

 

My Questions:

I am planning to design my own board based on STM32L031. My custom board is not going to have integrated ST-Link. Instead, I will be using J-Link Plus Compact and a 10 pin Tag Connect to flash and debug the device.

Since this is my first time designing PCB based on STM32L031, I would like to clarify what is the correct way to route the STM32L031 to Tag connect(JLINK).

I have found the following pinout for the 10-pin Tag Connect:

 
 

tag_connect.png

 From what I understand, this should allow me to Flash and Debug. How can I also connect RX/TX for UART printfs?

 

Additionally, I would like to understand what are the TDI and TDO pins used for? The difference between 6 pin Tag Connect and 10 pin Tag Connect seems to be TDI and TDO pins

 

 

5 REPLIES 5
Pavel A.
Evangelist III

Instead of the 10-pin connector, consider the extended 14-pin connector and ST-LINKv3.

 

The RX/TX for UART connect to pins 13,14 on the connector for flat cable or to the golden strips connector on the ST-LINK itself.  TDI, TDO pins are for JTAG, you don't need these. Use the SWD mode.

Good luck!

Thanks for suggestion. Are there any other methods available? The board that I am designing is a very small device and using 14 pin connector might be an issue. I am already stretching it by using 10 pin connector...

 

My other idea:

use 6 pin Tag Connect for flashing and debugging and route USART2 RX/TX pins to some external header where I can connect USB->UART converter such as:

 

LPetr1_1-1695118966291.jpeg

That would allow me to use printf to console.

Is my idea correct?

 

It's certainly possible. I often use only SWD, SWC, GND on my boards. If I know I'll need a serial port for diagnostics and configuration on every board, I'll use a special connector. When the serial port is needed only for debugging and development, I just leave the small pads on the PCB and solder the wiress to them when I need it.
 
Pavel A.
Evangelist III

 The board that I am designing is a very small device and using 14 pin connector might be an issue. 

No problem. Get rid of the standard connector, solder the wires directly to the ST-LINK contacts. It is cheap.

Or consider a hole & needle connector (the cable is more expensive). Same, 10 pin.

The connectors your are refering (needle connectors) are also known as Tag Connect 🙂 These are exactly the connectors that I am planning to use 🙂