Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

CMCON0 and ANSEL registers

HighTechPower

Member level 2
Joined
Jul 10, 2020
Messages
52
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
425
Hi. Recently I designed a circuit with PIC12F683. It's pins not working properly until I declare CMCON0 register although I'm not using it's internal comparator. Is it not true that to declare pins as digital or analog I have to use either CMCON0 or ANSEL register and not both. However when I omit the CMCON0 line in code below then circuit does not work properly (e.g. POWER_GOOD pin does not go high). I'm using ADC that is why I have declared ANSEL register.
Code:
#define POWER_GOOD GP0

void init_micro (void)
{
    OSCCON = 0b01100111;
    TRISIO = 0b00001010;
    CMCON0 = CMCON0 | 0b00000100;
    ANSEL = 0b01010010;
    GPIO = 0b00000000;
    POWER_GOOD = TRUE;
    __delay_ms(100);
}
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
48,383
Helped
14,245
Reputation
28,751
Reaction score
12,932
Trophy points
1,393
Location
Bochum, Germany
Activity points
280,027
Is it not true that to declare pins as digital or analog I have to use either CMCON0 or ANSEL register and not both.
To use a GPIO as digital input, both ANSx and respective comparator function have to be disabled. In case of GP0, digital output function doesn't depend on CMCON0 and ANSEL setting, it does however for GP2. Regarding your findings, either you confused GP0 with GP2, or the datasheet is incorrect.
 

LaTeX Commands Quick-Menu:

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top