AnsweredAssumed Answered

Hard Fault, after HAL_UART_Receive_DMA() is called.

Question asked by tomiyama.tadao on Sep 28, 2017
Latest reply on Oct 10, 2017 by tomiyama.tadao

Hello!

 

I am trying to use USART2 + DMA for Rx/Tx. Tx is working OK already.
For Rx, I would like to use DMA circular mode.

 

I use followings.
  STM32L476 nucleo

  STM32CubeMX, STM32CubeL4 1.9.0.

 

After do workaround PLLM problem adding RCC_OscInitStruct.PLL.PLLM = 1;

I called,

HAL_StatusTypeDef HAL_UART_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);

     huart == &huart2

     pData == &receive_str[0] == 0x2000194c

     Size == sizeof(receive_str) == 64

until 63rd character receive there is no problem. I typed 'a' 63 times.

The black backed area is buffer for  Receive_DMA.
black-back is buffer for Rx DMA

No Hard Fault occured yet.

 

However, when I type 64th character 'b' Hard Fault raised as following.

'b' exists at  receive_str[63]  by DMA.

64th character is successfully captured by DMA

CFSR.PRECISEERR is ON.

PRECISEERR is 1 , BFAR = 0x20018000.

It looks unwanted memory access to 0x200018000, did not such access.

 

 

 

DMAC is still transfers Rx data correctly.

I typed 'c' 3times, then the buffer is overwriten circulariy as expected.

DMA looks working.

At the time, I lookd stack.

return address is not my code.

 

Does anyone know my mistake, or how to workaround?

 

Thanks!

Attachments

Outcomes