2camjohn
Member
I had my 16f82a (edit 16f628 thanks Exo) set up with an external comparator.
Now I want to use the internal comparator to save space, the problem is I had all my inputs using port B and my outputs using port A.
From reading the datasheet the comparator can only be used on pins RA0 - 3
I am using interrupts from port b.0
Im really confused as to how to set up my inputs and outputs:
Here is what I want io wise:
18 RA1,AN1 - Output - solenoid driven by transistor
1 Vref,AN2,RA2 Comparator reference voltage (from pot)
2 CMP1,AN3,RA3 Comparator non inverting input (ie when this value is above reference the output is 1)
6 INT,RB0 Interrupt trigger
7 RX,DT,RB1 Output - led
8 TX,CK,RB2 Output - led
Util now I have been able to configure the outputs just by saying all portA is an output (TRISA = 0x00) but now it has suddenly got alot more complicated.
Can someone explain how to set this up, or better yet give me the code to do it as I am pretty confused.
Also how do I access the output of the comparator (i know this is in the datasheet but they are quite hard to comprehend in places)
Thanks in advance for your time,
John
Now I want to use the internal comparator to save space, the problem is I had all my inputs using port B and my outputs using port A.
From reading the datasheet the comparator can only be used on pins RA0 - 3
I am using interrupts from port b.0
Im really confused as to how to set up my inputs and outputs:
Here is what I want io wise:
18 RA1,AN1 - Output - solenoid driven by transistor
1 Vref,AN2,RA2 Comparator reference voltage (from pot)
2 CMP1,AN3,RA3 Comparator non inverting input (ie when this value is above reference the output is 1)
6 INT,RB0 Interrupt trigger
7 RX,DT,RB1 Output - led
8 TX,CK,RB2 Output - led
Util now I have been able to configure the outputs just by saying all portA is an output (TRISA = 0x00) but now it has suddenly got alot more complicated.
Can someone explain how to set this up, or better yet give me the code to do it as I am pretty confused.
Also how do I access the output of the comparator (i know this is in the datasheet but they are quite hard to comprehend in places)
Thanks in advance for your time,
John