Mercurial > ~darius > hgwebdir.cgi > modulator
comparison trigger.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 |
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 .program trigger | 5 .program trigger |
6 .define DAC_TRIGGER_IRQ 0 | 6 .define TRIGGER_IRQ 0 |
7 .define CTRL_TRIGGER_IRQ 1 | |
8 ; Use 1 side set pin for debugging | 7 ; Use 1 side set pin for debugging |
9 .side_set 1 | 8 .side_set 1 |
10 | 9 |
11 .wrap_target | 10 .wrap_target |
12 ; Wait for trigger to be low | 11 ; Wait for trigger to be low |
13 wait 0 pin 0 side 0 | 12 wait 0 pin 0 side 0 |
14 ; Wait for rising edge | 13 ; Wait for rising edge |
15 wait 1 pin 0 side 0 | 14 wait 1 pin 0 side 0 |
16 ; Signal DAC SM (which will trigger the control one) | 15 ; Signal DAC & ctrl SMs |
17 irq nowait DAC_TRIGGER_IRQ side 1 | 16 irq nowait TRIGGER_IRQ side 1 |
18 .wrap | 17 .wrap |
19 | 18 |
20 % c-sdk { | 19 % c-sdk { |
21 static inline void trigger_program_init(PIO pio, uint sm, uint offset, uint pin, uint clkdiv) { | 20 static inline void trigger_program_init(PIO pio, uint sm, uint offset, uint pin, uint clkdiv) { |
22 pio_sm_config c = trigger_program_get_default_config(offset); | 21 pio_sm_config c = trigger_program_get_default_config(offset); |
35 // Connect this GPIO to this PIO block | 34 // Connect this GPIO to this PIO block |
36 pio_gpio_init(pio, pin + 1); | 35 pio_gpio_init(pio, pin + 1); |
37 | 36 |
38 sm_config_set_clkdiv(&c, clkdiv); | 37 sm_config_set_clkdiv(&c, clkdiv); |
39 | 38 |
40 // Load our configuration, and start the program from the beginning | 39 // Load our configuration |
41 pio_sm_init(pio, sm, offset, &c); | 40 pio_sm_init(pio, sm, offset, &c); |
42 pio_sm_set_enabled(pio, sm, true); | |
43 } | 41 } |
44 %} | 42 %} |