-
I try to get the following program to work (on Arduino) int _freq=48000; PIOProgram *_i2s; #include "hardware/pio.h" #define pio_i2s_in_wrap_target 0 static const uint16_t pio_i2s_in_program_instructions[] = { static const struct pio_program pio_i2s_in_program = { static inline pio_sm_config pio_i2s_in_program_get_default_config(uint offset) { static inline void pio_i2s_in_program_init(PIO pio, uint sm, uint offset, uint data_pin, uint clock_pin_base, uint bits) { void setup() {
} void loop() { } The code is an extraction of the example I2S library and needless to say I2SInput is working (I can see clock and framesync) Intention here is ONLY to get the pio running. Later I will add dma to fetch data. Edit: seems that DMA is necessary, but why? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
For sake of completeness, here is the code that is running on kb2040 int _freq=48000; PIOProgram *_i2s; #include "hardware/pio.h" #define pio_i2s_in_wrap_target 0 static const uint16_t pio_i2s_in_program_instructions[] = { static const struct pio_program pio_i2s_in_program = { static inline pio_sm_config pio_i2s_in_program_get_default_config(uint offset) { static inline void pio_i2s_in_program_init(PIO pio, uint sm, uint offset, uint data_pin, uint clock_pin_base, uint bits) { void i2s_setup(void) _i2s = new PIOProgram( &pio_i2s_in_program); pio_i2s_in_program_init(_pio, _sm, off, _pinDOUT, _pinBCLK, _bps); pio_sm_set_enabled(_pio, _sm, true); #define NBUF 16 static void dma_irq(void) void dma_setup(void)
} void setup() { while(!Serial); i2s_setup(); dma_setup(); void loop() { |
Beta Was this translation helpful? Give feedback.
For sake of completeness, here is the code that is running on kb2040
`
pin_size_t _pinDOUT =0;
pin_size_t _pinBCLK =1;
int _freq=48000;
int _bps=32;
int off=0;
PIOProgram *_i2s;
PIO _pio;
int _sm;
#include "hardware/pio.h"
#define pio_i2s_in_wrap_target 0
#define pio_i2s_in_wrap 7
static const uint16_t pio_i2s_in_program_instructions[] = {
// .wrap_target
0xa022, // 0: mov x, y side 0
0x4801, // 1: in pins, 1 side 1
0x0041, // 2: jmp x--, 1 side 0
0x5801, // 3: in pins, 1 side 3
0xb022, // 4: mov x, y side 2
0x5801, // 5: in pins, 1 side 3
0x1045, // 6: jmp x--, 5 side 2
0x4801, // 7: in pins, 1 side 1
// .wrap
};
static const struct pio_program pio_i2s_in_program = {
.instructions = pio_…