Quantcast
Channel: Arduino Forum - Latest topics
Viewing all articles
Browse latest Browse all 15427

Setting Timers to Toggle PWM Pins on Arduino Uno, Can A Different Initial Value Be Used?

$
0
0

I am trying to generate two 100KHz square waves to drive a full-bridge inverter using an Arduino Uno, with the following code:

TCCR1A = bit(COM1A0)  // toggle OC1A on Compare Match
           | bit (COM1B0);  // toggle OC1A on Compare Match
    TCCR1B = bit(WGM12) 
           | bit(CS11);   // CTC, /8 prescaling
    OCR1A =  9;       // (9 + 1) * 8 CPU cycles  -> 16 MHz / 80 = 100 KHz
}

This works well, and both OC1A and OC1B (9 and 10) display a 100KHz square waveform on my oscilloscope. However, I need to invert one of the signals. Is there any way to set the initial value of one of the pins to be inverted? The datasheet is making me think that 0 is always the starting value, based on this table:

Is my only option to use an external logic inverter?

3 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 15427

Trending Articles