cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 + uart idle interrupt delayed

jo_me
Associate II

Hi,

i am currently experiancing a strange problem on the STM32F4 using a uart connection (6,25mbaud) with DMA to another controller:

scope_1.png

 Green is the RX line of usart1, yellow is set to 0 on sending my request and put to 1 again on the occurence of the idle interrupt. Sending my request and receiving the complete answer only takes about 40us. Afterwards the input and output lines of the usart1 are idle for about 4.5-7ms before the idle interrupt is fired.

Any suggestions what might be the cause of this and how to fix this long delay?

Best Regards,

Jo

4 REPLIES 4
Karl Yamashita
Lead II

Show some code so we know what you're doing

If you find my answers useful, click the accept button so that way others can see the solution.

Good Morning,

the project is based on a (fairly old) cube-mx template.

in main.c, i do

 

	HAL_Init();

	SystemClock_Config();
	
	MX_GPIO_Init();
	MX_DMA_Init();
	MX_CRC_Init();
	MX_RNG_Init();
	MX_FMC_Init();
	MX_SPI3_Init();
	MX_USART1_UART_Init();
[...]
	HAL_UART_DeInit(&huart1);
[...]
	di.huartX                  = &huart1;
	di.huartX->Init.WordLength = UART_WORDLENGTH_8B;
	di.huartX->Init.Parity     = UART_PARITY_NONE;
	di.huartX->Init.StopBits   = UART_STOPBITS_1;
	di.huartX->Instance        = USART1;
	HAL_USART_Init((USART_HandleTypeDef*)deviceInfo.huartX);
[...]
	di.huartX->Init.BaudRate = deviceInfo.baudrate;
	HAL_UART_Init(deviceInfo.huartX);

 

usart.c is expanded by the interrupt commands:

 

void MX_USART1_UART_Init(void)
{
	huart1.Instance          = USART1;
	huart1.Init.BaudRate     = ESO_DEFAULT_BAUDRATE;
	huart1.Init.WordLength   = UART_WORDLENGTH_9B;
	huart1.Init.StopBits     = UART_STOPBITS_1;
	huart1.Init.Parity       = UART_PARITY_EVEN;
	huart1.Init.Mode         = UART_MODE_TX_RX;
	huart1.Init.HwFlowCtl    = UART_HWCONTROL_NONE;
	huart1.Init.OverSampling = UART_OVERSAMPLING_8;
	#ifdef BOOTLOAD
		HAL_NVIC_SetPriority(USART1_IRQn, 0, 0);
		HAL_NVIC_EnableIRQ(USART1_IRQn);
	#endif

	if (HAL_UART_Init(&huart1) != HAL_OK)
	{
		_Error_Handler(__FILE__, __LINE__);
	}
}

 

The Send-Receive is then performed as:

 

HAL_UART_Transmit(di.huartX, buffer->packet.array, buffer->length, 500);
di.huartX->Instance->DR; // necessary to clear last byte so it doesn't show up at the beginning of new buffer...
HAL_UART_Receive_DMA(di.huartX, buffer->next->packet.array, 259);

 

 

Update:

The issue seems not to be with our firmware. The same binary runs on other hardware (same stm32f4 but other revision i think) without problems:

Board1 Type A: interrupt delayed or not even triggered

Board2 Type A: interrupt delayed or not even triggered

Board 3 Type B: working

Board4 Type C: working

again Board1: working???

That sounds to me much like software problem, namely, consequence of not completely initialized init struct.

But without actual code (a minimal but complete compilable example exhibiting the problem) it's just guessing, of course. Debug as usually - observe registers content, toggle pins at key points of software (e.g. where you enable/disable the idle interrupt, whether directly or indicrectly through calling Cube/HAL functions).

JW