Mercurial > ~darius > hgwebdir.cgi > modulator
comparison ctrl.pio @ 27:e1d8fe3e418a
Run PIOs at 1x with delays and sync.
Can now use a single trigger to set both DAC & ctrl.
DAC [still] jitters against the ctrl though..
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Wed, 26 Feb 2025 11:03:59 +1030 |
parents | 6070d2e66b4c |
children | 600a394629e6 |
comparison
equal
deleted
inserted
replaced
26:336f06fa6e47 | 27:e1d8fe3e418a |
---|---|
1 ; | 1 ; |
2 ; Copyright (c) 2025 Daniel O'Connor | 2 ; Copyright (c) 2025 Daniel O'Connor |
3 ; | 3 ; |
4 | 4 |
5 .define TRIGGER_IRQ 0 | |
6 | |
5 .program ctrl | 7 .program ctrl |
6 .define DAC_TRIGGER_IRQ 0 | |
7 .define CTRL_TRIGGER_IRQ 1 | |
8 | |
9 ; Assert all 0s | 8 ; Assert all 0s |
10 mov pins, null | 9 mov pins, null |
11 ; Wait for start trigger and clear IRQ | 10 ; Wait for start trigger and clear IRQ |
12 wait 1 irq CTRL_TRIGGER_IRQ | 11 wait 1 irq TRIGGER_IRQ |
13 .wrap_target | 12 .wrap_target |
14 out pins 8 | 13 out pins 8 [1] |
15 nop | 14 nop [1] |
16 out pins 8 | 15 out pins 8 [1] |
17 nop | 16 nop [1] |
18 out pins 8 | 17 out pins 8 [1] |
19 nop | 18 nop [1] |
20 out pins 8 | 19 out pins 8 [1] |
21 nop | 20 nop [1] |
22 .wrap | 21 .wrap |
23 | 22 |
24 % c-sdk { | 23 % c-sdk { |
25 static inline void ctrl_program_init(PIO pio, uint sm, uint offset, uint pin, uint clkdiv) { | 24 static inline void ctrl_program_init(PIO pio, uint sm, uint offset, uint pin, uint clkdiv) { |
26 pio_sm_config c = ctrl_program_get_default_config(offset); | 25 pio_sm_config c = ctrl_program_get_default_config(offset); |
45 // We only send, so disable the RX FIFO to make the TX FIFO deeper. | 44 // We only send, so disable the RX FIFO to make the TX FIFO deeper. |
46 sm_config_set_fifo_join(&c, PIO_FIFO_JOIN_TX); | 45 sm_config_set_fifo_join(&c, PIO_FIFO_JOIN_TX); |
47 | 46 |
48 sm_config_set_clkdiv(&c, clkdiv); | 47 sm_config_set_clkdiv(&c, clkdiv); |
49 | 48 |
50 // Load our configuration, and start the program from the beginning | 49 // Load our configuration |
51 pio_sm_init(pio, sm, offset, &c); | 50 pio_sm_init(pio, sm, offset, &c); |
52 pio_sm_set_enabled(pio, sm, true); | |
53 } | 51 } |
54 %} | 52 %} |