Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot send only 4 bits of data in SPI mode #23

Closed
GoogleCodeExporter opened this issue Mar 23, 2015 · 3 comments
Closed

Cannot send only 4 bits of data in SPI mode #23

GoogleCodeExporter opened this issue Mar 23, 2015 · 3 comments

Comments

@GoogleCodeExporter
Copy link

I try to communicate with the MCP3202 A/D converter. This converter from 
Microchip has an SPI interface and, according to the documentation, at the 
begginning of communication I've to send 4 bits to the A/D in order to select 
the input analog channel, set the bit-ordering mode, etc. After sending these 4 
bits, subsequential 13 clock cycles will output a null bit and the 12 bits of 
the converted value.

So, using the "write" function is not an option because as far as I know this 
function sends only a byte at a time, and I must write only 4 bits to the chip, 
not an entire byte. Is there any way to do so with libmpsse? or I've to modify 
it?

For the sake of reference, this A/D chip is part of a DLP-2232DAQ board. I've 
managed yet to communicate with the I/O ports included there thanks your great 
libmpsse, so thank you for your work!

Original issue reported on code.google.com by masores...@gmail.com on 5 Mar 2013 at 3:21

@GoogleCodeExporter
Copy link
Author

Currently libmpsse only supports sending 8-bit bytes, although adding support 
for arbitrary bit-length transfers shouldn't be hard since the FTDI chips do 
support that. I'll put it on the todo list, but in the meantime yes, you will 
either need to modify libmpsse, or bitbang the data using libmpsse's bitbang 
mode.

Original comment by heffne...@gmail.com on 11 Mar 2013 at 2:14

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Author

I've checked in some patches to the trunk that now include WriteBits and 
ReadBits functions. Initial testing seems OK, but I need to test them on a real 
device.

Original comment by heffne...@gmail.com on 22 Mar 2013 at 7:07

  • Changed state: Started

@GoogleCodeExporter
Copy link
Author

The latest code from the trunk contains two new functions: ReadBits and 
WriteBits, which allow you to read and write from 1 to 8 bits at a time. They 
can be safely mixed with the Read and Write functions in your code. I have 
tested this at different bit widths in SPI0 mode reading and writing data MSB 
first.

Original comment by heffne...@gmail.com on 25 Mar 2013 at 3:00

  • Changed state: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant