Hello all,
I have a simple question that deals with programming a PIC 12F675 micro controller using C.
A little background: I have a comparator circuit in front of the PIC chip supplying either about 1.8V or 0V. These levels are supposed to act as either 'logic high' or 'logic low'.
Basically I want the chip to read the logic high at an input and fire off 2 logic high signals at 2 separate outputs. If the chip reads a logic low, I want it to do nothing.
I wanted to set a threshold level at 1.8V so the chip would interpret this or anything higher as 'logic high' since i can't get the full 5V to it. If the chip sees anything less than 1.8V, I want it to be considered logic low.
My previous approach was to use the A2D converter built into the chip. The number 96 comes from the 1:64 prescalar and is supposed to represent 1.8V.
I know this is simple and I may be way off. Any help is much appreciated!!!!!!!!!
.................................................. .................................................. ..............
#include <pic.h>
__CONFIG(UNPROTECT & BORDIS & MCLRDIS & PWRTEN & WDTDIS & INTIO);
main()
{
CMCON = 0b0000011; // Disable comparator
ANSEL = 0b00111000; // Enable ADC
ADCON0 = 0b00000001; // Turn on AD Control Register
OPTION = 0b10000101; // Configure TMR0 with 1:64 prescalar
TRISIO = 0b00111100; // Configure GP1 as ADC output
// Configure GP0 as LED output
// Configure GP4 as ADC input signal
GPIO1=0; // Initially set ADC output low
GPIO0=0; // Initially turn the LED off
while(1)
{
while(ADRESH<96)
{
NOP();
}
while(ADRESH>96)
{
GPIO1=1;
GPIO0=1;
}
}
}