SPI Write 11 bits
Topic last updated
25 Oct 2011, by
Jesse Ardonne.
4 replies
SPI,
write
nintendo9713
#
25 Oct 2011
Hey guys! I'm working on a project and need some quick guidance. I bought this chip :
http://tinyurl.com/ThanksMbedCommunity
From what I understand, I use 11 bits to control the digital potentiometers. The first 3 bits are address (000 - 101) with the following 8 bits to control the wiper arm. As simple as it may or may not seem, I can't figure out how to transmit an 11 bit data string to the SPI connection. I'm using the typical p5,p6,p7 SPI connection.
The examples I find are generally spi.write(0x07) but I need exactly 11 bits (I think).
Could someone give me a pointer on this? I'm sure it's simple and I'm over complicating it. Thanks guys!
Replies
Hi Jesse,
You should be able to do something like:
SPI spi(p5, p6, p7);
spi.format(11);
spi.write(0x7FF);
Hope that helps,
Simon
nintendo9713
#
25 Oct 2011
Thanks Simon! I'll be trying this soon. I'm just confused with it needing exactly 11 bits, such as if I send 0x7FF, that would be 0100 1111 1111. What does it do with that first 0? Does it just read the first 11 and disregard the rest? I'm just trying to understand what's happening. Thanks for the quick reply!
Hi Jesse,
It'll just send the last 11 bits of whatever value you send. Have a play and hopefully it'll do what you expect.
Good luck!
Simon
Hi Jesse,
It'll just send the last 11 bits of whatever value you send. Have a play and hopefully it'll do what you expect.
Good luck!
Simon
Please log in to post a reply.
Hey guys! I'm working on a project and need some quick guidance. I bought this chip :
http://tinyurl.com/ThanksMbedCommunity
From what I understand, I use 11 bits to control the digital potentiometers. The first 3 bits are address (000 - 101) with the following 8 bits to control the wiper arm. As simple as it may or may not seem, I can't figure out how to transmit an 11 bit data string to the SPI connection. I'm using the typical p5,p6,p7 SPI connection.
The examples I find are generally spi.write(0x07) but I need exactly 11 bits (I think).
Could someone give me a pointer on this? I'm sure it's simple and I'm over complicating it. Thanks guys!