I am not clear on how Arduino code works with the "shiftout" function.
I need to shift out 12 bits.
should I use the shiftout or just bitbang with other functions?
I need to shift out 12 bits.
should I use the shiftout or just bitbang with other functions?
Code:
void WriteToDAC(void)
{
//#define DAC_CLK 28
//#define DAC_Data 29
//#define VddDAC_Sel 30
byte bitcount;
int DACvalue;
if (DACbuffer > 4095) // tens, ones, tenths
DACbuffer = 0; // limit to f.s. of DAC 5V
DACvalue = DACbuffer * 16; // Move 12 bit to MSB position for 16bit (long)
output_low(VddDAC_Sel);
for (bitcount=12; bitcount>0;bitcount--)
{
shiftOut(DAC_Data,DAC_CLK,MSBFIRST,DACbuffer[bitcount]); ??????????????
//Output_High(DAC_CLK); ??????????????
//delay(1); ??????????????
//Output_Low(DAC_CLK); ??????????????
}
output_high(VddDAC_Sel);
}