2023-09-18 11:20 PM - edited 2023-09-18 11:22 PM
Hello. I am currently working with the STM32L031 Nucleo board:
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:
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
2023-09-19 2:04 AM - edited 2023-09-19 2:07 AM
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!
2023-09-19 3:23 AM - edited 2023-09-19 3:37 AM
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:
That would allow me to use printf to console.
Is my idea correct?
2023-09-19 3:55 AM
2023-09-19 4:37 AM - edited 2023-09-19 4:39 AM
> 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.
2023-09-19 9:17 PM - edited 2023-09-19 9:18 PM
The connectors your are refering (needle connectors) are also known as Tag Connect :) These are exactly the connectors that I am planning to use :)