I think I got what you mean. Heres a rough thought process
(master)
-pulse(toggle) digital pin fast when time to sync
-save the current time of pulse
(slave)
-setup isr to monitor digitalpin
-turn on isr before we need to sync (I don't like idea of the isr constantly being called and watching pin while recording adc)
-if isr digitalpin== high, grab slaves current time
-request masters time ,which is start of pulse
-calculate offset, set slaves time according to offset
isr()
-if digitalpin read fast ==high -> flip a bool to notify syncing is starting
So if:
-after requesting a sync
-master time equals 13:00:50
-slave time = 13:00:52
-offset = 2 sec
-set: slave time = slave time - offset
Something like this? If I understand correctly
int my_time;
void SetTime() {
my_time = micros();
}
void setup() {
attachInterrupt(isr_pin, SetTime, RISING);
}
volatile bool collect_data = false;
void Daq() {
collect_data = true;
}
void setup() {
attachInterrupt(sync_pin, Daq, RISING);
}
void loop() {
if (collect_data) {
/* Reset the flag */
collect_data = false;
/* Do the analog read, etc */
}
}
Hrm....I think, just request the time when pulse occurred after recording, this way both teensys record at nearly same time, and after this ,take my time to ask Master for time when pulse happened.
By part of , do you mean physically connecting I2C to both teensy 3.5's? If so yes,for now, but I can't seem to get i2c_t3.h to run basic master/slave example properly.Master sends data but slave never receives,and both have external pullup resistors 4.7k,I've tried 2k-5.5k, I think I might start a new thread for this,if can't get it going after further testing.Same issue with wire.h....im overlooking something.
But I do like having options such as UART,this sounds doable as well. Ill have to test and play around for abit,but thank you all for more then one way to solve it. I couldn't of asked for better peeps to reply.