Hi,
I have a problem with my little project
In a small analog to CAN interface , I use a AD7606 with a arduino mega.
Now I want to update to a teensy for some more processing capacity and of course the onboard CAN .
The problem is , I can not get the AD7606 to run on my Teensy
I tried with a 2nd one but also not running.
I have the feeling it is a SPI problem.
I use the following sketch to test :
I suppose I,m doing something wrong for a teensy ?
the same AD7606 and sketch is working with arduino Mega so I,m very certain the wiring is correct (SPI).
I had a pullup resistor over the Cs pin 10 .
The SPI seems to work as I have tested with a Max31855 on the SPI bus.
Regards Klass
I have a problem with my little project
In a small analog to CAN interface , I use a AD7606 with a arduino mega.
Now I want to update to a teensy for some more processing capacity and of course the onboard CAN .
The problem is , I can not get the AD7606 to run on my Teensy
I tried with a 2nd one but also not running.
I have the feeling it is a SPI problem.
I use the following sketch to test :
Code:
#include <SPI.h>
#define SCALE_FACTOR 0.000152587890625
// 10/(2^16) = 0.000152587890625
#define BUSY 3
#define RESET 4
#define START_CONVERSION 5
#define CHIP_SELECT 10
#define MISO 12
#define LED 13
#define TOTAL_RAW_BYTES 16
int bytesToRead = TOTAL_RAW_BYTES;
byte raw[TOTAL_RAW_BYTES];
signed long parsed[8];
void setup() {
pinMode(BUSY, INPUT);
pinMode(RESET, OUTPUT);
pinMode(LED, OUTPUT);
pinMode(START_CONVERSION, OUTPUT);
pinMode(MISO, INPUT);
Serial.begin(115200);
SPI.begin();
digitalWrite(START_CONVERSION, HIGH);
digitalWrite(CHIP_SELECT, HIGH);
digitalWrite(RESET, HIGH);
delay(1);
digitalWrite(RESET, LOW);
}
void loop() {
int i;
digitalWrite(START_CONVERSION, LOW);
delayMicroseconds(10);
digitalWrite(START_CONVERSION, HIGH);
while (digitalRead(BUSY) == HIGH) {
// wait for conversion to complete
}
digitalWrite(CHIP_SELECT, LOW);
while (bytesToRead > 0) {
raw[TOTAL_RAW_BYTES - bytesToRead] = SPI.transfer(0x00);
bytesToRead--;
}
digitalWrite(CHIP_SELECT, HIGH);
bytesToRead = TOTAL_RAW_BYTES;
parseRawBytes();
//Serial.write(raw, 16);
for(i=0; i<8; i++) {
Serial.print((float)parsed[i] * SCALE_FACTOR, 5);
Serial.print(",");
}
Serial.print("\r\n");
delay(1000);
}
void parseRawBytes() {
parsed[0] = (raw[0] << 8) + raw[1];
parsed[1] = (raw[2] << 8) + raw[3];
parsed[2] = (raw[4] << 8) + raw[5];
parsed[3] = (raw[6] << 8) + raw[7];
parsed[4] = (raw[8] << 8) + raw[9];
parsed[5] = (raw[10] << 8) + raw[11];
parsed[6] = (raw[12] << 8) + raw[13];
parsed[7] = (raw[14] << 8) + raw[15];
}
I suppose I,m doing something wrong for a teensy ?
the same AD7606 and sketch is working with arduino Mega so I,m very certain the wiring is correct (SPI).
I had a pullup resistor over the Cs pin 10 .
The SPI seems to work as I have tested with a Max31855 on the SPI bus.
Regards Klass