changeset 23:3c713073dd0c

Remove debug prints and #ifdef now the control code works.
author Daniel O'Connor <darius@dons.net.au>
date Tue, 25 Feb 2025 15:56:49 +1030
parents 9ad0dd5c638c
children c7845db23ab2
files modulator.c
diffstat 1 files changed, 3 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/modulator.c	Tue Feb 25 15:46:46 2025 +1030
+++ b/modulator.c	Tue Feb 25 15:56:49 2025 +1030
@@ -16,7 +16,6 @@
 ** Create modulation shape
 **
 */
-#define WITH_CTRL
 //#define WITH_TRIGGER
 
 #include <stdio.h>
@@ -80,14 +79,13 @@
 uint dac_sm;
 // Instruction offset for DAC PIO program
 uint dac_pio_sm_offset;
-#ifdef WITH_CTRL
+
 // DMA channel to feed ctrl PIO
 static int ctrl_dma_chan;
 // Ctrl SM
 uint ctrl_sm;
 // Instruction offset for ctrl PIO program
 uint ctrl_pio_sm_offset;
-#endif
 
 /*
  * Use a DMA channel to feed PIO0 SM0 with pulse data.
@@ -102,44 +100,38 @@
  */
 void
 dma_handler(void) {
-  printf("dma_handler %d\n", get_core_num());
   // Clear the interrupt request.
   dma_hw->ints0 = 1u << dac_dma_chan;
 
+#if 0
   printf("DAC transfers %lu\n", dma_channel_hw_addr(dac_dma_chan)->transfer_count);
-#ifdef WITH_CTRL
   printf("Ctrl transfers %lu\n", dma_channel_hw_addr(ctrl_dma_chan)->transfer_count);
 #endif
 
   // Reset DAQ & ctrl PIO SMs so they are  waiting for a trigger
   pio_sm_exec(pulse_pio, dac_sm, pio_encode_jmp(dac_pio_sm_offset));
-#ifdef WITH_CTRL
   pio_sm_exec(pulse_pio, ctrl_sm, pio_encode_jmp(ctrl_pio_sm_offset));
-#endif
 
   // Setup next pulse data & ctrl DMA addresses
   dma_channel_wait_for_finish_blocking(dac_dma_chan);
   dma_channel_set_read_addr(dac_dma_chan, pulse_data, true);
-#ifdef WITH_CTRL
   dma_channel_wait_for_finish_blocking(ctrl_dma_chan);
   dma_channel_set_read_addr(ctrl_dma_chan, pulse_ctrl, true);
-#endif
 }
 
 
 void
 pwm_wrap(void) {
-  printf("pwm_wrap %d\n", get_core_num());
   pwm_clear_irq(slice_num);
 
 #ifndef WITH_TRIGGER
   // Manually trigger DAQ SM (cleared by SM)
   pulse_pio->irq_force = 3;
-#endif
 
   // 'scope trigger
   gpio_put(2, 1);
   gpio_put(2, 0);
+#endif
 }
 
 // Calculate pulse shape data
@@ -395,7 +387,6 @@
     irq_set_exclusive_handler(DMA_IRQ_0, dma_handler);
     irq_set_enabled(DMA_IRQ_0, true);
 
-#ifdef WITH_CTRL
     // Load the ctrl program, and configure a free state machine
     // to run the program.
     ctrl_pio_sm_offset = pio_add_program(pulse_pio, &ctrl_program);
@@ -423,7 +414,6 @@
         true			   // Start transfer
     );
     // No IRQ, piggyback on the data one
-#endif
 
 #ifdef WITH_TRIGGER
     // Load the trigger program, and configure a free state machine