Loading...
 

Zephyr project on STM32

   Zephyr Workbench, a VSCode extension to manage Zephyr on STM32.
It enables users to easily create, develop, and debug Zephyr applications.
Main features:
  • Install host dependencies.
  • Import toolchain and SDK.
  • Create, configure, build and manage apps.
  • Debug STM32.
You can directly download it from the VSCode marketplace
For more details, visit the Zephyr Workbench

System Workbench for STM32


Printf issues on nucleoF401RE

Hello,
I’m currently using a nucleoF401RE with HAL cube drivers to control an arduino 9 axes motion shield.

I would like to send message to my pc terminal through the printf function but i have some trouble.
Since the Uart pin are not configured i have to do it myself, so, as recommended i implemented the HAL_UART_MspInit function:



GPIO_InitTypeDef GPIO_InitStruct;

__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_USART2_CLK_ENABLE();

/*Reglages des ports*/
GPIO_InitStruct.Pin = GPIO_PIN_2;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Alternate = GPIO_AF7_USART2;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

GPIO_InitStruct.Pin = GPIO_PIN_3;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);



And i set the huart handler as recommended :



huart.Instance = USART2;

huart.Init.BaudRate = 9600;
huart.Init.WordLength = UART_WORDLENGTH_8B;
huart.Init.StopBits = UART_STOPBITS_1;
huart.Init.Parity = UART_PARITY_NONE;
huart.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart.Init.Mode = UART_MODE_TX_RX;
huart.Init.OverSampling = UART_OVERSAMPLING_16;

if(HAL_UART_Init(&huart) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}



But when i’m using printf() function nothing happened... BUT if i used the function HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout) which is already implemented, i’m able to send data though the serial port.

Could you help me to “fix” the printf() function ? As i dont know how to send full words or data values with the HAL_UART_Transmit function.

Thank you very much
PMA

Tunisia

Hello Pierre-marie,

You have just to modify the _write function in your syscall.c and the ‘io_putchar’ in your main.c

just like mentioned in this topicQuestion

Regards,
Tarek


Thank you very much, i will try this !