Skip to content

Commit 69e63cc

Browse files
authored
Enhance flash SSI DMA example with interrupt control for stable operations (#490)
added interrupt control for stable flash operations
1 parent e38b215 commit 69e63cc

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

flash/ssi_dma/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ add_executable(flash_ssi_dma
55
target_link_libraries(flash_ssi_dma
66
pico_stdlib
77
hardware_dma
8+
hardware_sync
89
)
910

1011
# create map/bin/hex file etc.
1112
pico_add_extra_outputs(flash_ssi_dma)
1213

1314
# add url via pico_set_program_url
14-
example_auto_set_url(flash_ssi_dma)
15+
example_auto_set_url(flash_ssi_dma)

flash/ssi_dma/flash_ssi_dma.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "pico/time.h"
1212
#include "hardware/dma.h"
1313
#include "hardware/structs/ssi.h"
14+
#include "hardware/sync.h"
1415

1516
// This example DMAs 16kB of data from the start of flash to SRAM, and
1617
// measures the transfer speed.
@@ -66,11 +67,16 @@ uint32_t *expect = (uint32_t *) XIP_NOCACHE_NOALLOC_BASE;
6667

6768
int main() {
6869
stdio_init_all();
70+
6971
memset(rxdata, 0, DATA_SIZE_WORDS * sizeof(uint32_t));
7072

7173
printf("Starting DMA\n");
7274
uint32_t start_time = time_us_32();
75+
76+
uint32_t ints = save_and_disable_interrupts();
7377
flash_bulk_read(rxdata, 0, DATA_SIZE_WORDS, 0);
78+
restore_interrupts(ints);
79+
7480
uint32_t finish_time = time_us_32();
7581
printf("DMA finished\n");
7682

0 commit comments

Comments
 (0)