📄 timer.c
字号:
#include "public.h"
//void timer0() interrupt 1 using 3 //50ms
void timer1() interrupt 3 using 2 //定时器1的中断服务程序入口为中断3
{
EA=0;
TH1=-20000/256;
TL1=-20000%256;
if(time_5sta_flg==0){
temp_state1=P1_0; //司机上状态
temp_state2=P1_2; //司机下状态
temp_state3=P1_4; //司机状态
temp_state4=P1_5; //直驶状态
temp_state5=P1_6; //保留状态
sum_state1+=temp_state1;
sum_state2+=temp_state2;
sum_state3+=temp_state3;
sum_state4+=temp_state4;
sum_state5+=temp_state5;
}
// if(((time_5sta_count--)==0)&&(time_5sta_flg==0)){
if(time_5sta_flg==0)
if((time_5sta_count--)==0){
time_5sta_flg=1;
time_5sta_count=TIMER_FILTER_NUM;
}
if(time_insel_flg==0){
//内选数据记录
if(time_insel_count==5){
array0[0]=XBYTE[((P2&0x60)|0x91)*256];
array0[1]=XBYTE[((P2&0x60)|0x92)*256];
array0[2]=XBYTE[((P2&0x60)|0x93)*256];
}else if(time_insel_count==4){
array1[0]=XBYTE[((P2&0x60)|0x91)*256];
array1[1]=XBYTE[((P2&0x60)|0x92)*256];
array1[2]=XBYTE[((P2&0x60)|0x93)*256];
}else if(time_insel_count==3){
array2[0]=XBYTE[((P2&0x60)|0x91)*256];
array2[1]=XBYTE[((P2&0x60)|0x92)*256];
array2[2]=XBYTE[((P2&0x60)|0x93)*256];
}else if(time_insel_count==2){
array3[0]=XBYTE[((P2&0x60)|0x91)*256];
array3[1]=XBYTE[((P2&0x60)|0x92)*256];
array3[2]=XBYTE[((P2&0x60)|0x93)*256];
}else if(time_insel_count==1){
array4[0]=XBYTE[((P2&0x60)|0x91)*256];
array4[1]=XBYTE[((P2&0x60)|0x92)*256];
array4[2]=XBYTE[((P2&0x60)|0x93)*256];
}
}
if(time_insel_flg==0)
if((time_insel_count--)==0){
time_insel_flg=1;
time_insel_count=TIMER_100ms;
}
//Can发送时用
// if(((time_500ms_count--)==0)&&(time_500ms_flg==0)){
if(time_500ms_flg==0)
if((time_500ms_count--)==0){
time_500ms_flg=1;
time_500ms_count=TIMER_500ms;
}
//到站钟延时
if(m_cArriveRingFlg==1){
// if(((time_arrive2s_count--)==0)&&(time_arrive2s_flg==0)){
if(time_arrive2s_flg==0)
if((time_arrive2s_count--)==0){
time_arrive2s_flg=1;
time_arrive2s_count=TIMER_2s;
}
}
//蜂鸣器间隔延时
if(m_cBingFlg==1){
if(time_bing2s_flg==0)
if((time_bing2s_count--)==0){
time_bing2s_flg=1;
time_bing2s_count=TIMER_2s;
}
}
if(((time_nocan_count--)==0)&&(time_nocan_flg==0)){
time_nocan_flg=1;
time_nocan_count=TIMER_5s;
}
EA=1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -