5 years, 3 months ago.  This question has been closed. Reason: Unclear question

Do I need to write a data format register to a chip before I send data?

I am trying to send 24 bits of data through SPI from a Nucleo-STM32F411RE to a DAC8551 chip. I am trying to send a number from 0-65535 to the chip to give me an analog output between 0-5V. The DAC chip has a 16 bit resolution but there has to be 8 bits sent before the 16 bits as per manufactures documentation. I have the SPI library added and in my code I have ' spi.format(16, 0)' and ' spi.frequency (1000000)' in the main of the code and the 'spi.write' in the loop. I have the code broken up into 3 bytes. First byte is all 0's as per manufacture documentation and the next 2 bytes are in hex for the number 4000. My question is do I need to write a data format register byte before I send data? If yes, what would it be?

I have attached a piece of code that I am using to test the DAC chip. Is there anything that I am doing wrong?

Note: I can get the chip to work when using 12 bit (0-4095) but it is designed to be 16 bit resolution. I have to write the spi.write as 'spi.write(0x0FA0);'

/media/uploads/robertmahon/dac_code.png