Skip to main content
darla14
Associate III
February 2, 2016
Question

DMA giving hardfault in STM32F4 Nucleo @84Mhz

  • February 2, 2016
  • 11 replies
  • 3042 views
Posted on February 02, 2016 at 14:20

I have modified an STM32F4 example and developed a windows application to interact with it for sending data continuously.I am reading a file on PC line by line and sending continuously each line on a serial port (COM9) to which STM32F4Nucleo board is connected.

STM324 is running @84Mhz and UART is configured at 921600 Baudrate.

Host code : 

loop : 

while(1)

//being while loop

//read a line from a text file

 if(line == ''EOF'')

   break

else

{ send a line to COM Port 

   delay 500 ms

}

 //End while loop

 

on STM32 : 

int main(void)

{

  

 HAL_Init();

  

  /* Configure the System clock to 84 MHz */

  SystemClock_Config();

  

/* Initialize UART */

USARTConfig();

        

  /* Infinite loop */

  while (1)

  {

    

if (UART_ReceivedMSG((TMsg*) &Msg)) {

 //do the processing of the MSg data

                   printf(Msg.Data);

}

attached is the file where UART_ReceivedMSG is defined.

So here I am able to see the data coming (on console I/O of the IDE I am using - IAR)

but at times I am getting a hardfault at 

Get_DMA_Flag_Status > 

uint32_t Get_DMA_Flag_Status(DMA_HandleTypeDef *handle_dma)

{

  return (__HAL_DMA_GET_FLAG(handle_dma, __HAL_DMA_GET_FE_FLAG_INDEX(handle_dma)));

}

What could be the cause for this?

Is it some sort of non atomic operation happening at the handle_dma.How can I avoid it.

Thanks in advance !

#hardfault #hardfault #hardfault #uart #dma #dma #dma #stm32f4 #!stm32f4-!stm32f401
This topic has been closed for replies.

11 replies

Tesla DeLorean
Guru
March 9, 2016
Posted on March 09, 2016 at 13:53

Well it is pretty clear that R0 is gettin corrupted, itcontains some ASCII values like 0x312D.... which is not a valid or readable address, and bang it Hard Faults.

You NEED to sanity  check the address of the handle and its internal references BEFORE you hand it down to the HAL code so you can identify WHEN this is first occuring. Check it frequently at key points in your code.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..