cancel
Showing results for 
Search instead for 
Did you mean: 

huart2 died on reception and needs repower

ICohe.1
Associate III

F4 board (Master) with huart1 & huart2 identically configured, talking to 2 identical boards(Slaves) with the same program. huart1 works perfectly, huart2 dies after receiving from slave.

Sequence:

Master sends 6 chars ( 9600) using HAL_UART_Transmit_IT() and slave answer with 20 chars repeatedly. Works fine when tested with huart1(on PB6,PB7).

Connecting the same slave to huart2(on PA2,PA3) instead, Master sends, slave received, slave answer with 20 chars, then Master try to send again but nothing coming out on the wire.

HAL_UART_Transmit_IT() still generate a call to HAL_UART_TxCpltCallback() but nothing is out.

The only way to get this single transaction again is to repower the Master.

The program do not even try to receive. No call to any IRQ or polling reception function. If I disconnect the Master's RX wire, it can transmit again (but useless without the slaves answer) .

Settings are identical for both huarts and done with QubeIDE.

Here is the simple program I use

void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart){
	__NOP();
}
 
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart){
	__NOP();
}
 
 
 
void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart){
	__NOP();
}
 
UART_HandleTypeDef *uartUsed;
 
int main(void)
{
  HAL_Init();
 
  SystemClock_Config();
 
  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_I2C1_Init();
  MX_USART1_UART_Init();
  MX_RTC_Init();
  MX_USART2_UART_Init();
  MX_USART6_UART_Init();
  MX_TIM1_Init();
 
  uartUsed=&huart2;
 
  while (1)
  {
		  HAL_Delay(1000);
		 HAL_UART_Transmit_IT(uartUsed,txBuffCmd,6); 
 }
 
static void MX_USART1_UART_Init(void)
{
 
  /* USER CODE BEGIN USART1_Init 0 */
 
  /* USER CODE END USART1_Init 0 */
 
  /* USER CODE BEGIN USART1_Init 1 */
 
  /* USER CODE END USART1_Init 1 */
  huart1.Instance = USART1;
  huart1.Init.BaudRate = 9600;
  huart1.Init.WordLength = UART_WORDLENGTH_8B;
  huart1.Init.StopBits = UART_STOPBITS_1;
  huart1.Init.Parity = UART_PARITY_NONE;
  huart1.Init.Mode = UART_MODE_TX_RX;
  huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
  huart1.Init.OverSampling = UART_OVERSAMPLING_16;
  if (HAL_UART_Init(&huart1) != HAL_OK)
  {
    Error_Handler();
  }
  /* USER CODE BEGIN USART1_Init 2 */
 
  /* USER CODE END USART1_Init 2 */
 
}
 
/**
  * @brief USART2 Initialization Function
  * @param None
  * @retval None
  */
static void MX_USART2_UART_Init(void)
{
 
  /* USER CODE BEGIN USART2_Init 0 */
 
  /* USER CODE END USART2_Init 0 */
 
  /* USER CODE BEGIN USART2_Init 1 */
 
  /* USER CODE END USART2_Init 1 */
  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;
  if (HAL_UART_Init(&huart2) != HAL_OK)
  {
    Error_Handler();
  }
  /* USER CODE BEGIN USART2_Init 2 */
 
  /* USER CODE END USART2_Init 2 */
 
}

11 REPLIES 11

One of the common problems in debugging is not listening to others' questions:

>> Isn't PA2/PA3 connected to something else on the board

I understand why that is: you've already discarded that question beforehand by judging that it's irrelevant (and my question was also blurred by the fact that I was talking about Nucleo there).

This is why talking to the teddybear (explaining the problem to ruber duck, your wife/girlfriend, the cleaning lady, etc.) *is* a valid debugging method: by explaining the problem to an outsider, you question yourself (or if you talk to a person, potentially he/she questions maybe in an unqualified way) the thought paths you've already taken, and potentially "unlock" other paths.

> in theory should not be an issue because all I/Os are inputs on powerup

That's the generalized vision, but obviously, they don't all remain so. See AN2606.

JW

ICohe.1
Associate III

Agree !

I did used my wife as  rubber duck as you suggested. When this didn't helped I used the form and this helped:-) Not all rubber duck are equal.

Thanks for taking the time to help me.