Skip to content

Instantly share code, notes, and snippets.

@Ryanhu1015 Ryanhu1015/adc_test_2.c
Last active Oct 20, 2018

Embed
What would you like to do?
embedded rookie
unsigned short ADCbuffer;
unsigned short wc_DelayTimeOutCounter;
//skip the functions prototypes
void main(){
//initiate hardware
//..
//..
while(1){
if(wc_DelayTimeOutCounter==100){ // grab the value per second
ADCbuffer = (ADB<<4) + (ADR&0x0F);
txsenddata(ADCbuffer);
ADM &= 0xDF;//clear EOC bit to 0
ADM |= 0x40;//cause after conversion, ADS bit will automatically change into 0
wc_DelayTimeOutCounter=0;
}
}
void Timer0_ISR(void) interrupt ISRTimer0 {
TH0=0x97;// 10 millis per cycle
TL0=0xD5;
wc_DelayTimeOutCounter++;
//skip the part below
//..
//..
}
void txsenddate(short da){
//skip this part
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.