Pages: [1]   Go Down
Author Topic: howto 16bit readout from device  (Read 353 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So creating a new topic because it turned out to be 16bit device.
http://ww1.microchip.com/downloads/en/devicedoc/70590c.pdf

I have no idea on how to read this out true SPI, little help?
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26250
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Two eight bit transfers?
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I dont know how to do this, 2X 8bit transfers to get the full 16
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So i came up with this, but im not getting any output.

Code:
#include<SPI.h>

const int CS= 10;


const int command=0x0000; //STSREG

void setup ()

{

Serial.begin(9600);

SPI.begin();

pinMode(CS,OUTPUT);


SPI.setDataMode(SPI_MODE0); //datasheet

SPI.setBitOrder(MSBFIRST);

digitalWrite(CS,HIGH);

// Slow down the master a bit if needed, max 20mhz (datasheet)
//SPI.setClockDivider(SPI_CLOCK_DIV8);

}

void loop() // repeated pattern

{

digitalWrite(CS,LOW);

byte msb = SPI.transfer(highByte(command));

byte lsb = SPI.transfer(lowByte(command));


Serial.println(msb);
Serial.println(lsb);

digitalWrite(CS,HIGH);

delay(5000);

}
Logged

Pages: [1]   Go Up
Jump to: