2024-10-18 11:42 PM - last edited on 2024-10-19 03:15 AM by Andrew Neil
hey how to use printf in stm32f429i-disc1 board and my mcu is stm32f103cbt6
Solved! Go to Solution.
2024-10-29 09:15 AM
@syedhashmiraza wrote:
hello
can you provide me a disign setting for printf
Hello,
Attached a project that prints "Hollo World" using printf over USART1.
Need first to check which COM was allocated by windows to your STLINK VCP in Device manager:
Then in the HyperTerminal to configure these parameters:
Baudrate: 115200
Datasize: 7
Parity: None
Handshake: Off
Hope it helps.
2024-10-18 11:51 PM
Hello @syedhashmiraza and welcome to the ST Community :smiling_face_with_smiling_eyes:.
I suggest you to take a look at this article. It should be helpful.
Best Regards.
STTwo-32
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-10-18 11:55 PM
hey how to use printf in stm32f429i-disc1 board and my mcu is stm32f103cbt6
2024-10-19 01:29 AM - edited 2024-10-19 01:34 AM
as @STTwo-32 already said, see this article:
And here's a 3rd-party article on the same:
Tip:
Get the basic direct UART output working before adding the printf stuff.
2024-10-19 01:33 AM - edited 2024-10-19 01:36 AM
@syedhashmiraza wrote:in stm32f429i-disc1 board and my mcu is stm32f103cbt6
That doesn't make sense!
As its name suggests, the stm32f429i-disc1 board contains an stm32f429i microcontroller - not an stm32f103cbt6.
But, anyhow, the method to get printf working is the same irrespective of what microcontroller you use.
2024-10-19 03:35 AM
iam using stm32f429i-disc1 microcontroller for debug reason how to use printf
2024-10-19 03:37 AM
i treid this one but still printf is not working
2024-10-19 05:01 AM
Do you have USART output working? Via HAL_UART_Transmit()
Show code.
Plumb that into __io_putchar() or syscalls/_write()
2024-10-19 06:10 AM - last edited on 2024-10-19 03:28 PM by SofLit
#include "main.h"
#include "cmsis_os.h"
#include "usb_host.h"
#include <stdio.h>
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_CRC_Init(void);
static void MX_DMA2D_Init(void);
static void MX_FMC_Init(void);
static void MX_I2C3_Init(void);
static void MX_LTDC_Init(void);
static void MX_SPI5_Init(void);
static void MX_TIM1_Init(void);
static void MX_USART1_UART_Init(void);
void StartDefaultTask(void const * argument);
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
PUTCHAR_PROTOTYPE
{
HAL_UART_Transmit(&huart, (uint8_t *)&ch, 1, 0xFFFF);
return ch;
}
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_CRC_Init();
MX_DMA2D_Init();
MX_FMC_Init();
MX_I2C3_Init();
MX_LTDC_Init();
MX_SPI5_Init();
MX_TIM1_Init();
MX_USART1_UART_Init();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
/* USER CODE BEGIN RTOS_MUTEX */
/* add mutexes, ... */
/* USER CODE END RTOS_MUTEX */
/* USER CODE BEGIN RTOS_SEMAPHORES */
/* add semaphores, ... */
/* USER CODE END RTOS_SEMAPHORES */
/* USER CODE BEGIN RTOS_TIMERS */
/* start timers, add new ones, ... */
/* USER CODE END RTOS_TIMERS */
/* USER CODE BEGIN RTOS_QUEUES */
/* add queues, ... */
/* USER CODE END RTOS_QUEUES */
/* Create the thread(s) */
/* definition and creation of defaultTask */
osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 4096);
defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL);
/* USER CODE BEGIN RTOS_THREADS */
/* add threads, ... */
/* USER CODE END RTOS_THREADS */
while (1)
{
printf("Hello World\n\r");
HAL_Delay(1000);
}
/* Start scheduler */
osKernelStart();
/* We should never get here as control is now taken by the scheduler */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
2024-10-19 06:32 AM
Do you have USART output working? Via HAL_UART_Transmit()
This a Yes / No question, it needs to work for printf() to succeed
How about
void OutString(char *s)
{
while(*s) __io_putchar(*s++);
}
OutString("Hello World!\n");
Look at the code initializing the UART, clocks and pins related to it, perhaps the MSP file.
USART1 PA9:TX, PA10:RX