From 35a427e8a04043c22dc70c00157d3212fdb9c9c4 Mon Sep 17 00:00:00 2001 From: sys64738 Date: Mon, 19 Jul 2021 03:34:48 +0200 Subject: [PATCH] overclocking so SUMP mode can sample up to 50 MHz --- README.md | 1 + bsp/rp2040/m_sump/sump_hw.c | 9 +++++++++ bsp/rp2040/m_sump/sump_hw.h | 10 +++++----- src/m_sump/cdc_sump.c | 7 ++++--- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index c40002f..2b9a773 100644 --- a/README.md +++ b/README.md @@ -277,6 +277,7 @@ libco is licensed under the [ISC license](https://opensource.org/licenses/ISC) - OpenOCD as XVC client?? - [x] SUMP logic analyzer mode? - see also [this](https://github.com/perexg/picoprobe-sump) + - [ ] runtime config options for overclocking, logging - [ ] FT2232 emulation mode? - watch out, still need a vnd cfg interface! libftdi expects the following stuff: (TODO: acquire detailed protocol description) - interface 0 ("A"): index 1, epin 0x02, epout 0x81 diff --git a/bsp/rp2040/m_sump/sump_hw.c b/bsp/rp2040/m_sump/sump_hw.c index 7ce0d05..a9bcc1a 100644 --- a/bsp/rp2040/m_sump/sump_hw.c +++ b/bsp/rp2040/m_sump/sump_hw.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -336,6 +337,10 @@ void sump_hw_init(void) { } void sump_hw_stop(void) { + // TODO: make this configurable + vreg_set_voltage(VREG_VOLTAGE_1_15); + set_sys_clock_khz(200000, true); + // IRQ and PIO fast stop irq_set_enabled(SAMPLING_DMA_IRQ, false); pio_sm_set_enabled(SAMPLING_PIO, SAMPLING_PIO_SM, false); @@ -355,6 +360,10 @@ void sump_hw_stop(void) { } void sump_hw_deinit(void) { + // TODO: make this configurable + set_sys_clock_khz(133333, false); + vreg_set_voltage(VREG_VOLTAGE_DEFAULT); + sump_hw_stop(); sump_dma_set_irq_channel_mask_enabled(SUMP_DMA_MASK, false); diff --git a/bsp/rp2040/m_sump/sump_hw.h b/bsp/rp2040/m_sump/sump_hw.h index d683dd8..ac0510e 100644 --- a/bsp/rp2040/m_sump/sump_hw.h +++ b/bsp/rp2040/m_sump/sump_hw.h @@ -9,11 +9,11 @@ #define SAMPLING_BITS (SAMPLING_GPIO_LAST-SAMPLING_GPIO_FIRST+1) #define SAMPLING_BYTES ((SAMPLING_BITS+7)/8) -#if PICO_NO_FLASH -#define SUMP_MEMORY_SIZE 151552/*102400*/ // 150kB -#else -#define SUMP_MEMORY_SIZE 204800 // 200kB -#endif +//#if PICO_NO_FLASH +//#define SUMP_MEMORY_SIZE 151552/*102400*/ // 150kB +//#else +//#define SUMP_MEMORY_SIZE 204800 // 200kB +//#endif #define SUMP_MAX_CHUNK_SIZE 4096 #endif diff --git a/src/m_sump/cdc_sump.c b/src/m_sump/cdc_sump.c index 5d03de2..334a2b4 100644 --- a/src/m_sump/cdc_sump.c +++ b/src/m_sump/cdc_sump.c @@ -44,13 +44,14 @@ #error "Correct sampling width (8 or 16 bits)" #endif -#if (SUMP_MEMORY_SIZE % SUMP_MAX_CHUNK_SIZE) != 0 +// TODO: runtime errors? +/*#if (SUMP_MEMORY_SIZE % SUMP_MAX_CHUNK_SIZE) != 0 #error "Invalid maximal chunk size!" #endif -// TODO + #if (SUMP_MEMORY_SIZE / SUMP_MAX_CHUNK_SIZE) < SUMP_DMA_CHANNELS #error "DMA buffer and DMA channels out of sync!" -#endif +#endif*/ #define SUMP_STATE_CONFIG 0 #define SUMP_STATE_INIT 1