What's the difference between toggle,set&?

I found someone expained"
Clear - output set to LOW
Set - output set to HIGH
Toggle - output set to opposite of current state."

I still can't understand,sepecially" opposite of current state".What's the meaning of that?

I also want to know the meaning of "0b" in the code "TCCR0A = 0b01000010".

if state is 1 it will be cleared to 0, if state is 0 it will be set to 1.

means following digits are binary number

1 Like

Toggle will turn LOW into HIGH or HIGH into LOW. Also known as XOR or eXclusive OR. "0b" is a prefix for binary numbers.

int value = 0b00000010; //value = 2
value = value xor 2; //value = 0
value = value xor 2; //value = 2

In C xor is usually written as "^": value = value ^ 2 or the short version: value ^= 2

1 Like

preceding bits are binary. 100b = 8

Thanks for your answer! I found a kind of statement asfollows
"A FOC0A strobe will not generate any interrupt, nor will it clear the timer in CTC mode using OCR0A as TOP. "
is the meanig of"clear the timer" "Clear the data of the counter"? :smiley:

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