Waitpne for an external IRQ can you timeout with Counter Duty?
tonyp12
Posts: 1,951
What is known, a Cog uses the actual electrical state of the pin when reading INA.
What I need:
Cog sleeps but wakes up every 100mS to run a quick SPI-read-routine, but if the external device pulls IRQ low I need to do the SPI-read-routine asap.
Could I simulate a IRQ ever 100mS by having a Counter pulling (internally) this pin low even though DIRA is set a input?
I don't want to waste any Prop pins by running external pins to each other.
What could I do, as waitcnt and waitpne don't mix well.
What I need:
Cog sleeps but wakes up every 100mS to run a quick SPI-read-routine, but if the external device pulls IRQ low I need to do the SPI-read-routine asap.
Could I simulate a IRQ ever 100mS by having a Counter pulling (internally) this pin low even though DIRA is set a input?
I don't want to waste any Prop pins by running external pins to each other.
What could I do, as waitcnt and waitpne don't mix well.
Comments
I assume power consumption is an issue, since you said you want the cog to sleep. If it is not, you could use a tight loop reading INA that also checks if the time has passed 100 ms. You would need to check if your latency is compatible with the time that your external device pulls the IRQ pin low.
If power consumption is an issue but you have an extra cog, you could waitcnt with it, but instead of pulling the pin low with OUTA, make DIRA high (with OUTA low) for a brief time every 100 ms. This would allow the external device to pull it low for the IRQ when it needs to, and would leave both cogs sleeping most of the time.
As INA, Waitpne and Counters all use the actual electrical state if pin there is no way that the cog could exit a waitpne by having its counter toggle the pin as it of course have to remain an input.
A second cog cogs counter could not do it either as if it sets that as an output, that pin is now no longer an "true" input for any cog.
Wasting an Prop pin that externally with a mosfet pulls the line low could work, or keep polling INA at 50uS intervals and at least got some sleep in there.
If you don't need interval timing, but just a way to signal the other cog
Have another cog use DIRA to force a state as to signal the other cog that is locked in a Waitpne state,
Should use a series resistor unless the IRQ line is open drain in the first place.
It works fine with both sync time and a switch.
My switch is active high, so change it, if it is active low.
If you are using the EEPROM pins only for loading, then you may be able to 'borrow' SDA as the signaling pin,
or dual-purpose some other pin ?
So if your counter hits SDA will change and if your external sensor changes your input pin will change.
Enjoy!
Mike