Community
cancel
Showing results for 
Search instead for 
Did you mean: 
idata
Community Manager
879 Views

Edison SPI AND XDK

I am using the intel XDK for the first time and I am trying to get a reading from this SPI ADC http://www.ti.com/lit/ds/symlink/ads7950.pdf http://www.ti.com/lit/ds/symlink/ads7950.pdf

its connected like so

SPI_2_RXD -> MISO

SPI_2_TXD -> MOSI

SPI_2_CLK -> SCLK

SPI_2_FS0 -> ADC_CS

I have never used SPI before, I am very lost. I've been searching for 24 hours now and I'm not much closer to understanding what I'm supposed to do here.

here is the current hail mary code I'm trying. all I get back is ffffffff

var x = new m.Spi(0);

x.bitPerWord=16;

x.frequency = 20;

var buf = new Buffer(4);

buf[0] = char('0x0b');

buf[1] = char('0x11');

buf[2] = char('0x11');

buf[3] = char('0x11');

var buf2 = x.write(buf);

console.log("Sent: " + buf.toString('hex') + ". Received: " + buf2.toString('hex'));

Any help is appreciated

0 Kudos
9 Replies
idata
Community Manager
32 Views

The ADC is texas instruments ADS7951SRGER 12 Bit Analog to Digital Converter 8 Input 1 SAR 24-VQFN (4x4)

idata
Community Manager
32 Views

Hi Bruce,

Thank you for your interest in the Intel Edison Platform.

 

 

In order to assist you in a better way could you please provide some information, do you see "ffff" only in the MISO and MOSI or also in SCLK and CS. I would recommend you to see the time frame in the datasheet in page 18, if you can see something like that then we know that the device is correctly communicating with the Edison. If not please check again your connections and let me know the values in the MOSI, MISO, SCLK and CS this should be done with an oscilloscope in order to check compatibility with the time frame mention above.

 

 

I will be waiting for your reply, have a nice day.

 

Best regards

-Jose

idata
Community Manager
32 Views

Hey Jose,

I do not have access to an oscilloscope. I gather from the documentation that the frequency should be 20hz. I could be wrong, this is my first time trying to do anything with SPI.

currently the code looks like this:

var m = require('mraa'); //require mraa

// helper function to go from hex val to dec

function char(x) {

return parseInt(x, 16);

}

var x = new m.Spi(0);

//x.bitPerWord=12;

x.frequency = 20;

var buf = new Buffer(4);

buf[0] = char('0x0b');

buf[1] = char('0x11');

buf[2] = char('0x11');

buf[3] = char('0x11');

var buf2 = x.write(buf);

console.log("Sent: " + buf.toString('hex') + ". Received: " + buf2.toString('hex'));

it is returning

Sent: 0b111111. Received: 00000000

idata
Community Manager
32 Views

Hi Bruce,

 

 

I see you are using the template for the SPI, please check your datasheet you will see in the time frame that the frequency of the SCLK is 20 MHz. I try this template and it works just fine, you can actually test it if you connect your MISO to your MOSI you will see the same input in the receive message. I would recommend you to first check if you have the latest releases of the mraa library by using the command "opkg update", also please check that you are connecting correctly your ADC to the Edison. Please let me know what are your results.

 

 

I will be waiting for your reply, have a nice day.

 

 

Best Regards,

 

 

-Jose
idata
Community Manager
32 Views

Hey Jose,

I updated everything and tried x.frequency(20000000);, still nothing. I'm assuming I'm supposed to do something with the SPI_2_FS0 -> ADC_CS, like pull it low or something, but I have no clue how I'm supposed to go about that.

idata
Community Manager
32 Views

Hi Bruce,

I did some more research and first what I did is to use a logic analyzer with the template, as you can see in the image in doesn't look that is working well. I would recommend to follow this thread: . Were someone was trying to see how to use the SPI with the Intel XDK, also I recommend to read this article: http://www.i-programmer.info/programming/hardware/9589-exploring-edison-spi.html Exploring Edison - SPI . Were it explains how SPI works and how to use it in the Edison with the mraa library. Please let me know if you were able to connect your ADC to your Edison.

I will be waiting for your reply, have a nice day.

Best Regards,

-Jose

idata
Community Manager
32 Views

Hi ShakerBreaker,

 

 

Were you able to connect your ADC to your Edison by SPI? Please let me know, I will be happy to help with any issues that have come along.

 

 

I will be waiting for your reply, have a nice day.

 

 

Regards,

 

-Jose
idata
Community Manager
32 Views

hey Jose, i ended up figuring it out. i just needed to manually drop the CS0 between low and high

idata
Community Manager
32 Views

Hi ShakerBreaker,

 

 

I'm glad to hear that you managed to make it work! If you have any more questions, please don't hesitate to contact us.

 

 

Have a nice day!

 

 

Best Regards,

 

-Jose.
Reply