hello, newbie question (I have searched google + arduino forums but do't understand the responses, and am stuck).
Can someone please explain the use of attachInterrupt
, especially with regards to the ISR within a library. I have tried various things, and keep having errors of various flavours being provided, thanks in advance.
basically I am trying to write a class to enable various pins on the Arduino DUE
, and within which I have tried to setup interrupts to call a few ISR's when the interrupts occur.
I am basically trying to calculate the time elapsed between pulses from a variable reluctance sensor (via an LM1815)
I have tried a few different variants now, but the code within the class is essentially the following:
attachInterrupt(_1VRSenPin, Update1VR, CHANGE);
the code within the ISR function is essentially:
TimeNow = micros();
if( TimeNow > 1VRSenTimeOld)
1VRSenDT = TimeNow - 1VRSenTimeOld ;
1VRSenTimeOld = TimeNow;
1VRSenTimeOld = TimeNow; // if you're wondering this is the one way I thought
// I could deal with timer micros() overflow, given I don't expect much variance
// from one VR pulse to the next because of inertia in the object I'm measuring.
Can someone please explain to a newbie the use of the ISR function within a library?
I've looked at a few libraries that contain interrupts now and just cannot seem to understand the ISR bit, I've tried it as it's function within the library and within the class and I'm still having errors thrown up.