This commit is contained in:
parent
cc402ce4fa
commit
ad3786f699
1 changed files with 36 additions and 24 deletions
|
|
@ -9,51 +9,63 @@
|
|||
//Hardware is more reliable than DUE's noise immunity.
|
||||
//Note the MAX5387LAUD+ doesn't support I2C readback.
|
||||
|
||||
//detailed threshold calibration could be done, but our signal generator doesn't plug in very well.
|
||||
//using DAC would be a nice option for checking the thresholds.
|
||||
|
||||
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 ");
|
||||
pinMode(48, OUTPUT); //used to inject 3.3V signals if required with jumpers
|
||||
pinMode(49, OUTPUT); //used to inject as well
|
||||
pinMode(35, OUTPUT); //setup for the MAX5387 - later set to 0. signal PA0
|
||||
pinMode(36, OUTPUT);//setup for the MAX5387 - later set to 0. signal PA1
|
||||
pinMode(37, OUTPUT);//setup for the MAX5387 - later set to 0. signal PA2
|
||||
pinMode(A1, INPUT); //make sure the input pins are in high impedance mode
|
||||
pinMode(A2, INPUT);//make sure the input pins are in high impedance mode
|
||||
digitalWrite(35, LOW);//configure the address of the MAX5387 pot
|
||||
digitalWrite(36, LOW);//configure the address of the MAX5387 pot
|
||||
digitalWrite(37, LOW);//configure the address of the MAX5387 pot
|
||||
//pinMode(38, INPUT); //optional high impedance mode for strigA - note forcing signal high doesn't really work.
|
||||
//pinMode(39, INPUT);//optional high impedance mode for strigB - note forcing signal high doesn't really work.
|
||||
pinMode(5, INPUT); //set the interrupt pin for trigger as high impedance, probably not required
|
||||
attachInterrupt(38, striga, RISING); //interrupt on STRIGA
|
||||
attachInterrupt(39, strigb, RISING); //interrupt on STRIGB
|
||||
attachInterrupt(5, realint, RISING); //interrupt on the real trigger - note rising,
|
||||
|
||||
//setup the serial for debug
|
||||
Serial.begin(9600);
|
||||
//setup the MAX5387 pot
|
||||
Wire.begin();
|
||||
Serial.print("MAX5387 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);
|
||||
Serial.println("threshold set to 0x50"); //note that this is manually updated by the human!
|
||||
}
|
||||
|
||||
//interrupt routine for event on STRIGA signal (channel A high)
|
||||
void striga(){
|
||||
Serial.print("a");
|
||||
}
|
||||
|
||||
//interrupt routine for event on STRIGB signal (channel B high)
|
||||
void strigb(){
|
||||
Serial.println("b");
|
||||
}
|
||||
|
||||
//interrupt routine for event on TRIG signal (AND output high)
|
||||
void realint(){
|
||||
Serial.println("real");
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
//delay(100);
|
||||
//nothing to do here at the moment.
|
||||
//delay(100);
|
||||
|
||||
//digitalWrite(48, HIGH);
|
||||
//digitalWrite(48, HIGH); //3.3v signal injections via pins 48 and 49 if required.
|
||||
//digitalWrite(49, HIGH);
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue