📄 cpu.c
字号:
#include"inc/config.h"
BOOL f_15ms ;
BOOL f_500ms ;
BOOL f_1s ;
BOOL f_5s ;
BOOL f_60s ;
u08 SYS_ch ;
u08 AlrmStatusT ;
u08 AlrmStatusH ;
u08 Humidity ;
int16 Temperature ;
BOOL f_sensor_t ; //温度传感器不存在
BOOL f_sensor_h ;
u08 RelayBreak ;
u08 SystemStatus;
u08 SystemMode =AUTO_TH ;
/*******************system time base *****************************/
#define _CPU_C 1
BOOL f_15ms =false; //time base
BOOL f_500ms =false; //time base
BOOL f_1s =false;
BOOL f_5s =false;
BOOL f_60s =false;
//*****************************************************************//
//functionname: void TimerInit(void);
//purpose: initialize timer by user
//input:
//output
//call:
//becalled;
//date: 2006.04.13
//created:
//*******************************************************************
void TimerInit(void)
{
/*t0 initailize*/
/*
TCCR0 = 0x00; //stop
//TCCR0 |= (1<<CS02)|(1<<CS00); //1024 div
TCCR0 = (1<<CS02); //256 div
TCNT0 = TIMER0_BGN_VAL;
TIMSK |=(1<<TOIE0); */ //enable the t0 overflow intterrupt
/*t2 intialize*/
/* */
TCCR2 = 0x00;
TCCR2 = (1<<CS22)|(1<<CS21); // T2 256分频工作
TIMSK |= (1<<TOIE2); //enable the t0 overflow intterrupt
TCNT2 = TIMER2_BGN_VAL ;
/*t0 as an counter ,count the pulse on t0 pin*/
TCCR0 = 0x00;
TCCR0 |= (1<<CS02)|(1<<CS01)|(1<<CS00);//外部上升边沿
TCNT0 = 0 ;
/*TIMER1**/
TCCR1B =0X00;
TCCR1B =(1<<CS11);//8M8FENGPIN
TIMSK |= (1<<TOIE1); //enable the t0 overflow intterrupt
TCNT1 =(65536-20000);//20MS 定时
}
void timer0_start(void)
{
TCCR0 |= (1<<CS02)|(1<<CS01)|(1<<CS00);//外部上升边沿
TCNT0 = 0 ;
}
void timer0_stop(void)
{
TCCR0 =0x00;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -