I think I've just hit this same problem. I've a small program that uses DMA to feed ADC output into a double buffer. It seemed to be fine until I wanted to blink the LED on the Pico W, then I see the same errors mentioned here:
It happens every time. Here's the code:
No idea what's going on.
Code:
StartingDMA finished[CYW43] HT not ready[CYW43] core not in reset[CYW43] core not in reset[CYW43] core not in reset[CYW43] HT not readyDMA finished[CYW43] core not in reset[CYW43] core not in reset[CYW43] core not in reset[CYW43] HT not ready[CYW43] core not in reset[CYW43] core not in reset[CYW43] core not in reset[CYW43] HT not readyDMA finished[CYW43] Failed to start CYW43[CYW43] Failed to start CYW43
Code:
#include <stdint.h>#include <stdio.h>#include <string.h>#include <pico/stdlib.h>#include <hardware/adc.h>#include <hardware/dma.h>#include <pico/cyw43_arch.h>/* Sample double buffer. 10000 samples x2 channels each */#define DBUFFER_LEN (10000 * 2)static uint16_t _dbuffer[2][DBUFFER_LEN];static int _dbuffer_block = 0;static int _dma_channel;static void _dma_interrupt(void){/* Clear the interrupt request */dma_hw->ints0 = 1 << _dma_channel;/* Set the new DMA write address and trigger */dma_channel_set_write_addr(_dma_channel, &_dbuffer[_dbuffer_block & 1][0], true);_dbuffer_block++;}int main(void){dma_channel_config dma_cfg;stdio_init_all();cyw43_arch_init();/* Give myself time to connect serial console */sleep_ms(5000);/* Configure the ADC */adc_init();adc_gpio_init(26);adc_select_input(0); /* Use ADC0 */adc_set_clkdiv(4800); /* Sample at 10kHz */adc_fifo_setup(true,/* Enable the ADC's FIFO */true,/* Enable DMA requests */1,/* Assert DREQ (and IRQ) at least 1 sample present */true,/* Pass in error flag in bit 15 */false /* Don't shift each sample to 8 bits */);/* Setup DMA */_dma_channel = dma_claim_unused_channel(true);dma_cfg = dma_channel_get_default_config(_dma_channel);channel_config_set_transfer_data_size(&dma_cfg, DMA_SIZE_16);channel_config_set_read_increment(&dma_cfg, false);channel_config_set_write_increment(&dma_cfg, true);channel_config_set_dreq(&dma_cfg, DREQ_ADC);dma_channel_configure(_dma_channel,&dma_cfg,NULL,/* Write address (set by interrupt handler) */&adc_hw->fifo, /* Read from the ADC fifo */DBUFFER_LEN,/* Number of transfers (samples) per block */false /* Don't start yet */);/* Enable DMA IRQ */dma_channel_set_irq0_enabled(_dma_channel, true);irq_set_exclusive_handler(DMA_IRQ_0, _dma_interrupt);irq_set_enabled(DMA_IRQ_0, true);/* Manually trigger interrupt to begin first transfer */_dma_interrupt();/* Start ADC running */adc_run(true);printf("Starting\n");while(true){/* Wait for a DMA transfer to complete */dma_channel_wait_for_finish_blocking(_dma_channel);printf("DMA finished\n");/* Blink status LED */cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, 1);sleep_ms(10);cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, 0);}/* We never get here... */cyw43_arch_deinit();return(0);}
Statistics: Posted by fsphil — Wed Jan 29, 2025 10:38 pm