ADC triggered by PWM channel 4?

Is it possible to trigger the ADC using any other PWM channel except channel 0? I wrote this code thinking that this was enough for triggering it from PWML4,

And I selected the ADC triggering event by this line of code,

 ADC->ADC_MR |= ADC_MR_TRGEN_EN | ADC_MR_TRGSEL_ADC_TRIG5; 

My doubt arises because I don't see any CMPV or CMPM registers defined for other PWM channels in the file component_PWM under libsam.

In order for more people to help you, never paste screenshots in your posts, use text instead.

Hi @b707
Sorry about that - thank you for pointing that out.

  PWM->PWM_CMP[4].PWM_CMPV = PWM_CMPV_CV(1500); //The value to be compared with the counter of channel 4 (val btwn 1 - PWM_CPRD)
  PWM->PWM_CMP[4].PWM_CMPM = PWM_CMPM_CEN;      // ENable comparison
  PWM->PWM_ELMR[1] = PWM_ELMR_CSEL4; //Event line triggering per CMPV value of channel 4 (thus CSEL 4)
  

This is the line I wrote for triggering the ADC

ADC->ADC_MR |= ADC_MR_TRGEN_EN | ADC_MR_TRGSEL_ADC_TRIG5;

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.