Mercurial > ~darius > hgwebdir.cgi > modulator
view dac.pio @ 8:0249d0cecac4
Use interpolator to compute pulse up.
Use interpolator to clamp values.
Calculate speed.
Do memory clear in routine to be more honest about the speed.
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Sun, 16 Feb 2025 14:36:33 +1030 |
parents | 2db42eaba3c8 |
children | 3acdebd7eec7 |
line wrap: on
line source
; ; Copyright (c) 2021 Daniel O'Connor ; .program dac .side_set 1 ; Clock DAC and write data from the FIFO .wrap_target pull side 1 out pins 8 side 0 nop side 1 out pins 8 side 0 nop side 1 out pins 8 side 0 nop side 1 out pins 8 side 0 .wrap % c-sdk { static inline void dac_program_init(PIO pio, uint sm, uint offset, uint pin, uint clkdiv) { pio_sm_config c = dac_program_get_default_config(offset); // Set the OUT base pin to the provided `pin` parameter. // First 8 pins are data, last is clock sm_config_set_out_pins(&c, pin, 9); // Set the pin directions to output at the PIO pio_sm_set_consecutive_pindirs(pio, sm, pin, 9, true); // Connect these GPIOs to this PIO block for (int i = 0; i < 9; i++) pio_gpio_init(pio, pin + i); sm_config_set_out_shift( &c, true, // Shift-to-right false, // Autopull enabled 32 // Autopull threshold (bits!) ); // Configure clock as sideset pin sm_config_set_sideset_pins(&c, pin + 7); // We only send, so disable the RX FIFO to make the TX FIFO deeper. sm_config_set_fifo_join(&c, PIO_FIFO_JOIN_TX); sm_config_set_clkdiv(&c, clkdiv); // Load our configuration, and start the program from the beginning pio_sm_init(pio, sm, offset, &c); pio_sm_set_enabled(pio, sm, true); } %}