hello, i have configured the comparator register but i have no ideas of how to read the input and output. my program is below
#include <system.h>
#include "RF transmitter.h"
void setup_hardware (void)
{
/* set all of PORTB for output */
trisb = 0x00 ;
/* bits 0-2 of PORTA for input and bit 3 of portA for output which is C1OUT */
trisa = 0x05;
/* Just A0 and A3 ( comparator voltage reference) in analogue mode */
ansel = 0x05 ;
portb=0x00;
cmcon = 0x46;
}
void main ( void )
{
int v;
setup_hardware () ;
while (1) {
what should be here ?????????????????????????????? }
}
problem of using comarator in 16f88
-
- Posts: 7
- Joined: Fri Nov 26, 2010 6:45 pm
- Contact:
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: problem of using comarator in 16f88
Hello,
To read the output from each comparator module you can use the following C code.
Code:
char compA;
char compB;
compA = (cmcon & 0x40) >> 6;
compB = (cmcon & 0x80) >> 7;
To read the output from each comparator module you can use the following C code.
Code:
char compA;
char compB;
compA = (cmcon & 0x40) >> 6;
compB = (cmcon & 0x80) >> 7;
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: problem of using comarator in 16f88
With the way you have setup the comparators it looks like you may also be able to read the comparator output by reading input pins RA3 and RA4.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel