双核单片机红外遥控码代码
时间:12-01
来源:互联网
点击:
一个用应广双核单片机做的红外遮挡开光(反射式)全部代码。
IR_SW equ pb.1
IR_INPUT equ pa.0
IR_OUTPUT equ pa.6
byte ir_new
byte ir_old
byte ir_enable
byte i
byte ir_new1
byte ir_new2
byte ir_new3
goto main0
goto main1
//----------------FPPA0-------------------
main0:
.ADJUST_OTP_IHRCR 8MIPS// IHRC/2 = 8MIPS, WatchDog Disable, RAM 0,1 temporary be used
sp = 0x30
disgint
inten = 0
mov a,0b000_11_111 //disable timer
mov t16m,a
set1 pbc.1
set0 IR_SW
set0 pac.0
set1 pac.6
set0 IR_OUTPUT
delay 200
ir_new = 0
ir_old = 0
ir_enable = 0
mov a,0
mov intrq,a
set1 fppen.1 //eanble FPPA1
ir_enable = 1
i = 20
while(i)
{
delay 200
i--
}
if(IR_INPUT)
{
ir_old = 1
}
else
{
ir_old = 0
}
ir_enable = 0
i = 5
while(i)
{
delay 200
i--
}
clkmd.1 = 1 //enable watch dog
main0_loop:
wdreset
call check_ir
if(ir_new != ir_old)
{
if(ir_new != 1)
{
tog IR_SW
}
ir_old = ir_new
}
i = 100
while(i)
{
delay 200
i--
}
goto main0_loop
check_ir:
ir_enable = 1
i = 20
while(i)
{
delay 200
i--
}
if(IR_INPUT)
{
ir_new1 = 1
}
else
{
ir_new1 = 0
}
i = 5
while(i)
{
delay 200
i--
}
if(IR_INPUT)
{
ir_new2 = 1
}
else
{
ir_new2 = 0
}
i = 5
while(i)
{
delay 200
i--
}
if(IR_INPUT)
{
ir_new3 = 1
}
else
{
ir_new3 = 0
}
if((ir_new1 == ir_new2) (ir_new2 == ir_new3))
{
ir_new = ir_new1
}
else
{
ir_new = ir_old
}
ir_enable = 0
i = 20
while(i)
{
delay 200
i--
}
ret
//----------------FPPA1-------------------
main1:
sp = 0x38
delay 200
main1_loop: //output 38k IR signal
if(ir_enable)
{
set1 IR_OUTPUT
delay 33
set0 IR_OUTPUT
delay 67
}
else
{
set0 IR_OUTPUT
delay 10
}
goto main1_loop
IR_SW equ pb.1
IR_INPUT equ pa.0
IR_OUTPUT equ pa.6
byte ir_new
byte ir_old
byte ir_enable
byte i
byte ir_new1
byte ir_new2
byte ir_new3
goto main0
goto main1
//----------------FPPA0-------------------
main0:
.ADJUST_OTP_IHRCR 8MIPS// IHRC/2 = 8MIPS, WatchDog Disable, RAM 0,1 temporary be used
sp = 0x30
disgint
inten = 0
mov a,0b000_11_111 //disable timer
mov t16m,a
set1 pbc.1
set0 IR_SW
set0 pac.0
set1 pac.6
set0 IR_OUTPUT
delay 200
ir_new = 0
ir_old = 0
ir_enable = 0
mov a,0
mov intrq,a
set1 fppen.1 //eanble FPPA1
ir_enable = 1
i = 20
while(i)
{
delay 200
i--
}
if(IR_INPUT)
{
ir_old = 1
}
else
{
ir_old = 0
}
ir_enable = 0
i = 5
while(i)
{
delay 200
i--
}
clkmd.1 = 1 //enable watch dog
main0_loop:
wdreset
call check_ir
if(ir_new != ir_old)
{
if(ir_new != 1)
{
tog IR_SW
}
ir_old = ir_new
}
i = 100
while(i)
{
delay 200
i--
}
goto main0_loop
check_ir:
ir_enable = 1
i = 20
while(i)
{
delay 200
i--
}
if(IR_INPUT)
{
ir_new1 = 1
}
else
{
ir_new1 = 0
}
i = 5
while(i)
{
delay 200
i--
}
if(IR_INPUT)
{
ir_new2 = 1
}
else
{
ir_new2 = 0
}
i = 5
while(i)
{
delay 200
i--
}
if(IR_INPUT)
{
ir_new3 = 1
}
else
{
ir_new3 = 0
}
if((ir_new1 == ir_new2) (ir_new2 == ir_new3))
{
ir_new = ir_new1
}
else
{
ir_new = ir_old
}
ir_enable = 0
i = 20
while(i)
{
delay 200
i--
}
ret
//----------------FPPA1-------------------
main1:
sp = 0x38
delay 200
main1_loop: //output 38k IR signal
if(ir_enable)
{
set1 IR_OUTPUT
delay 33
set0 IR_OUTPUT
delay 67
}
else
{
set0 IR_OUTPUT
delay 10
}
goto main1_loop
- 给弱势群体的一份关爱,语音识别助老助残服务系统的完整解决方案(06-04)
- 红外通信—红外遥控器NEC解码程序(12-02)
- 通过串口发送红外遥控器的解码值到PC(12-02)
- 单片机红外遥控解码HS0038B用1602液晶显示(12-02)
- 51单片机万能红外遥控解码程序(12-01)
- 1602屏配合红外遥控(实现光标移动)与对1602新的认识(12-01)