2021-09-15 12:45 PM
In the program that transmits the value received from uart4 to uart5, I want to move the value received from uart5 to another buffer, but I move it to HardFault_Handler.
what is the reason?
And please check if the method of receiving data using the dma I implemented is the correct program.
if((RX_BUFFER4_SIZE) != __HAL_DMA_GET_COUNTER(huart4.hdmarx) ){
SCB_InvalidateDCache_by_Addr((uint32_t*)RX_BUFFER4, RX_BUFFER4_SIZE);
HAL_UART_Transmit(&huart5,RX_BUFFER4,RX_BUFFER4_SIZE-__HAL_DMA_GET_COUNTER(huart4.hdmarx),0xFFFFFFFF);
__HAL_DMA_DISABLE(huart4.hdmarx);
__HAL_DMA_SET_COUNTER(huart4.hdmarx,RX_BUFFER4_SIZE);
__HAL_DMA_ENABLE(huart4.hdmarx);
memset(RX_BUFFER4,0x00,sizeof(RX_BUFFER4));
}
if((RX_BUFFER5_SIZE) != __HAL_DMA_GET_COUNTER(huart5.hdmarx) ){
SCB_InvalidateDCache_by_Addr((uint32_t*)RX_BUFFER5, RX_BUFFER5_SIZE);
HAL_UART_Transmit(&huart4,RX_BUFFER5,RX_BUFFER5_SIZE-__HAL_DMA_GET_COUNTER(huart5.hdmarx),0xFF);
memcpy(RX_BUFFER_WAV,RX_BUFFER5,4096-bytesRx);
__HAL_DMA_DISABLE(huart5.hdmarx);
__HAL_DMA_SET_COUNTER(huart5.hdmarx,RX_BUFFER5_SIZE);
__HAL_DMA_ENABLE(huart5.hdmarx);
memset(RX_BUFFER5,0x00,sizeof(RX_BUFFER5));
}
2021-09-15 01:04 PM
I don't understand the rational for the logic.
The buffers need to be properly aligned so the invalidation works properly.
The HAL_UART_Transmit()s will block.
You should be able to unpack the Hard Fault to understand, or surmise, the reason for it. You should be able to identify what the MCU doesn't like.
2021-09-15 01:51 PM
What do you mean by sorting buffers?
please tell me specifically
2021-09-15 02:15 PM
Doesn't seem like you're using the right calls. If you want to use DMA, then HAL_UART_Transmit_DMA/HAL_UART_Receive_DMA should be used.
Also possibly this:
https://community.st.com/s/article/FAQ-DMA-is-not-working-on-STM32H7-devices
2021-09-15 10:56 PM
yes thank you so much for your help
I changed the setting value by referring to the data you sent
However, when data is sent to uart5, it says that it receives a value in the receive buffer and then does not receive it.
Changed HAL_UART_Transmit -> HAL_UART_Transmit_DMA.
2021-09-16 01:40 AM