internal interrupt

Status
Not open for further replies.

tsitze

New member
Hey all, I was wondering how to correctly use an interrupt in my code to act as a shutdown function in case of a redline event. This is my first time using a Teensy and I'm not super familiar with implementing interrupts.
My research leads me to believe that interrupts only attach to a pin which enables at say a button press. However, I need an interrupt that will watch an array of values and trigger in the case of say the mean of those values being above a certain threshold. In this case the array is storing pressure values measured at every 10 or so milliseconds.

Maybe I'm going down the wrong rabbit hole and interrupts aren't the thing to use but I couldn't find any nice easy ways to run a watcher function in parallel with the rest of the system. Currently we have a bunch of calls to the watcher function hard coded after every step but it would be so much easier if there was a way to 'multi thread'? am I using that right?
 
Maybe I'm misunderstanding, but isn't IntervalTimer not just a timer which calls the function every x seconds? I'm hoping for something that won't interrupt except when the conditions are met.
 
Hi @tsitze, I might have picked you up wrongly but I thought you want to run a function, at an interval to check your array with some sort of watcher function.
If watcher identifies something wrong (conditions met) then take action to recover. cheers Paul
 
Based on the OP … Seems a borderline issue for a clean solution - not sure interrupt is the answer if data is read at some 'TIME' - and that data can indicate a time critical issue - it should be checked and confirmed at that 'TIME'.

If there were some element not controlled by user data - like the CPU temp - having an automated interrupt check like there is makes sense.

Here it seems that data is read or parsed/interpreted in one or more places under user/program control.

If that has to be done in multiple places then would be best to perform a call to 'panicCheck()' function at each of those points where some way to validate if a problem exists and some action needs to be taken.

However the data read/updated about every 10ms - so calling that function to work may be trivial - or it may be onerous? If it is onerous - that is not trivial perhaps the post #2 IntervalTimer solution checking every 50ms or whatever is fast enough prevent harm and respond in a timely fashion would prevent calling it 2 or 10 times from multiple places every few ms. The problem with checking on an interrupt is that data may be in transition as the interrupt occurs and a false decision could be made if some of the latest updated data conflicts with data not yet updated in the array/data being checked.
 
Status
Not open for further replies.
Back
Top