Skip to main content
KWiśn.2
Associate
May 25, 2023
Question

After restart device UART_3 printing some rubbish ţ˙ţţţţţţţţüţüüüüüüüüüüüüüüüüüü

  • May 25, 2023
  • 18 replies
  • 3734 views

Dear,

Microcontroler STM32H742 (stm32CubeIDE)

When i plug out and plug in device, this printing on UART_3:

ţ˙ţţţţţţţţüţüüüüüüüüüüüüüüüüüü

or:

ţ

NVT: FF FE FE

ţţ{FF}

i this problem was not watched on same device with stm32F205(Rowley crossworks).

I clear all buffer 

char bufRcv[256] {'\0'}; but it nothing change

Could you have some solution

Many thanks

This topic has been closed for replies.

18 replies

KWiśn.2
KWiśn.2Author
Associate
June 6, 2023

Sorry for the delay, I was sick.

//--------------------------------------------------------------------------------------

void UART_3::Init()

{

 __HAL_RCC_DMA1_CLK_ENABLE();

 HAL_NVIC_SetPriority(DMA1_Stream3_IRQn, 3, 0);

 HAL_NVIC_EnableIRQ(DMA1_Stream3_IRQn);

 /* Peripheral interrupt init */

 HAL_NVIC_SetPriority(USART3_IRQn, 2, 0);

 HAL_NVIC_EnableIRQ(USART3_IRQn);

 __HAL_UART_ENABLE_IT(&huart3,UART_IT_RXNE);

}

//--------------------------------------------------------------------------------------

void UART_3::ParametersChanged()

{

 ConfigureUsart();

}

//--------------------------------------------------------------------------------------

void UART_3::ConfigureUsart()

{

 uint16_t parity = DecodeParity(Params.Com1_Parity);

 huart3.Instance = USART3;

 huart3.Init.BaudRate = DecodeBaudrate(Params.Com1_Baudrate);

 huart3.Init.WordLength = (parity == PARITY_NONE) ? UART_WORDLENGTH_8B : UART_WORDLENGTH_9B;

 huart3.Init.StopBits = UART_STOPBITS_1;

 huart3.Init.Parity = parity;

 huart3.Init.Mode = UART_MODE_TX_RX;

 huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE;

 huart3.Init.OverSampling = UART_OVERSAMPLING_16;

 huart3.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;

 huart3.Init.ClockPrescaler = UART_PRESCALER_DIV1;

 huart3.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;

 if (HAL_UART_Init(&huart3) != HAL_OK) Error_Handler();

 if (HAL_UARTEx_SetTxFifoThreshold(&huart3, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK) Error_Handler();

 if (HAL_UARTEx_SetRxFifoThreshold(&huart3, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK) Error_Handler();

 if (HAL_UARTEx_DisableFifoMode(&huart3) != HAL_OK) Error_Handler();

}

//--------------------------------------------------------------------------------------

KWiśn.2
KWiśn.2Author
Associate
June 6, 2023
//--------------------------------------------------------------------------------------
extern "C" void USART3_IRQHandler(void)
{
	if (__HAL_UART_GET_FLAG(&huart3, UART_FLAG_ORE))
	{
		__HAL_UART_CLEAR_FLAG(&huart3, UART_CLEAR_OREF);
	}
 if(__HAL_UART_GET_IT_SOURCE(&huart3,UART_IT_RXNE) != RESET && __HAL_UART_GET_FLAG(&huart3, UART_FLAG_RXNE) != RESET )
 {
		 char data = huart3.Instance->RDR & (uint8_t)0x00FF;
		 Com1.ByteReceivedIsr(data);
}
	HAL_DMA_IRQHandler(&hdma_usart3_tx);
}
 

KWiśn.2
KWiśn.2Author
Associate
June 6, 2023

__attribute__((weak)) int _write(int file, char *ptr, int len)

{

int DataIdx;

for (DataIdx = 0; DataIdx < len; DataIdx++)

{

__io_putchar(*ptr++);

}

return len;

}

LCE
Principal II
June 6, 2023

There is still no link to the UART whatsoever.

So the _write function needs some output to the UART, like you give the pointer and length to the UART DMA transmit function.

KWiśn.2
KWiśn.2Author
Associate
June 6, 2023

Uart still work, this problem is only when plug the power cord to the mains, after start all transmition work correctly.

ONadr.1
Senior III
June 6, 2023

Try to disable bootloader. This is the first FW which can use UART.

KWiśn.2
KWiśn.2Author
Associate
June 6, 2023

You're right, i forget