I need to catch an event lasting on average, about 20 to 30 nanoseconds and I'm not sure the best way to do it.
The device is 16F677
I think I can use Interrupt On Change, or possibly the Capture / Compare / PWM module.
The 677 doesn't have the CCP1 function, and use of the CCP also requires use of Timer1, which in my application will be busy with another task. It could be reconfigured, but I'd really like to avoid using this route if at all possible.
I'd like to use the IOC route but I've got questions...
- It sounds as if the change event happens during an active pin read cycle in the execution. As the duration is so short compared to the clock cycle time (I'm running at 20Mhz, external resonator) - the event could easily be missed between reads.... or is this setting of the interrupt flag something that happens almost "analog" - where a sort of switch is tripped which will be discovered on the next read - so in theory, an exceptionally short event - maybe 1nS even would still trip the IOC. Is this true, or do we need to assume the change lasts for multiple clock cycles?
- The same with the comparator - I do have all those pins open to use, and I know a change in the state of the comparator can trigger interrupts or set other flags.... as the comparator runs essentially free of the clock timing... could I just compare it to the internal voltage, which would cause the comparator to read opposite during the transient spike event?
... or is there another method that's better?
Thanks!!
Bookmarks