How do I make a PWM signal run once only.

Sorry Im not sure what you mean by that ard_Newbie. I probably wasnt clear in my explanation I need the waveforms to run once on command to control a Hbridge. The timing needs to be quite precise and accurate for the switching and I need them to run anytime a particular action happens. PWM is probably the best way to do this considering the precision and accuracy required?

MartinL:
Hi new_to_due,

I had a go at trying to get dead-time insertion together with synchronous PWM outputs and single pulse output, but it appears that doing so causes the Due to act strangely. I think that combining all three features is straying outside the bounds of what I'd call PWM controller's normal operation.

It appears that dead-time insertion only works if the PWM clock is not divided down, which isn't helpful if you require low frequency output. Also, the output PWM waveforms only work if the channel 0 duty-cycle update register is loaded with zero.

If your intention is to use dead-time insertion for a H-bridge, it might be better to use two asynchronous channels' high (PWMHx) and low side (PWMLx) complementary PWM outputs and adjust their high (DTH) and low (DTL) dead-time insertion accordingly. I'm not familiar with the H-bridge, but I imagine this is how the Due's PWM channels with dead-time insertion are intended to be used.

Hey Martin I have tried your suggestion but cant seem to get it give me the outputs I require using different complementary channels. Again the dead time doesnt seem to be working for complementary channels. ie when I set the PWMHx channel to 100% duty cycle I cant seem to get a dead time in the channel, but perhaps I am using the registers incorrectly to do it it in this particular instance.

void setup () {

  // PWM Set-up on pins PC6 and PC9 (Arduino Pins 41(PWMH3)& Pins 39(PWMH2 )): see Datasheet chap. 38.5.1 page 973
  PMC->PMC_PCER1 |= PMC_PCER1_PID36;                    // PWM power ON
  
  PWM->PWM_DIS = PWM_DIS_CHID2 | PWM_DIS_CHID3;         // Disable PWM channel 2
 
  // Select Instance=PWM; Signal=PWML2 (channel 2); I/O Line=PC6 (P6, Arduino pin 38, see pinout diagram) ; Peripheral=B
  PIOC->PIO_PDR |= PIO_PDR_P6;                          // Set the pin to the peripheral PWM, not the GPIO

  PIOC->PIO_ABSR |= PIO_PC6B_PWML2;                     // Set PWM pin perhipheral type B
  
  // Select Instance=PWM; Signal=PWMH3 (channel 3); I/O Line=PC9 (P9, Arduino pin 41, see pinout diagram) ; Peripheral type =B
  PIOC->PIO_PDR |= PIO_PDR_P9;                          // Set the pin to the peripheral PWM, not the GPIO

  PIOC->PIO_ABSR |= PIO_PC9B_PWMH3;                     // Set PWM pin perhipheral type B

  PWM->PWM_CLK = PWM_CLK_PREA(0) | PWM_CLK_DIVA(16);    // Set the PWM clock rate to 2MHz (84MHz/42). Adjust DIVA for the resolution you are looking for

  PWM->PWM_CH_NUM[2].PWM_CMR = PWM_CMR_CPRE_CLKA;       // The period is left aligned, clock source as CLKA on channel 2
  PWM->PWM_CH_NUM[3].PWM_CMR = PWM_CMR_CPRE_CLKA;       // The period is left aligned, clock source as CLKA on channel 3

  PWM->PWM_CH_NUM[2].PWM_CPRD = 37500;                  // Channel 2 : Set the PWM frequency 2MHz/(2 * CPRD) = F ;
  PWM->PWM_CH_NUM[3].PWM_CPRD = 37500;                  // Channel 2 : Set the PWM frequency 2MHz/(2 * CPRD) = F ;
 
  PWM->PWM_CH_NUM[2].PWM_CDTY = 315;                    // Channel 2: Set the PWM duty cycle to x%= (CDTY/ CPRD)  * 100 % ;
  
  PWM->PWM_CH_NUM[3].PWM_CMR = PWM_CMR_DTE | PWM_CMR_CPRE_CLKA;        // Enable single slope PWM and set the clock source as CLKA for all synchronous channels
  PWM->PWM_CH_NUM[3].PWM_DT = PWM_DT_DTH(630) | PWM_DT_DTL(3780);      // Set the low and high dead-time to start at 120us to 720us (140Hz => 600us period)
  PWM->PWM_CH_NUM[3].PWM_CDTY = 37500;                                 // Set the PWM duty cycle to 100% for the high channel 
  
  PWM->PWM_ENA = PWM_ENA_CHID2 | PWM_ENA_CHID3;
}

void loop() {
  
}