Timeline for How to send 16 bit data to MCP4802 from ATmega328p (Arduino Nano)
Current License: CC BY-SA 4.0
5 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Nov 30, 2022 at 0:44 | comment | added | ojacomarket | perfect! Works like charm! Have a good day and thanks again for your time! | |
Nov 30, 2022 at 0:31 | comment | added | Tom Carpenter |
@ojacomarket According to the datasheet (page 23), you should be sending only two 8-bit bytes, not three. The first byte contains the four control bits plus the upper four bits of the DAC output, and the second byte contains the lower four bits of the data. For the 8-bit DAC, you would send (config << 4) | (data >> 4) for the first byte, and (data << 4) for the second byte, where data is a uint8_t containing your waveform, and config is a uint8_t containing the four config bits, e.g. 0b0001 would be gain of 2.
|
|
Nov 30, 2022 at 0:15 | vote | accept | ojacomarket | ||
Nov 30, 2022 at 0:15 | comment | added | ojacomarket | You are the best! Thank you very much! Btw have you an idea why my signal is ca 1 V at the output? I have set my MCP4802 SPI to 0b0001000, which means USE GAIN of 2? So first byte is 0b0001000, second is 8 byte data and last is 8 bytes don't care | |
Nov 30, 2022 at 0:04 | history | answered | Tom Carpenter | CC BY-SA 4.0 |