Skip to content

Commit

Permalink
Enhance flash SSI DMA example with interrupt control for stable opera…
Browse files Browse the repository at this point in the history
…tions (#490)

added interrupt control for stable flash operations
  • Loading branch information
francdoc authored Jul 11, 2024
1 parent e38b215 commit 69e63cc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion flash/ssi_dma/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ add_executable(flash_ssi_dma
target_link_libraries(flash_ssi_dma
pico_stdlib
hardware_dma
hardware_sync
)

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

# add url via pico_set_program_url
example_auto_set_url(flash_ssi_dma)
example_auto_set_url(flash_ssi_dma)
6 changes: 6 additions & 0 deletions flash/ssi_dma/flash_ssi_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "pico/time.h"
#include "hardware/dma.h"
#include "hardware/structs/ssi.h"
#include "hardware/sync.h"

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

int main() {
stdio_init_all();

memset(rxdata, 0, DATA_SIZE_WORDS * sizeof(uint32_t));

printf("Starting DMA\n");
uint32_t start_time = time_us_32();

uint32_t ints = save_and_disable_interrupts();
flash_bulk_read(rxdata, 0, DATA_SIZE_WORDS, 0);
restore_interrupts(ints);

uint32_t finish_time = time_us_32();
printf("DMA finished\n");

Expand Down

0 comments on commit 69e63cc

Please sign in to comment.