Mercurial > ~darius > hgwebdir.cgi > modulator
comparison modulator.c @ 24:c7845db23ab2
Add sideset for trigger output.
Trigger both SMs
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Tue, 25 Feb 2025 16:47:00 +1030 |
parents | 3c713073dd0c |
children | 6070d2e66b4c |
comparison
equal
deleted
inserted
replaced
23:3c713073dd0c | 24:c7845db23ab2 |
---|---|
14 ** MODULATOR.C | 14 ** MODULATOR.C |
15 ** | 15 ** |
16 ** Create modulation shape | 16 ** Create modulation shape |
17 ** | 17 ** |
18 */ | 18 */ |
19 //#define WITH_TRIGGER | 19 #define WITH_TRIGGER |
20 | 20 |
21 #include <stdio.h> | 21 #include <stdio.h> |
22 #include <string.h> | 22 #include <string.h> |
23 | 23 |
24 #pragma GCC diagnostic push | 24 #pragma GCC diagnostic push |
49 // Base of DAC pins | 49 // Base of DAC pins |
50 #define DACOUT_GPIO 7 | 50 #define DACOUT_GPIO 7 |
51 // Base of ctrl pins | 51 // Base of ctrl pins |
52 #define CTRLOUT_GPIO 16 | 52 #define CTRLOUT_GPIO 16 |
53 // PWM output pin | 53 // PWM output pin |
54 #define TRIGOUT_GPIO 23 | 54 #define TRIGOUT_GPIO 22 |
55 // PIO SM trigger input pin (connected to above for testing) | 55 // PIO SM trigger input pin (connected to above for testing) |
56 // Also outputs trigger on next pin | |
56 #define TRIGIN_GPIO 27 | 57 #define TRIGIN_GPIO 27 |
57 | 58 |
58 // Pulse control bits | 59 // Pulse control bits |
59 #define PACTIVE 0x01 | 60 #define PACTIVE 0x01 |
60 #define PHINV 0x02 | 61 #define PHINV 0x02 |
116 dma_channel_wait_for_finish_blocking(dac_dma_chan); | 117 dma_channel_wait_for_finish_blocking(dac_dma_chan); |
117 dma_channel_set_read_addr(dac_dma_chan, pulse_data, true); | 118 dma_channel_set_read_addr(dac_dma_chan, pulse_data, true); |
118 dma_channel_wait_for_finish_blocking(ctrl_dma_chan); | 119 dma_channel_wait_for_finish_blocking(ctrl_dma_chan); |
119 dma_channel_set_read_addr(ctrl_dma_chan, pulse_ctrl, true); | 120 dma_channel_set_read_addr(ctrl_dma_chan, pulse_ctrl, true); |
120 } | 121 } |
121 | |
122 | 122 |
123 void | 123 void |
124 pwm_wrap(void) { | 124 pwm_wrap(void) { |
125 pwm_clear_irq(slice_num); | 125 pwm_clear_irq(slice_num); |
126 | 126 |
424 __breakpoint(); | 424 __breakpoint(); |
425 } | 425 } |
426 uint trigger_sm = pio_claim_unused_sm(pulse_pio, true); | 426 uint trigger_sm = pio_claim_unused_sm(pulse_pio, true); |
427 trigger_program_init(pulse_pio, trigger_sm, trigger_pio_sm_offset, TRIGIN_GPIO, 2); | 427 trigger_program_init(pulse_pio, trigger_sm, trigger_pio_sm_offset, TRIGIN_GPIO, 2); |
428 #endif | 428 #endif |
429 | |
429 // | 430 // |
430 // Setup PWM | 431 // Setup PWM |
431 // Used here to output a trigger which gets fed back into the trigger SM | 432 // Used here to output a trigger which gets fed back into the trigger SM |
432 // | 433 // |
433 // 120MHz / 250 = 480kHz base | 434 // 120MHz / 250 = 480kHz base |