PDA

View Full Version : Comparators on 18F4520



RacerX10
- 27th August 2009, 21:13
I'm just doing a little experimenting and would like to test out the comparators on an 18F4520.

I don't need an interrupt or a internal reference voltage, I just want a zero-crossing-detector on comparator 2 and be able to view the results on my o-scope.

I'm starting to wonder if the comparator 2 output is even available on a pic pin ? It's labeled C2OUT, and the datasheet shows RA5 as C2OUT, but I'm not seeing any action on that pin.

The circuit :

http://www.rtach.com/pics/comparatorcircuit.png

The input / output (this is what I'm reading on the PIC pin RA1 and output on RA5)

http://www.rtach.com/pics/scope.jpg

Thanks .. please convey if you have any idea why I'm not seeing a nice square wave on RA5 of the pic !

RacerX10
- 27th August 2009, 23:33
Ok it's fixed, info for the archives :

I had set the comparator mode wrong. 010 is "two independent comparators". 011 is "two independent comparators WITH OUTPUTS"

I have no idea how I overlooked that for 2 full days.

<sigh>