Can SPI support only 8it and 16-bit (short) data transfers?

Hi, I use “Cobra board”.

I have read the “NETMF Tutorials”, I find that "NETMF supports 8-bit (byte) and 16-bit (short) data transfers. "

Can SPI support only 8it and 16-bit (short) data transfers?

If I want 12bit, 13bit, or 4bit, how can I define it?

SPI is easy to bitbang - that’s stepping outside the netmf SPI driver.

SPI as implemented in NETMF takes an array and will transfer the entire array at one time and then toggle the Chip Select line. I have never heard of a case of someone wanting to transfer less than a full byte over SPI. To do that you could try shifting the data within the byte so that after a byte wide shift the four bits you are interested in are still in the target device register.

You’ve never seen a 5-bit shift register? :wink:

** Holy crap, such a thing actually exists. 7496 5-bit shift register. Alright, I’m done with the sarcasm now, I guess.

@ godefroi - lol

I have a "DAC MCP4822 "

The device is 12-Bit Dual Voltage Output Digital-to-Analog Converter with Internal VREF and SPI Interface

How about 12bit of the device MCP4822? How can I transfer the 12bit data with SPI?

the 12-bit is how many bits of resolution the DAC is, and can have NOTHING to do with the number of bits you need to communicate to it.

With SPI, you HAVE to look at the datasheet of the device. A quick look on page 23 of the data sheet for that device shows 16-bit transfers. You’re worried about nothing.

With the MCP DAC family you need to transfer 16 bits for one sample.
4 bits for the command + 12 bits for the sample… give a look at the spec in the serial communication part…
It’s clear and easy to understand.

Xavier

@ Ixox -

you are right!!! I got it !