liz02
Posts: 2
Joined: Sun Jan 22, 2017 9:00 pm

How to send 16bit via spidev?

Sun Jan 22, 2017 9:20 pm

Hi!
I'm currently facing some problems communicating with an AD7490. So far I've only worked with the MCP3208.
I know that I need to send 16 bit, and until now I've tried everything I found on the internet unfortunately most examples are written in C not in python.
So is it even possible to do that in python? If yes can anyone please give me an example on how to?

Best regards
Elisabeth

User avatar
joan
Posts: 14093
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: How to send 16bit via spidev?

Sun Jan 22, 2017 11:51 pm

Send two bytes. Each byte is 8 bits. Two are 16 bits.

SPI has no concept of length other than a bit . It doesn't know about bytes.

liz02
Posts: 2
Joined: Sun Jan 22, 2017 9:00 pm

Re: How to send 16bit via spidev?

Mon Jan 23, 2017 5:30 am

Thanks, for the reply. I've tried that in several ways. But I thin my syntax is off, either I got 8 bits or nothing.

User avatar
brekee12
Posts: 335
Joined: Wed Feb 03, 2016 3:36 pm
Location: HU

Re: How to send 16bit via spidev?

Mon Jan 23, 2017 9:10 am

Try pigpio library with second spi device not with standard spidev. Probably your AD7490 does not accept CS handling during the 16 bit communication. Between the two words it raises momentarly that can be the problem. Unfortunatelly, it is a long time ago I made C programming of this second spi but with B+ series Raspberries it works well.
Brekee12
on a Raspberry B+ with whezzy, two Zero with Jessie Light

User avatar
joan
Posts: 14093
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: How to send 16bit via spidev?

Mon Jan 23, 2017 9:21 am

liz02 wrote:Thanks, for the reply. I've tried that in several ways. But I thin my syntax is off, either I got 8 bits or nothing.
Post the code (in Code quotes on the tool bar when you create/edit a post).

picandies
Posts: 186
Joined: Wed Nov 26, 2014 5:13 pm

Re: How to send 16bit via spidev?

Sat Aug 18, 2018 6:52 pm

Did you ever get the chip working--what was the solution?

Return to “Python”