AnsweredAssumed Answered

UART2 doesn't sent data from TX

Question asked by Takayoshi Ishii on Jul 20, 2017
Latest reply on Jul 31, 2017 by Takayoshi Ishii

I made a program and it works well without UART2. I just made a simple program but nothing happend on the TX pin of the UART2.

 

while (1)
{
/* USER CODE END WHILE */

/* USER CODE BEGIN 3 */
displayBuffer[0]++;
updateLcd();
HAL_UART_Transmit(&huart2, &displayBuffer[0], 1, 0xFFFF);
tmp++;
HAL_Delay(1000);
}

 

"updateLcd()" function is using I2C and the clock source is same of UART2, so I think the clock for UART2 works. I2C works well.

TX line voltage continues hi, as idle. No data come up.

I can see the TDR resistor changes the value each 1 sec, so my data is stored in TDR for sure.

 

I tried to not use HAL_UART_Transmit() function and tried to write the data directly into the TDR like following, the result was same...

 

huart2.Instance->TDR = displayBuffer[0];

 

 

The periferal clock is 16MHz, and the UART2 setting is following.

 

/* USART2 init function */
static void MX_USART2_UART_Init(void)
{

huart2.Instance = USART2;
huart2.Init.BaudRate = 9600;
huart2.Init.WordLength = UART_WORDLENGTH_8B;
huart2.Init.StopBits = UART_STOPBITS_1;
huart2.Init.Parity = UART_PARITY_NONE;
huart2.Init.Mode = UART_MODE_TX_RX;
huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart2.Init.OverSampling = UART_OVERSAMPLING_16;
huart2.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
huart2.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if (HAL_UART_Init(&huart2) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}

}

 

Thank you!

Outcomes