cancel
Showing results for 
Search instead for 
Did you mean: 

Set the TX pin low before each UART transmission

Posted on April 10, 2018 at 15:34

Hi,

   I have a peculiar situation in which is necessary that the signal of pin TX has to remain in level 0 for 1ms, before performing each transmission through the uart.

   I tried to perform DeInit (HAL_UART_MspDeInit), recofigured the GPIO setting the TX pin as output to zero, a delay, reinit the UART (HAL_UART_MspInit and MX_USART1_UART_Init) and than start the transmission. But after the 'DeInit' the uart does not transmit.

The uart transmission works normally without this procedure.

How to solve this? What is the proper way to do that?

Thank you in advance.

Code:

...

HAL_UART_MspDeInit(&huart1);

HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10);

GPIO_InitStruct.Pin = GPIO_PIN_9;

GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

HAL_GPIO_WritePin( GPIOA, GPIO_PIN_9 , GPIO_PIN_RESET );

HAL_Delay(1);

HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10);

MX_USART1_UART_Init();

HAL_UART_Transmit_IT( &huart1,(uint8_t*)bufferTxUart1, len );

   Using KEIL, HAL library, with STM32F103.

#control-tx-pin #stm32f #init #hal-uart #deinit
1 REPLY 1
Posted on April 10, 2018 at 23:26

You don't need to deinit/reinit the USART, just do the GPIO reconfiguration.

JW