Go Down

Topic: Answered: Unclear moment in sending data on serial (Read 608 times) previous topic - next topic

AlfaOmega

Apr 27, 2013, 08:50 pm Last Edit: Apr 28, 2013, 12:32 am by AlfaOmega Reason: 1
Hi all!

I'm making a programmable load. One of the steps is to make ATmega328 to talk to a MCP4921 DAC via serial interface.
The code that does the actual sending looks like this (courtesy of tronixstuff):

Code: [Select]
 outputValue = tAmps;
   digitalWrite(10, LOW);
   data = highByte(outputValue);
   data = 0b00001111 & data;
   data = 0b00110000 | data; //or data = 0b10110000 | data; to address the DACb
   SPI.transfer(data);
   data = lowByte(outputValue);
   SPI.transfer(data);
   digitalWrite(10, HIGH);
   delay(10);


I do understand how this code does what it does, except for the "0b" part in the   "data = 0b00001111 & data;" line in a line just below it.
If you know please explain :)
_

PaulS

0b means that the value to follow is in binary, not decimal, octal, or hex.

The art of getting good answers lies in asking good questions.

liuzengqiang

That part takes out the highest 4 bits of data using AND.
Serial LCD keypad panel,phi_prompt user interface library,SDI-12 USB Adapter

AlfaOmega


Go Up