Skip to main content
SSeo.17
Associate III
Jun 1, 2019 11:50 AM UTC
Question

Hardware fault on FATFS and I2S

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.

This topic has been closed for replies.

3 replies

Tesla DeLorean
Guru
Jun 1, 2019 12:17 PM UTC

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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
SSeo.17
SSeo.17Author
Associate III
Jun 5, 2019 2:33 PM UTC

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.

Tesla DeLorean
Guru
Jun 6, 2019 12:54 AM UTC

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 (See Profile) Up vote any posts that you find helpful, it shows what's working..