Search code examples
cembeddedpicxc8

Properly shutting off ADC on PIC12F675


I am trying to port some simple digital IO code from a CCS compiler to XC8.

The MCU is PIC12F675.

XC8 does not have peripheral libraries for 12 series.

I have managed to configure it, set clock etc.

I can't seem to use pins 0-3 as digital IO by default.

I think it is because of the ADC configuration but it might be any of the parameters below.

Can someone help me write this CCS code to XC8?

   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_comparator(NC_NC);
   setup_vref(FALSE);  

Thanks in advance.


Solution

  • I managed to do it, now it seems to work properly:

    ANSEL = 0x00;
    ADCON0 = 0x00;
    CMCON = 0x07;
    VRCON = 0x00;
    TRISIO = 0x2F; //or whatever your config
    GPIO = 0x00;
    

    There was no need to set timers in order for digital GPIO to work.