📄 timer.c
字号:
//-----------------------------------------------------------------------------
// timer.c
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
// Includes
//-----------------------------------------------------------------------------
#include <reg52.h>
#include "main/main.h"
#include "cpu/cpu.h"
#include "misc/general.h"
//-----------------------------------------------------------------------------
// Timer0 Interrupt Routine
//-----------------------------------------------------------------------------
void Timer0_ISR (void) interrupt 1
{
static char fiftyms = 0;
static char ones = 0;
static char threes = 0;
static char sixs = 0;
TR0 = 0;
Task0 = 1; // 50ms
cpu_LED = OFF;
if ( ++fiftyms == 20 )
{
fiftyms = 0;
Task1 = 1; // 1s
cpu_LED = ON;
if ( ++ones == 3 )
{
ones = 0;
Task2 = 1; // 3s
if ( ++threes == 2 )
{
threes = 0;
Task3 = 1; // 6s
if ( ++sixs == 100 )
{
sixs = 0;
Task4 = 1; // 10min
}
}
}
}
TH0 = MSBYTE( TIMER0_CLICK ); // set Timer0 overflow in 10ms
TL0 = LSBYTE( TIMER0_CLICK );
TR0 = 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -