Skip to content

Instantly share code, notes, and snippets.

@Ryanhu1015
Created August 27, 2018 10:27
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/1a60a19b6231d3f0fc76b85c537bb085 to your computer and use it in GitHub Desktop.
Save Ryanhu1015/1a60a19b6231d3f0fc76b85c537bb085 to your computer and use it in GitHub Desktop.
embedded rookie
#include <stdio.h>
#include <SN8F5701.H>
//variable
int count_millis=0;
uint8_t count_sec=0;
uint8_t count_min=0;
//prototype of functions
void Timer0_Init(void);
void main(){
Timer0_Init();
while(1){
//just like the "loop" function in Arduino
}
}
void Timer0_Init(){
/* this is for 10 millisecs per cycle
TH0=0x97;
TL0=0xD5;
*/
// this if for 1 millisec per cycle
TH0=0xF5;
TL0=0x95;
//...still lots of setting below
}
void Timer0_ISR(void) interrupt ISRTimer0{
count_millis++;
if(count_millis==1000){
count_sec++;
count_millis=0;
}
if(count_sec==60){
count_min++;
count_sec=0;
}
//.. clear the value of "count_min" if needed
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment