cancel
Showing results for 
Search instead for 
Did you mean: 

hi everyone, why UART using DMA stops receiving data suddenly in IDLE MODE

SSRIN.2
Associate III
 
1 ACCEPTED SOLUTION

Accepted Solutions
nilesh-dryad
Associate III

What exactly display_function do? I faced the same problem when I was doing some operation before enabling the IDLE interrupt again. I resolved by just coping the received data to Main buffer and then enable the interrupt and then call your display function. In your case,

void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size)
{
if(huart->Instance == USART1)
 
{ // Check if it is an "Idle Interrupt"
__HAL_UART_CLEAR_IDLEFLAG(&huart1);
memcpy(MainBuf,RxBuf,Size);
}
 
__HAL_UART_ENABLE_IT(&huart1, UART_IT_IDLE);
HAL_UARTEx_ReceiveToIdle_DMA(&huart1,RxBuf,RxBuf_SIZE);
__HAL_DMA_DISABLE_IT(&hdma_usart1_rx,DMA_IT_HT);
 
display_function(MainBuf); // Pass the Size too here. if it is zero then just return.
}

View solution in original post

11 REPLIES 11

You need to give full details of what, exactly, you're doing and how & when you are observing this.

What debugging/investigation have you done to find the cause?

which particular STM32 are you using? Is it on a devboard, or something custom?

SSRIN.2
Associate III

I am using custom board with controller with part number given below

0693W00000QMLGhQAP.png

SSRIN.2
Associate III

as i am using stm32f030cct6 in my custom board, in this two controllers are used with same part number.

controller1 send the data in chunks with different sizes through UART, controller2 receive data through UART from controller1. because of different chunk sizes i used UART in DMA mode with IDLE line detection for proper data reception.

the code is given below for data reception is working

void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size)

{

if(huart->Instance == USART1)

{ // Check if it is an "Idle Interrupt"

__HAL_UART_CLEAR_IDLEFLAG(&huart1);

memcpy(MainBuf,RxBuf,Size);

display_function(MainBuf);

}

__HAL_UART_ENABLE_IT(&huart1, UART_IT_IDLE);

HAL_UARTEx_ReceiveToIdle_DMA(&huart1,RxBuf,RxBuf_SIZE);

__HAL_DMA_DISABLE_IT(&hdma_usart1_rx,DMA_IT_HT);

}

above code i used for data reception from controller1 to controller2.

controller1 continuously transmit data to controller2.

some time even controller1 transmit data controller2 not responding

while debugging i checked there is no updata in RxBuf

if i reset the controller2 again it continue receiveing

baudrate used is 19200 for UART communication

i didnt understand the problem

please help me to tackle this issue

You've forgotten already how to post source code?

0693W000008xsqBQAQ.png 

@SSRIN.2​ "if i reset the controller2 again it continue receiveing"

So something is getting disabled?

Check register settings when the problem occurs ...

nilesh-dryad
Associate III

What exactly display_function do? I faced the same problem when I was doing some operation before enabling the IDLE interrupt again. I resolved by just coping the received data to Main buffer and then enable the interrupt and then call your display function. In your case,

void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size)
{
if(huart->Instance == USART1)
 
{ // Check if it is an "Idle Interrupt"
__HAL_UART_CLEAR_IDLEFLAG(&huart1);
memcpy(MainBuf,RxBuf,Size);
}
 
__HAL_UART_ENABLE_IT(&huart1, UART_IT_IDLE);
HAL_UARTEx_ReceiveToIdle_DMA(&huart1,RxBuf,RxBuf_SIZE);
__HAL_DMA_DISABLE_IT(&hdma_usart1_rx,DMA_IT_HT);
 
display_function(MainBuf); // Pass the Size too here. if it is zero then just return.
}

can the DMA be set to toggle between two buffers - then you wouldn't even need the copy...?

SSRIN.2
Associate III

can any one help me

how to do button long press interrupt in stm32.

Yes it can be done. I tried to do that but somehow it didn't work. May be I am doing something wrong. If you made it work, can you please share the configuration or code snippet? It would save a unnecessary copy.

hi sir,

could you please help me to do button long press and short press interrupt in stm32