Hi - I am new in programming PIC device and I have a project where I need to use one of the two Comparators in PIC16F887
I have read the datasheet several time but is still unsure about setting up the port - hope someone can come with an solution.
in my project I use tree 7 segment display so I use interrupt to make them work and its works fine.
I do not know for sure if this gives problem for my comparator!?
(I use Pascal as my sw)
- interrupt setup:
Procedure interrupt;
begin
PORTB := 0;
PORTD := ciffer[v] + blink_on;
PORTB := zz; // turn on appropriate 7seg. display
v := v + 1;
zz := zz shr 1;
if zz = 16 then zz := 128; // 4 // prepare mask for digit
if v > 2 then v := 0; // 3 disp. // turn on 1st, turn off 2nd 7seg.
TMR0 := 0;
INTCON := $20;
end;
and my setup for the comparator:
ANSELH := 0;
// setup Port A :
TRISA :=%11011111; // input execp bit A5 - used for output for comparator
ANSEL :=%00001001; // bit A0 and A3 analog = input for comparator
CM1CON0 :=%11100000; // Comparator C1 enabled
SRCON :=%00000000; // no latch enabled
VRCON :=%00100000; // no v ref. enabled
this is the correct setting for comparator as best I know - but not sure because it not work.
here is the code where I retrieve the output
If portA.5=1 then ...
Can any help ? - do I need to do something for getting the the output
Best regards Erik Nielsen, Denmark.
Bookmarks