In some code examples, it's about timer, capture/compare register's value,
TACCR0 = 50 >> 1;
What does '>>' function? If i write like this into capture/compare register what happens its value?
Thanks.
Ferhat
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
In some code examples, it's about timer, capture/compare register's value,
TACCR0 = 50 >> 1;
What does '>>' function? If i write like this into capture/compare register what happens its value?
Thanks.
Ferhat
'>>' is a mathematical operator. It does a binary right shift by the given number of bits.
50>>1 means the binary value 50 ( 00110010) is shifted right by 1 digit (00011001) which gives 25. So 'x >> y' is effectively a division of x by 2^y.
Since the processor has its own instruction fo doing this, it is much faster (several magnitudes) than dividing by two. But in this case, it is a constant anyway and the compiler will directly calculate the resulting 25.
BTW: the opposite is a left shift and its operator is '<<', doing affectively a multiplication by 2, 4, 8 etc.
**Attention** This is a public forum