Skip to content

Instantly share code, notes, and snippets.

@Ryanhu1015
Created October 20, 2018 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ryanhu1015/de9a54c8c73baa6523ac36a63939983b to your computer and use it in GitHub Desktop.
Save Ryanhu1015/de9a54c8c73baa6523ac36a63939983b to your computer and use it in GitHub Desktop.
embedded rookie
void ADC_Init(void);
void ADC_Init(){
P0M=0x38;// set I/O as input/output mode
P0CON |= 0x02;//let P01 as a pure analog pin
P0UR=0;// disable the pull-high
ADM=0x81;// enable ADC function, and use AIN1
ADR=0x60;// enable AIN channel, and set clock rate = fosc/1
VREFH=0x04;// ADC internal reference high voltage -> VDD
IEN0 |= 0x80;// enable global interrupt
//IEN2 |= 0x01;//ADC interrupt enable
ADM |= 0x40;//start ADC conversion
}
void ADC_ISR(void) interrupt ISRAdc{}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment