Thanks Darrel....I'll check it out later.
So here's the ludicrously simple 'get me up & running' setup I have (lifted/edited fromthe Microchip Tips' n trick sheet)
I put a sawtooth from a sig gen on the comparator input, but get nowt on the output
Now like I say, I always struggle with the registers - and even then, it's been a while - so try not to laugh...
Code:@MyConfig = _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON @MyConfig = MyConfig & _MCLRE_OFF DEFINE OSC 4 ' Internal 4MHz CMCON0 = %00000001 'CIN pins are configured as analog, COUT pin configured as Comparator output? ADCON0 = %00000000 'ADC disabled? ANSEL = %00001111 'All Analogue inputs enabled? TRISIO = %111011 'GPIO2 output (Comparator Out) ' PIN# NAME USE & CONNECTION ' 1 Vdd +5VDC power supply ' 2 GPIO.5 Debug Port (PicKit2 needs switching from here to pin Pin 7 to allow programming) ' 3 GPIO.4 ' 4 GPIO.3 ' 5 GPIO.2 Comparator Out (GP2) ' 6 GPIO.1 CIN- Signal In (GP1) ' 7 GPIO.0 CIN+ trigger level (GP0) ' 8 Vss Power supply ground '-------------------------------------------------------------------------
EDIT Ok, spotted it..
& here we have an output...Code:ANSEL = %00001011 'All Analogue inputs except AN2 enabled
Now...what to do with the output?!!!![]()






Bookmarks