cancel
Showing results for 
Search instead for 
Did you mean: 

How to modify stm32-w25qxx example code to use SPI with DMA ?

freeflyer
Associate II

I am using this example to read data from an external flash (W25Q128) using SPI on a NUCLEO-L433RC-P board...

https://stm32world.com/wiki/STM32_W25Qxx

The code is here...

https://github.com/lbthomsen/stm32-w25qxx

How do I modify this example to use SPI with DMA ?

The end result is to read a WAV file from the external flash and play it using the internal DAC.

I have enabled DMA for SPI...

freeflyer_0-1748781574422.png

 

But don't know what other modifications I need to make.

In w25qxx.c, I tried changing...

if (HAL_SPI_Receive(w25qxx->spiHandle, buf, len, HAL_MAX_DELAY) == HAL_OK) {

to...

if (HAL_SPI_Receive_DMA(w25qxx->spiHandle, buf, len) == HAL_OK) {

but when I step through the code it jumps to the HardFault_Handler.

I will need to use double DMA buffers, so that the DAC reads from one buffer whilst the external flash writes to the other buffer (for glitchless playback)

 

1 REPLY 1
Saket_Om
ST Employee

Hello @freeflyer 

Could you share your SPI and DMA setting please?


@freeflyer wrote:

but when I step through the code it jumps to the HardFault_Handler.


On which instruction it goes to hardfault?

Please refer to the article below to debug hardfault:

How to debug a HardFault on an Arm® Cortex®-M STM3... - STMicroelectronics Community

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Saket_Om