CrossRoads:
Wow, that is a lot of code to send two bytes to a DAC.This part
#include <SPI.h>
#include "MCP4911.h"
#define AOUT_CS 5
#define AOUT_LDAC 6
#define AOUT_CLK 7
#define AOUT_SDI 8
The SPI pins are specific hardware pins. On a '328, D13-12-11 and typically 10 for CS. On a '2560, something like D53-52-51 and 50 somewhere in that range). On a 1284, D13-12-11-10 for Bobuino, and D7-6-5-4 for other versions. Not sure where on a 32U4 (Leonardo). How will those "# define"s work when SPI.transfers are actually being used, as in below?// Enable SPI communications
digitalWrite(cs,LOW);
// Send command word
byte0 = cmdWrd >> 8;
byte1 = cmdWrd & 0b0000000011111111;
SPI.transfer(byte0);
SPI.transfer(byte1);
// Disable SPI communications
digitalWrite(cs,HIGH);Could be I am totally misunderstanding this as well, really the first time I looked at what goes into a library/class whatever it is called that you crafted.
The CLK and SDI defines were ones I added. But since SPI.transfer uses the hardware pins (something I completely overlooked!), I will remove all references to the pins I tried to define! I hope that when my chip gets here it will work well with the library, if not... well I'll have to take another look at software SPI, I think.
So I connect:
SDI (MOSI) - 51
SCK - 52
And I get to choose CS (SS), and LDAC. I think I understand.
I have never delved into libraries either, everything is so new and complicated to me! Thank you for your help ![]()