63 lines
No EOL
1.7 KiB
Text
63 lines
No EOL
1.7 KiB
Text
#include <Wire.h>
|
|
|
|
//this test works when testing with boards 1 and 2
|
|
//set the threshold as a 1 time value, max is 3.3V (voltage reference removed from protos)
|
|
//crashes due to 50Hz noise
|
|
//input thresholds not checked 100%
|
|
//minimum input signal duration 40ns for coincidence.
|
|
//at 40ns incident coincidence the output lasts for 150ns - plenty for the DUE to capture.
|
|
//Hardware is more reliable than DUE's noise immunity.
|
|
//Note the MAX5387LAUD+ doesn't support I2C readback.
|
|
|
|
void setup() {
|
|
// put your setup code here, to run once:
|
|
pinMode(48, OUTPUT);
|
|
pinMode(49, OUTPUT);
|
|
pinMode(35, OUTPUT);
|
|
pinMode(36, OUTPUT);
|
|
pinMode(37, OUTPUT);
|
|
pinMode(A1, INPUT);
|
|
pinMode(A2, INPUT);
|
|
digitalWrite(35, LOW);
|
|
digitalWrite(36, LOW);
|
|
digitalWrite(37, LOW);
|
|
//pinMode(38, INPUT);
|
|
//pinMode(39, INPUT);
|
|
pinMode(5, INPUT);
|
|
attachInterrupt(38, striga, RISING);
|
|
attachInterrupt(39, strigb, RISING);
|
|
attachInterrupt(5, realint, RISING);
|
|
Wire.begin();
|
|
Serial.begin(9600);
|
|
Serial.print("Address ");
|
|
Serial.print(0x28, HEX);
|
|
Wire.beginTransmission(byte(0x28)); // transmit to device #112
|
|
Wire.write(byte(B00010011));
|
|
Wire.write(byte(0x50));// sets register pointer to echo #1 register (0x02)
|
|
Wire.endTransmission(); // stop transmitting
|
|
Serial.println("threshold set to 0x80");
|
|
//digitalWrite(48, HIGH);
|
|
//digitalWrite(49, HIGH);
|
|
}
|
|
|
|
void striga(){
|
|
Serial.print("a");
|
|
}
|
|
void strigb(){
|
|
Serial.println("b");
|
|
}
|
|
void realint(){
|
|
Serial.println("real");
|
|
}
|
|
void loop() {
|
|
// put your main code here, to run repeatedly:
|
|
//delay(100);
|
|
|
|
//digitalWrite(48, HIGH);
|
|
//digitalWrite(49, HIGH);
|
|
|
|
|
|
//digitalWrite(48, LOW);
|
|
//digitalWrite(49, LOW);
|
|
//delay(1000);
|
|
} |