marcel-licence / ML_SynthTools

ML_SynthTools
GNU General Public License v3.0
149 stars 25 forks source link

RP2040 using other than PWM0 (solution) #32

Closed bradanlane closed 1 year ago

bradanlane commented 1 year ago

The current DMA code in RP2040_AudioPwm.cpp always manipulates PWM0. In the following code I have changed the PWM_BASE value to using the pwm_hw->slice[] value for the COUNT COMPARE.

(See commented out parameter followed by new parameter)

dma_channel_configure(
                      audio_dma_ch, 
                      &audio_dma_ch_cfg, 
                      // (void *)(PWM_BASE + PWM_CH0_CC_OFFSET),  // Write to PWM counter compare
                      &pwm_hw->slice[audio_pwm_slice_num].cc,     // Write to PWM counter compare
                      &(audio_buffer_a[0]), 
                      buffSize, 
                      false
          );

With this change, the proper slice is used based on the value of RP2040_AUDIO_PWM_PIN.

marcel-licence commented 1 year ago

Thank you very much, I've integrated your suggested code change

bradanlane commented 1 year ago

Glad I was able to find the fix.