top of page

Arduino 6.255KHZ Output, 180 DEGREE PHASE PULSE ( Dual Phase)

Writer: RAJ SHARMARAJ SHARMA

Arduino Code



// Generating Two 180° Out of Phase 6.255 kHz Square

// Waves with dead time on Timer1 of an

// Arduino UNO (Pins 9 and 10)

// Written January 23rd, 2023 by John Wasser


// frequency = 16MHz / (2 * prescaleFactor * (TOP + 1))

// Correction, because Phase Correct PWM is used:

// frequency = 16MHz / (2 * prescaleFactor * TOP)

const unsigned TOP = 1280;

// frequency = 16MHz / (2 * 1 * 160)

// frequency = 16MHz / 320

// frequency = 50,000


void setup()

{

Serial.begin(115200);

delay(200);


digitalWrite(9, LOW);

pinMode(9, OUTPUT);

digitalWrite(10, LOW);

pinMode(10, OUTPUT);


// Stop Timer/Counter1

TCCR1A = 0; // Timer/Counter1 Control Register A

TCCR1B = 0; // Timer/Counter1 Control Register B

TIMSK1 = 0; // Timer/Counter1 Interrupt Mask Register


// Set Timer/Counter1 to Waveform Generation Mode 8:

// Phase and Frequency correct PWM with TOP set by ICR1

TCCR1B |= _BV(WGM13); // WGM=8

TCCR1A |= _BV(COM1A1); // Normal PWM on Pin 9

TCCR1A |= _BV(COM1B1) | _BV(COM1B0); // Inverted PWM on Pin 10


ICR1 = TOP;

// Difference between OCR1A and OCR1B is Dead Time

OCR1A = (TOP / 2) - 1;

OCR1B = (TOP / 2) + 1;


// Start timer by setting the clock-select bits to non-zero

TCCR1B |= _BV(CS10); // prescale = 1

}


void loop() {}



 
 
 

Recent Posts

See All

Comments


​© 2014 INDIA Rajkumar Sharma                                                                                                                                                                                   Contact Me raj079@yahoo.com                                             

bottom of page