//when airbag use ,airbag output pulse width is 220ms
//编写人:马立平
//时间:2007年11月22日
//内容:airbag、ABS25km/h和ABS15km/h开关输入时,输出为airbag和abs方波。
#include <pic.h>
#define MMMMA RA0
#define MMMMB RA1
#define MMMMC RA2
#define MMMMD RA4
#define MMMME RA3
#define MMMMF RA5
bit airbag_fg;
bit airbag_high_fg;
bit abs_25kmh_fg;
bit abs_15kmh_fg;
bit abs_high_fg;
bit switch_lock_fg;
bit abs_out_fg;
bit airbag_out_fg;
bit abs_fg1;
bit abs_fg2;
unsigned int abs_15kmh_ram;
unsigned int abs_25kmh_ram;
unsigned int airbag_ram;//set airbag input delay time
unsigned int abs_out_ram; //set horn output time
unsigned int airbag_out_ram;
unsigned int value_ram;//delay ram
unsigned int value;//DELAY input
unsigned int absrammm;//DELAY input
unsigned int airrammm;//DELAY input
//io口定义
void io(void)
{
TRISA=0XFF;//0011 1111
PORTA=0x00;
TRISB=0X00;
PORTB=0x00;
TRISC=0X00;//0000 0011
PORTC=0X00;
ADCON1=0X06;
// IOCA=0;//ra INTERRUPT DISABLE
// WPUA=0;//PulL UP disable
// INTCON=0;
// PIR1=0;
// PIE1=0;
}
//++++++++++++++++++++//io口定义
void tmr1_initialization()
{
T1CON=0x30;//1:8分频
TMR1H=0;
TMR1L=0;
INTCON=0;
PIE1=0;//关闭中断允许位及中断标志
PIR1=0;//关闭中断允许位及中断标志
}
//TIME0延时测试函数
void times_delay(value)
{
while(value_ram<value)
{ value_ram++;
while(TMR0<=194)//50MS
{CLRWDT();}
TMR0=0;}
value_ram=0;
while(TMR0<=32)//8MS
{CLRWDT();}
TMR0=0;
}
void timeschu() //550
{
for(abs_25kmh_ram=0;abs_25kmh_ram<1;abs_25kmh_ram++)
{for(abs_15kmh_ram=0;abs_15kmh_ram<32351;abs_15kmh_ram++)
{CLRWDT();
CLRWDT();
CLRWDT();
CLRWDT();
CLRWDT(); }
}
}
void times450() //450
{
for(abs_25kmh_ram=0;abs_25kmh_ram<1;abs_25kmh_ram++)
{for(abs_15kmh_ram=0;abs_15kmh_ram<26469;abs_15kmh_ram++)
{CLRWDT();
CLRWDT();
CLRWDT();
CLRWDT();
CLRWDT(); }
}
}
void times200() //200
{
for(abs_25kmh_ram=0;abs_25kmh_ram<1;abs_25kmh_ram++)
{for(abs_15kmh_ram=0;abs_15kmh_ram<11765;abs_15kmh_ram++)
{CLRWDT();
CLRWDT();
CLRWDT();
CLRWDT();
CLRWDT(); }
}
}
void timesjian()
{
for(abs_25kmh_ram=0;abs_25kmh_ram<20;abs_25kmh_ram++)
{for(abs_15kmh_ram=0;abs_15kmh_ram<58826;abs_15kmh_ram++)
{CLRWDT();
CLRWDT();
CLRWDT();
CLRWDT();
CLRWDT(); }
}
}
main()
{ io();
OPTION=0;
tmr1_initialization();
TMR0=0;
times_delay(30);
NOP();
times_delay(0);
NOP();
for(abs_25kmh_ram=0;abs_25kmh_ram<2;abs_25kmh_ram++)
{for(abs_15kmh_ram=0;abs_15kmh_ram<58822;abs_15kmh_ram++)
{CLRWDT();
CLRWDT();
CLRWDT();
CLRWDT();
CLRWDT(); }
}
airbag_out_fg=1;
abs_15kmh_fg=1;
abs_25kmh_fg=1;
abs_fg1=1;
abs_fg1=1;
airbag_fg=1;
while(1)
{
LLLLM: if(MMMMA==0)
{goto LLLLA; }
else
{if(MMMMB==0)
{goto LLLLB; }
else
{if(MMMMC==0)
{goto LLLLC; }
else
{if(MMMMD==0)
{goto LLLLD; }
}}}
goto LLLLM;
goto LLLLM;
LLLLA: RB0=1; //3002
times200();
RB0=0;
times200();
times200();
times200();
times200();
RB2=1;
times200();
RB2=0;
times200();
times200();
times200();
times200();
RB4=1;
times200();
RB4=0;
times200();
times200();
times200();
times200();
RB6=1;
times200();
RB6=0;
times200();
times200();
times200();
times200();
RC0=1;
times200();
RC0=0;
times200();
times200();
times200();
times200();
RC2=1;
times200();
RC2=0;
times200();
times200();
times200();
times200();
RC4=1;
times200();
RC4=0;
times200();
times200();
times200();
times200();
RC6=1;
times200();
RC6=0;
times200();
times200();
times200();
times200();
if(MMMMF==0)
{goto LLLLF; }
else
{goto LLLLG;}
LLLLF: timesjian();
LLLLG: times200();
times200();
times200();
times200();
times200();
times200();
times200();
times200(); times200(); times200();
RB1=1;
times200();
RB1=0;
times200();
times200();
times200();
times200();
RB3=1;
times200();
RB3=0;
times200();
times200();
times200();
times200();
RB5=1;
times200();
RB5=0;
times200();
times200();
times200();
times200();
RB7=1;
times200();
RB7=0;
times200();
times200();
times200();
times200();
RC1=1;
times200();
RC1=0;
times200();
times200();
times200();
times200();
RC3=1;
times200();
RC3=0;
times200();
times200();
times200();
times200();
RC5=1;
times200();
RC5=0;
times200();
times200();
times200();
times200();
RC7=1;
times200();
RC7=0;
times200();
times200();
times200();
times200();
if(MMMMF==0)
{goto LLLYF; }
else
{goto LLLYG;}
LLLYF: timesjian();
LLLYG: times200();
times200();
times200();
times200();
times200();
times200();
times200();
times200(); times200(); times200();
goto LLLLM;
LLLLB: RB0=1; //3006
timeschu();
RB0=0;
times450();
RB2=1;
timeschu();
RB2=0;
times450();
RB4=1;
timeschu();
RB4=0;
times450();
RB6=1;
timeschu();
RB6=0;
times450();
RC0=1;
timeschu();
RC0=0;
times450();
RC2=1;
timeschu();
RC2=0;
times450();
RC4=1;
timeschu();
RC4=0;
times450();
RC6=1;
timeschu();
RC6=0;
times450();
if(MMMMF==0)
{goto LLLLh ;}
else
{goto LLLLi;}
LLLLh: timesjian();
LLLLi: times200();
times200();
times200();
times200();
times200();
times200();
times200();
times200(); times200(); times200();
goto LLLLM;
LLLLC: if(MMMMF==0) //3007
{goto LLLLj;}
else
{goto LLLLk;}
LLLLj: timesjian();
LLLLk: times200();
times200();
times200();
times200();
times200();
times200();
times200();
times200(); times200(); times200();
RB1=1;
times200();
RB1=0;
times200();
times200();
times200();
times200();
RB3=1;
times200();
RB3=0;
times200();
times200();
times200();
times200();
RB5=1;
times200();
RB5=0;
times200();
times200();
times200();
times200();
RB7=1;
times200();
RB7=0;
times200();
times200();
times200();
times200();
RC1=1;
times200();
RC1=0;
times200();
times200();
times200();
times200();
RC3=1;
times200();
RC3=0;
times200();
times200();
times200();
times200();
RC5=1;
times200();
RC5=0;
times200();
times200();
times200();
times200();
RC7=1;
times200();
RC7=0;
times200();
times200();
times200();
times200();
goto LLLLM;
LLLLD: RB0=1; //6000
times450();
RB0=0;
timeschu();
RB2=1;
times450();
RB2=0;
timeschu();
RB4=1;
times450();
RB4=0;
timeschu();
RB6=1;
times450();
RB6=0;
timeschu();
RC0=1;
times450();
RC0=0;
timeschu();
RC2=1;
times450();
RC2=0;
timeschu();
RC4=1;
times450();
RC4=0;
timeschu();
RC6=1;
times450();
RC6=0;
timeschu();
if(MMMMF==0)
{goto LLLLl;}
else
{goto LLLLn;}
LLLLl: timesjian();
LLLLn: times200();
times200();
times200();
times200();
times200();
times200();
times200();