system
July 30, 2012, 5:51pm
1
The code is below, I have highbyte and lowbytes set by switches. highbyte=00000000, lowbyte=00010000
int sendcheck = digitalRead(sendbutton);
if (sendcheck == HIGH) {
highbyte = PINL;
lowbyte = PINC;
digitalWrite(SS, LOW);
SPI.transfer(highbyte);
SPI.transfer(lowbyte);
digitalWrite(SS, HIGH);
here is the result of the code
How do I get rid of the high between the transfering the bytes?
What is MOSI doing then? You have data and control with SPI.
Is there a SCK pulse associated with the High on the data line?
If not, don't do anything. The receiving device certainly won't.
system
July 30, 2012, 8:27pm
5
@ crossroads, there is not a clock pulse, so the chip will skip that data.
Here is a picture with the clock pulses. I think the Phase is wrong. I need CPOL=0 CPHA=1 which is datamode 1.
My chip locks the bit in on the high to low transition. Did I screw up the SPI setup?
here is my SPI code in the Void setup
//SPI
SPI.begin();
pinMode (SS, OUTPUT);
digitalWrite(SS, HIGH);
SPI.setBitOrder(MSBFIRST);
SPI.setDataMode(1);
SPI mode, I've only ever used the standard mode. Not sure what the command is to change it.
Check here
The Arduino programming language Reference, organized into Functions, Variable and Constant, and Structure keywords.
Description
Sets the SPI data mode: that is, clock polarity and phase. See the Wikipedia article on SPI for details.
Syntax
SPI.setDataMode(mode)
Parameters
mode: SPI_MODE0, SPI_MODE1, SPI_MODE2, or SPI_MODE3