# HG changeset patch # User Daniel O'Connor # Date 1740464220 -37800 # Node ID c7845db23ab20f8dacd81f12bee21d9d34b146eb # Parent 3c713073dd0c272b48a0b2d2387b9660fd111ec5 Add sideset for trigger output. Trigger both SMs diff -r 3c713073dd0c -r c7845db23ab2 modulator.c --- a/modulator.c Tue Feb 25 15:56:49 2025 +1030 +++ b/modulator.c Tue Feb 25 16:47:00 2025 +1030 @@ -16,7 +16,7 @@ ** Create modulation shape ** */ -//#define WITH_TRIGGER +#define WITH_TRIGGER #include #include @@ -51,8 +51,9 @@ // Base of ctrl pins #define CTRLOUT_GPIO 16 // PWM output pin -#define TRIGOUT_GPIO 23 +#define TRIGOUT_GPIO 22 // PIO SM trigger input pin (connected to above for testing) +// Also outputs trigger on next pin #define TRIGIN_GPIO 27 // Pulse control bits @@ -119,7 +120,6 @@ dma_channel_set_read_addr(ctrl_dma_chan, pulse_ctrl, true); } - void pwm_wrap(void) { pwm_clear_irq(slice_num); @@ -426,6 +426,7 @@ uint trigger_sm = pio_claim_unused_sm(pulse_pio, true); trigger_program_init(pulse_pio, trigger_sm, trigger_pio_sm_offset, TRIGIN_GPIO, 2); #endif + // // Setup PWM // Used here to output a trigger which gets fed back into the trigger SM diff -r 3c713073dd0c -r c7845db23ab2 trigger.pio --- a/trigger.pio Tue Feb 25 15:56:49 2025 +1030 +++ b/trigger.pio Tue Feb 25 16:47:00 2025 +1030 @@ -3,15 +3,19 @@ ; .program trigger -.define TRIGGER_IRQ 0 +.define DAC_TRIGGER_IRQ 0 +.define CTRL_TRIGGER_IRQ 1 +; Use 1 side set pin for debugging +.side_set 1 .wrap_target ; Wait for trigger to be low - wait 0 pin 0 + wait 0 pin 0 side 0 ; Wait for rising edge - wait 1 pin 0 -; Signal other state machine - irq nowait TRIGGER_IRQ + wait 1 pin 0 side 0 +; Signal other state machines + irq nowait DAC_TRIGGER_IRQ side 1 + irq nowait CTRL_TRIGGER_IRQ side 1 .wrap % c-sdk { @@ -25,6 +29,13 @@ // Connect this GPIO to this PIO block pio_gpio_init(pio, pin); + // Configure side pin mapping to point to debug pin + sm_config_set_sideset_pins(&c, pin + 1); + // Set to output + pio_sm_set_consecutive_pindirs(pio, sm, pin + 1, 1, true); + // Connect this GPIO to this PIO block + pio_gpio_init(pio, pin + 1); + sm_config_set_clkdiv(&c, clkdiv); // Load our configuration, and start the program from the beginning