How to modify stm32-w25qxx example code to use SPI with DMA ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-06-01 5:46 AM
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...
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)
- Labels:
-
STM32L4 series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-06-02 1:42 AM
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
Saket_Om
