cancel
Showing results for 
Search instead for 
Did you mean: 

Hardware fault on FATFS and I2S

SSeo.17
Associate III

Try to play the wave file stored in uSD using STM32F103VCT and CODEC IC (TAS2505). 

Use 4bit SDIO (DMA) and I2S2 (DMA) with STM32 and CODEC. 

However, after playing Wave file, a hardware fault occurs and HardFault_Handler is called. 

If Wave file is played up to the middle, hardware fault will not occur, so problems related to SDIO or FATFS are suspected, but cannot be resolved. 

- The data read from File at once is 2048 bytes.

- stack size = 0x1000

- Heap size = 0x4000

- CubeMx Version = 5.2.0

- Cube MCU package for STM32F1 : 1.7.0

- There is no OS.

I'd be very grateful if anyone could help me.

3 REPLIES 3

Use a proper Hard Fault Handler which will display processor registers and context.

Review specific code at faulting location to understand the nature of the failure.

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

Thank you for your advice.

However, it is judged that hard-fault was caused by an error in writing data outside the variable area in the program code I wrote.

I tried to find out where hard-fault occurred based on the CPU register, but failed, and after careful examination of the code, I found the error above.

I'd appreciate it if you could explain how to find out where Hard-fault occurred.

The screen shots don't really show you've found anything.

Look at the processor registers, and data the fault pushes on to the stack frame to see where it came from.

Perhaps review Joseph Yiu's book where it covers the fault handling, and look at some of the MANY examples of a workable Hard Fault Handler that have been posted to the forum.

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