/* Project name:
Detect low voltage
* Description:
When voltage is detected LED blinks
* Test configuration:
MCU: PIC12F629
Dev.Board: EasyPIC4
Oscillator: 04.0000 MHz, Internal
SW: mikroC PRO for PIC
*/
unsigned char i;
bit oldstate; // Old state flag
void main() {
OSCCAL = 0b11111101; // calibrate internal osilator 4 MHz
CMCON = 0b00000100; // CIN- analog, Internal VRef
TRISIO = 0b00000010; // gp2 = output
VRCON = 0b10101111; // sets Vref
gpio.F2 = 0;
do {
if (CMCON.COUT == 1)
{
gpio.F2 = 1;
}
else
{
gpio.F2 = 0;
}
} while(1);
}