Hello,
i'm using R-R2 ladder to make 8bit DAC, using this schematic:
Since on mega8/168/328p/etc... PB6 and PB7 is used for crystal, free ports are from PB0..PB5 and PC0..PC5.
So i'm using the first 6 bits on PB0-5 and last two bits - PC5 and PC4.
And to get outputs from it using bitwise operators(value is 0-255 byte):
PORTB = (PORTB & 0xC0) | ((value & 0xFC) >> 2);
PORTC = (PORTC & 0x0F) | ((value & 0x03) << 4);
Tested via serial, i'm getting the right bits, however, testing with multimeter on output (Vout in sch) voltage drops from 0V to 4V for like 1V:
if value is 0, output is 0V, if value is 5, output is 1V, if value is 20, output is 4V, if value is 25, output goes again to 0V or 1V and this goes till value is 255.
Since i tested it via serial, it could be wiring problem...? Dunno... Or i missing somewhere else maybe?
P.S i know, there is PORTD available, but actually i need 2x 8bit DAC's, and yes, im already using one on PORTD.