Sat May 17 13:27:06 EDT 2014

Comparator + software discharge

The path with least external components is the software reset path.
The way to go here is to make the ISR fast such that the time from
interrupt -> discharge is fast.

Note that comparator can still be routed out for use in analog

A simple way might be to preset LAT to 0 and switch the comparator
input pin to digital out using one or two bit set instructions, e.g:

TRIS <- 0
save timer
clear interrupt bits
TRIS <- 1

This requires the input to be unbuffered, so the 500nA leakage current
becomes important.

From the pov of response it doesn't seem faster then just setting a
dedicated discharge pin.

LAT <- 1 to start discharge
switch comparator reference
save timer
clear COMP IF
wait for full discharge (2nd comparator?)
switch comparator reference
LAT <- 0

Reference settling time becomes important.  Response time is 400ns
max, 150ns typ.  At 12MHz cycle an instruction is 83ns, so 5 cycles
should be enough.

What is R_ON for the output drivers?  Essentially we just need to
pulse it long enough.  Might need to just try it.

So in principle, this is the approach:
- Comparator triggers -> start discharge
- Do bookkeeping
- Add fixed delay if necessary
- wait for comparator output to settle