Two PWM pulses using timer counter

I want to generate two pulses with 100 kHz frequency as shown,
image

So I used the updown_RC mode for the blue wave and up_RC for the orange wave, but I don't see any outputs on the Due. Since this doesn't need to do anything on interrupt, I did not include a handler(). I am using TIOA8 and TIOA0 channels to get the waves.

Also, how do I ensure that the wave will be high at first and resets when it matches RA value?

I want to get the TIOA waveform as shown here in this image from the ATMEL SAM3x8e datasheet.

void setup(){

  //Waveform on TIOA8 i.e TC2 Ch2, pin no Port D.7 pin D11
  PMC->PMC_PCER1 |= PMC_PCER1_PID35;
  PIOD->PIO_PDR |= PIO_PDR_P7; //Disable GPIO on D.7
  PIOD->PIO_ABSR |= PIO_PD7B_TIOA8;

  TC2->TC_CHANNEL[2].TC_CMR = TC_CMR_TCCLKS_TIMER_CLOCK1
                             | TC_CMR_WAVE
                             | TC_CMR_WAVESEL_UP_RC
                             | TC_CMR_ACPA_CLEAR
                             | TC_CMR_ACPC_SET;

  TC2->TC_CHANNEL[2].TC_RC = 420; //100 kHz frequency, sawtooth waveform
  TC2->TC_CHANNEL[2].TC_RA = 218; //Calculated corresponding to RC

  ////////////////////////////////////////////////////
  
  //Waveform on TIOA0 FOR SWITCH S1
  PMC->PMC_PCER0 |= PMC_PCER0_PID27; //TC0 CH0
  PIOB->PIO_PDR |= PIO_PDR_P25; //Disable GPIO on B.25
  PIOB->PIO_ABSR |= PIO_ABSR_P25;

  TC0->TC_CHANNEL[0].TC_CMR = TC_CMR_ACPA_TOGGLE |
                              TC_CMR_WAVE |
                              TC_CMR_WAVESEL_UPDOWN_RC |
                              TC_CMR_TCCLKS_TIMER_CLOCK1;

   TC0->TC_CHANNEL[0].TC_RC = 210;
   TC0->TC_CHANNEL[0].TC_RA = 17;                            
}

void loop(){}

What am I missing here?

The shown pulses are not periodical. Let's look closely to the beginning of your diagram - you have a both blue and orange HIGH. But on the end you have a blue as HIGH and orange LOW.
So your pulse scheme is incomplete and you should to clarify it first.

I drew out only 1 period. This is the pattern that repeats every cycle, I have just drawn it out for one period.

I only meant that the pattern for periodic signal should ends with the same pin states as it was begins. So you should extend your pattern to the beginning of the next cycle.

Ah I see, sorry about that. Could you help with the TIOA waveform generation as shown in the image of the datasheet (not the blue-orange waveform)? Thank you!

sorry, I have not an experience with Due timers

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