Skip to content

Instantly share code, notes, and snippets.

@Ryanhu1015
Last active February 1, 2019 17:47
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/71bba740bfab96de818b03117d43f3df to your computer and use it in GitHub Desktop.
Save Ryanhu1015/71bba740bfab96de818b03117d43f3df to your computer and use it in GitHub Desktop.
embedded rookie
#define Button1_SW1 P3_2 // P3_2 is one of the input button pin
unsigned int button1_time_cnt; //global variable
void Timer0ISR (void) interrupt 1 // trigger per 1 ms
{
TF0 = 0; // Clear Timer0 interrupt
TH0 = (65536-t0hrel)>>8; // Reload Timer0 high byte,low byte
TL0 = 65536-t0hrel;
button1_time_cnt <<= 1 ;
button1_time_cnt |= Button1_SW1;
//there are also lots of functions below
//just skip that part...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment