2018-03-03 03:58 PM
Hi,
I am developing a code in Visual Studio/visualgdb for STM32L476VG Discovery Board. How do I set up UART on this board so that I would be able to print my output on a terminal program (teraTerm, PuTTY etc)? Is there any standard code library available for this specific problem? I am using ST-Link debugger and STM32CubeMX for skeleton code generation.
Thank you!
2018-03-04 07:12 AM
Initialize the port/pins supporting the VCP on your board (see User Manual)
Add code hosting that USART
#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__ */...
/**
* @brief Retargets the C library printf function to the USART. * @param None * @retval None */PUTCHAR_PROTOTYPE{ /* Place your implementation of fputc here */ /* e.g. write a character to the USART1 and Loop until the end of transmission */ HAL_UART_Transmit(&UartHandle, (uint8_t *)&ch, 1, 0xFFFF);return ch;
}