Skip to content

Commit

Permalink
dual_external_adc: correct PIO program name
Browse files Browse the repository at this point in the history
  • Loading branch information
steve-m committed Feb 8, 2025
1 parent 5c9313a commit 6108b00
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ For the vhsdecode use-case, there is also an [adapter PCB](https://github.com/Se
### dual_external_adc

Similar to the external_adc app, but samples two 12 bit ADCs connected to a RP2350B, as well as two PCM1802 modules. Intended for use with vhs-decode, see [this PCB](https://github.com/Sev5000/RP2350B_DualADC_DualPCM) for the matching hardware.
This example needs to be built with an RP2350B-board in order to work correctly:

cmake -DPICO_PLATFORM=rp2350 -DPICO_BOARD=solderparty_rp2350_stamp_xl ../

## Credits

Expand Down
6 changes: 3 additions & 3 deletions apps/dual_external_adc/adc_24bit_input.pio
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
; Third word: D23 D22 D21 D20 D19 D18 D17 D16 D15 D14 D13 D12 D11 D10 D09 D08 D07 D06 D05 D04 D03 D02 D01 D00 C23 C22 C21 C20 C19 C18 C17 C16

.pio_version 1
.program adc_12bit_input
.program adc_24bit_input
.side_set 3

public entry_point:
Expand Down Expand Up @@ -60,9 +60,9 @@ public entry_point:
.wrap

% c-sdk {
static inline void adc_12bit_input_program_init(PIO pio, uint sm, uint offset, uint pin, uint clk_pin)
static inline void adc_24bit_input_program_init(PIO pio, uint sm, uint offset, uint pin, uint clk_pin)
{
pio_sm_config c = adc_12bit_input_program_get_default_config(offset);
pio_sm_config c = adc_24bit_input_program_get_default_config(offset);

// Set the IN base pin to the provided `pin` parameter.
sm_config_set_in_pins(&c, pin);
Expand Down
12 changes: 7 additions & 5 deletions apps/dual_external_adc/dual_external_adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* hsdaoh - High Speed Data Acquisition over MS213x USB3 HDMI capture sticks
* Implementation for the Raspberry Pi RP2350 HSTX peripheral
*
* External 12-bit ADC example, connected to the PIO
* Dual External 12-bit ADC example, connected to the PIO
*
* Copyright (c) 2024-2025 by Steve Markgraf <[email protected]>
*
Expand Down Expand Up @@ -45,6 +45,10 @@
#include "adc_24bit_input.pio.h"
#include "pcm1802_fmt00.pio.h"

#if (PICO_PIO_USE_GPIO_BASE != 1)
#warning "PICO_PIO_USE_GPIO_BASE is not set to 1, this application will not work correctly!"
#endif

/* The PIO is running with sys_clk/2, and needs 4 cycles per sample,
* so the ADC clock is sys_clk/8 */
#define SYS_CLK 320000 // 40 MHz ADC clock
Expand Down Expand Up @@ -88,12 +92,10 @@ void init_pio_input(void)
/* move up GPIO base of PIO to access all ADC pins */
pio_set_gpio_base(pio, 16);

uint offset = pio_add_program(pio, &adc_12bit_input_program);
uint offset = pio_add_program(pio, &adc_24bit_input_program);
uint sm_data = pio_claim_unused_sm(pio, true);


adc_12bit_input_program_init(pio, sm_data, offset, PIO_INPUT_PIN_BASE, PIO_OUTPUT_CLK_PIN);

adc_24bit_input_program_init(pio, sm_data, offset, PIO_INPUT_PIN_BASE, PIO_OUTPUT_CLK_PIN);

dma_channel_config c;
c = dma_channel_get_default_config(DMACH_PIO_PING);
Expand Down

0 comments on commit 6108b00

Please sign in to comment.