Skip to content

Instantly share code, notes, and snippets.

@Ryanhu1015
Last active October 20, 2018 15:12
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/db9c5b1a9fa17e3254a4b8de9319d041 to your computer and use it in GitHub Desktop.
Save Ryanhu1015/db9c5b1a9fa17e3254a4b8de9319d041 to your computer and use it in GitHub Desktop.
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