Lots of ideas here.
In dealing with interrupts over the years on varying platforms, I've run into something I call the nagging interrupt. The interrupt occurs and if you don't clear it before doing the return from interrupt it will continue to occur.
When you set a watch on a pin, does a change on the pin create an interrupt? In the routine that queues the watch do you clear the interrupt bit for the pin?
Here is an outline subject to everyone's revisions;
SetWatch(User,function(),{IVectoraddress,IRegisteraddress,bitnum,bitval 0 or 1})
This would save the old address at the IVectoraddress in the interrupt table,
then insert the Watch action address into the table.
The watch action and queue code:
When the interrupt occurs the IResgisteraddress is used along with the bitnum and bitval to clear the interrupt. The event is queued along with the function to call.
When ClearWatch is called the old address would be restored to the interrupt table
As far as the external wire method between the OTpulse timer and the counting timer in gate mode, I think that works as far as the timers are concerned but I will have to see if the setWatch still works in that setup. The OTpulse pin is setup as an output. The gated timer gate would be an input. I'm a couple of steps from being able to try that in the timer thread.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Lots of ideas here.
In dealing with interrupts over the years on varying platforms, I've run into something I call the nagging interrupt. The interrupt occurs and if you don't clear it before doing the return from interrupt it will continue to occur.
When you set a watch on a pin, does a change on the pin create an interrupt? In the routine that queues the watch do you clear the interrupt bit for the pin?
Here is an outline subject to everyone's revisions;
SetWatch(User,function(),{IVectoraddress,IRegisteraddress,bitnum,bitval 0 or 1})
This would save the old address at the IVectoraddress in the interrupt table,
then insert the Watch action address into the table.
The watch action and queue code:
When the interrupt occurs the IResgisteraddress is used along with the bitnum and bitval to clear the interrupt. The event is queued along with the function to call.
When ClearWatch is called the old address would be restored to the interrupt table
As far as the external wire method between the OTpulse timer and the counting timer in gate mode, I think that works as far as the timers are concerned but I will have to see if the setWatch still works in that setup. The OTpulse pin is setup as an output. The gated timer gate would be an input. I'm a couple of steps from being able to try that in the timer thread.