at eight bits, while SPI can transfer arbitrary word
widths. (this is
handy for, say, ADCs and DACs).
Hmm.. I am not convinced.
You're not convinced that SPI supports multiple word widths?? I can
show you the datasheet of the microcontroller in my current design,
where it's configurable, if you like.
No, of course I am, convinced of that. I have read the data sheets for
SPI decvices. I am not convinced that having arbitrary word lengths
(which might not even be a multiple of 4 bits) is an advantage.
Any microprocesosr/controller is goinf to have
a 'natural' word size (8 bits, 16 bits, etc). The hardware SPI interface
is goign to trasnfer in chunks of that size -- you write a byte, or
whatever to a particualr I/O register and it sends it (or part of it). If
you bit-bang it, you will be shifitng the data in one of the procesor
registers, again of a definted size.
No, that's not at all how it works Tony. Or rather, that's perhaps a
suboptimal way to look at it. My particular example is the
Philips...erm, "NXP" (grumble) LPC2000-series ARM7 processors, which I'm
using all over the place now. They are 32-bit processors, and their SPI
controllers can be configured (by setting bits in very well-documented
registers) for 8, 9, 10, 11, 12, 13, 14, 15, or 16 bits per transfer.
You write to the SPI data register, which is sixteen bits wide, and just
treat the other bits as "don't cares".
Sure. I would have expected it to work that way. But what do you do if
you, say, have a 20 bit device? 10 bits at a time? That means repackign
the 20 bit word. Yo ucan't do 16 bits and then 4 bits (apparently), and
if you could you'd still ahve to reprogram the word length between the
parts of a single word. I'd prefer to just send an integral number of
bytes (or words, or whatever) and have the device ignore the unusued
data. That's waht I2C does for 12 bit devices AFAIK.
As a digression, normally, assuming programming in
C, you'd place a
"unsigned short" variable at the address of the SPI data register. (I'll
AFAIK sizeof(unsigned short) is not defined anywhere :-).
have none of that uncivilized "uint32_t"
bullshit that these kids have
dreamed up...and, surprise, my code is VERY portable)
-tony