Mon May 19 19:40:09 EDT 2014


There doesn't seem to be a good way to handle hysteresis automatically
in the PIC except as a consequence of how to handle the code.  The
oscillator itself could actually just be driven completely in an
analog way, using a 1/3 - 2/3 Schmitt-trigger.

Then if necessary, the I/O can be reconfigured and drive the discharge

I believe the comparator output is even asynchronous:

   "... multiplexors in the output path of the RA4 and RA5 pins will
   switch and the output of each pin will be the unsynchronized output
   of the comparator."

Because of loading, it's probably necessary to buffer the output.
Trouble there is slew rate.  By the time the buffer catches up, the
saw will have discharged past the 1/3 mark.  Maybe best to take the
input of the comparator behind the opamp as well, so PIC knows the
buffered signal.

TI LM324N spec says 0.5 V/us so it will take about 4uS to ramp down.
I guess that's still plenty fast for audio but causes a 10% frequency
drop at 25kHz.  It can be made faster by lowering the threshold
voltage through playing with the resistor values.

EDIT: So it basically works, after placing an inverter in front of the
transistor to get the right polarity.  Could do this in the PIC but
both polarities are necessary, or a different resistor network needs
to be constructed.

So interrupt is working as well.  Nice to see the jitter from the
comparator output wrt a pulse sent out from the ISR.

EDIT: Works better using a non-inverting ST.