cancel
Showing results for 
Search instead for 
Did you mean: 

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

KWiśn.2
Associate II

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

18 REPLIES 18

> I mean Plug the power cord to the mains.

> I have RS232 on mainboard in computer and i use db9 cable.

> problem is only after Plug the power cord to the mains.

Don't transmit anything in the STM32 software, just unplug and plug. Still receiving strange characters? Then you a hardware-related problem: observe the line using oscilloscope during unplugging/plugging in. What exactly happens during power-up depends on how exactly the power source and the interface circuitry is designed.

JW

Okay, we're getting closer...

Still missing:

  • DMA init
  • the "linking" function between hardware UART and printf
KWiśn.2
Associate II

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
Associate II
//--------------------------------------------------------------------------------------
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
Associate II

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

{

int DataIdx;

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

{

__io_putchar(*ptr++);

}

return len;

}

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
Associate II

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

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

KWiśn.2
Associate II

You're right, i forget