Hi,
I'm thinking of buying a MCP4922 which is a dual 12bit DAC with an SPI interface and not having much experience of SPI apart from using it in various libraries I need a bit of hand holding before I get started.
Some simple (hopefully) questions.
As far as I can tell the HardwareSPI library doesn't setup the CS pin itself, that needs to be done before calling write
- is that correct?
Therefore I assume the two SPI lines (MISO/MOSI or SDI/SDO) can be shared between devices? I am currently using SPI_2 for a SD card and SPI_1 for a RF2401 transceiver. If I share the SPI lines between the SD card and the DAC and use a separate CS pin for each device to select will I run into problems, assuming they use the same mode
and clock frequency?
The 4922 needs a 16bit word sent (4bits control, 12bits data)- will that be a problem with the maple which only sends a byte at a time. I'm assuming I just use the multi-byte write
command. Something like the code below should work?
uint16 fred = ccccdddddddddddd; // (bits:c=control, d=data)
digitalWrite( MCP4922A_CS, HIGH); // or low if it's _CS...
spi.write( (uint8 *) &fred, 2);
digitalWrite( MCP4922A_CS, LOW);
I just need to know if I'm on more or less the right path before I purchase.