This code works but I am wonder about the use of >>= vs >>.
byte dac_lo,dac_hi; unsigned int temp1,temp2; dac_ch = (v_dac_lo_reg & 7); temp1 = v_dac_hi_reg << 4; //shift to left 4 temp2 = v_dac_lo_reg >>= 4 & 0x0f; //shift to right 4 dac_lo = (temp1 | temp2); //combine dac_hi = v_dac_hi_reg >>= 4 & 0x0f;
Hi,
It's a compound operator. myVariable >>= 2; is the same as: myVariable = myVariable >> 2;
best, Michael
edit to correct typo
It is really just a convenience to keep you from typing myVariable twice. Back before code completion (like we are stuck with in the arduino IDE now) it was easy to make mistakes with complicated references like:
structptr->rect.point1->point.x