doceme / py-spidev

MIT License
461 stars 203 forks source link

Problem getting data from TI ADS8318 ADC via SPI on Minnowboard Turbot running Ubuntu 14.04 #74

Open mrapl opened 6 years ago

mrapl commented 6 years ago

Hello,

I'm trying to use spidev 3.2 to get data from ADS8318 ADC in Daisy Chain Mode on Ubuntu 14.04 3.19.0-25-generic. I'm able to open the SPI device in spidev with spi = spidev.SpiDev() spi.open(0,0) However the data I receive from SPI is all zeros regardless of the data I send. I've tried using readbytes(), xfer(), as well as xfer2().

According to the documentation of the ADC (https://www.ti.com/lit/ds/symlink/ads8318.pdf) I should make sure SDI is low and then initialize the ADC acquisition in daisy chain mode by setting CONVST up. Is there a way to control the individual SPI I/O pins from spidev. I'm not aware of any control codes to control them by sending data via the SPI.

I'm new to embedded systems in general, so any pointers to even the most obvious things I'm missing would be appreciated.

jonathancgroves commented 6 years ago

Hi @mrapl

I'm struggling with getting spidev to work properly as well.

I guess you realise the second parameter in your spi.open(0,0) is which CE should be used? I'm using Raspberry Pi and I'm sure your hardware is different, but it might be worth me explaining what I have gathered about this... The Pi has two SPI buses(complete sets of connections). Each channel can address two devices by asserting a different CE line then communicating with each. The first parameter in the spi.open command is the bus, and the second is which Chip Enable to assert. On the Pi there is actually a third CE which can be accessed as well. One of the things it seems spidev is designed to do is to take away all the pain of enabling the CE line before initiating the transaction - I guess the docs you were reading were intended for lower-level purposes. So if you have the right bus and CE set up you should be good to go. Be aware, however, there are a bunch of other settings which you may need to be aware of (word length, max_speed probably being the most significant). Hope this helps.

Edit to correct terminology