Created
August 27, 2018 10:27
-
-
Save Ryanhu1015/1a60a19b6231d3f0fc76b85c537bb085 to your computer and use it in GitHub Desktop.
embedded rookie
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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