# Pulse generation using Timer counter in ATMEL SAM3x8e Arduino Due

I am using the ATMEL SAM3x8e chip on an Arduino Due. I want to generate two pulses of frequency 100 kHz of the pattern shown below (1 period shown). For this I used TIOA8 and TIOA0 lines in the UPDOWN_RC mode and UP_RC mode. I see that the blue wave is very similar to an example waveform on TIOA shown on Pg.870 of the ATMEL datasheet.

My code is as follows, but I don't see any outputs on any of the two pins. What am I missing here? I deliberately didn't include the TCx_Handler() functions since I only want to generate the pulses and don't need any actions on interrupts.

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;

}

void loop(){}

• Can you be more clear about what you are trying to accomplish? Your blue line just shows a single pulse, and your orange line only shows a transition. How often do you need to send pulses? How precise is the timing requirement? Why not just bang in a delayMicroseconds() around a couple of digitalWrite()s? Dec 21, 2022 at 2:26