Hello everybody!
I’m trying to connect old UM6-LT to my Arduino UNO with SPI bus. I do get some data, but it is complete gibberish for me. Please, have a look, and tell me what you think about it.
#include <SPI.h>
void setup() {
Serial.begin(9600);
SPI.begin();
delay(100);
}
void loop() {
delay(100);
unsigned char data[6];
readRegister(0, (unsigned char *)&data);
for (int i = 0; i < 6; i ++ ){
Serial.print(data[i]);
Serial.print(' ');
}
Serial.println();
}
void readRegister(byte thisRegister, unsigned char * data) {
unsigned char tosend[6] = {0,thisRegister,0,0,0,0};
SPI.beginTransaction(SPISettings(340000, MSBFIRST, SPI_MODE0));
digitalWrite(SS, LOW);
delayMicroseconds(100);
SPI.transfer(tosend, 6);
for (int i = 0; i< 6; i++)
data[i] = tosend[i];
digitalWrite(SS, HIGH);
SPI.endTransaction();
}
void writeRegister(byte thisRegister, byte thisValue) {
}
[quote]0 0 0 0 0 0
126 0 0 0 8 15
126 0 0 0 8 15
126 0 0 0 8 15
63 100 221 94 0 0
0 0 0 0 8 15
126 0 0 0 8 15
126 0 0 0 8 15
126 0 0 0 8 15
126 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 8 15
126 0 0 0 8 15
126 0 0 0 8 15
126 0 0 0 8 15
126 0 0 0 8 15
126 0 0 0 8 15
126 0 0 0 8 15
126 0 0 0 8 15
126 0 0 0 8 15
126 0 0 0 8 15
126 0 0 0 0 0
0 0 0 0 8 15
63 100 221 94 0 0
0 0 0 0 8 15
126 0 0 0 8 64
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 8 64
0 0 0 0 0 0
0 0 0 0 8 64
0 0 0 0 8 15
126 0 0 0 8 15
126 0 0 0 0 0
0 0 0 0 8 15
126 0 0 0 8 15
63 100 221 94 0 0
0 0 0 0 0 0
0 0 0 0 8 64
0 0 0 0 8 15
63 100 221 94 0 0
[/quote]
clock is connected to pin 13, mosi is 11, miso is 12, ss is 10.
If I change SPI_MODE to 1, output becomes stabilized like that
[quote]0 128 64 128 85 0
0 128 64 128 85 0
0 128 64 128 85 0
0 128 64 128 85 0
0 128 64 128 85 0
0 128 64 128 85 0
0 128 64 128 85 0 [/quote]