0 Members and 1 Guest are viewing this topic.
#pragma config FOSC = INTOSC#include <xc.h>void main(){ OPTION_REG = 0b00000011; OSCCON = 0b01111010; TRISC = 0x00; PORTC = 0x00; TRISA = 0xFF; while(1) { CLRWDT(); if(PORTAbits.RA4) PORTC = 0xFF; else PORTC = 0x00; } }
1.1.6 ANALOG CONTROLThe ANSELA register (Register 11-4) is used toconfigure the Input mode of an I/O pin to analog.Setting the appropriate ANSELA bit high will cause alldigital reads on the pin to be read as ‘0’ and allowanalog functions on the pin to operate correctly.
REGISTER 11-4: ANSELA: PORTA ANALOG SELECT REGISTERU-0 U-0 U-0 R/W-1/1 U-0 R/W-1/1 R/W-1/1 R/W-1/1