;************三线四回路频闪跳机******* ;************工作寄存器************ p5==0X05 ioc5==0X05 p6==0X06 ioc6==0X06 isr==0x0f ;RF iocd==0x0d IOCE==0X0E IOCF==0X0F status==0x03 PC==0X02 ;**********一般寄存器****************** INCOUNT == 0X11 LEDTAB == 0X12 TEMP == 0X13 TEMPA == 0X14 TEMPB == 0X15 time == 0x16 incount_sw == 0x17 data1 == 0x18 data2 == 0x19 ;***********位定义********************* z==0X02 EXIF==0X02 ;************主程序*********************** org 000h jmp main ;***********外部引脚中断程序************* ORG 0X08 MOV TEMPA,A MOV A,STATUS MOV TEMPB,A BC ISR,EXIF ;ISR(RF)中断状态寄存器EXIF位,外部中断标志 INC INCOUNT ;计数器中断一次就加1 check jbc p6,1 jmp check1 call delay jbc p6,1 jmp check inc incount_sw clr incount check2 jbs p6,1 jmp check2 call delay check1 jbs p6,1 jmp check1 MOV A,TEMPB MOV STATUS,A MOV A,TEMPA RETI main: disi ;总中断关 mov a,@0b00000000 iow ioc5 iow p5 ;定义输出 mov a,@0b11111111 iow ioc6 iow p6 ;定义输入 mov a,@0b00000001 iow iocd ;定义P61口上拉 mov a,@0b01000000 iow ioce ;WDT控制器EIS位,外部中断引脚/INT但P60为输入 MOV A,@0b00000100 IOW IOCF ;中断屏蔽寄存器EXIE位,EXIF中断使能 mov a,@0b01000000 contw ;CONT控制寄存器INT位,中断使能标志 eni ;总中断开
main1: CLR LEDTAB clr incount clr incount_sw clr time mov a,@3 ;速度1 mov time,a loop1 CALL LEDOUT mov a,incount_sw xor a,@1 jbs status,z ;结果为0 Z=1 jmp next1 clr incount inc incount_sw mov a,@6 ;速度2 mov time,a jmp loop1 next1 mov a,incount_sw xor a,@3 jbs status,z jmp next2 clr incount inc incount_sw mov a,@12 ;速度3 mov time,a jmp loop1 next2 mov a,incount_sw xor a,@5 jbs status,z jmp ft clr incount_sw jmp main1
ft MOV A,INCOUNT XOR A,time ;灯亮时间 JBS STATUS,Z JMP loop1 CLR INCOUNT INC LEDTAB ;查表值 MOV A,LEDTAB XOR A,@4 JBC STATUS,Z ;结果为0 Z=1 CLR LEDTAB MOV A,@0B00001111 MOV P5,A ;灯灭时间=亮时间X3 JMP LOOP1 LEDOUT: MOV A,LEDTAB ADD PC,A JMP LED0 JMP LED1 JMP LED2 JMP LED3 LED0 MOV A,@0B00001110 MOV P5,A RET LED1 MOV A,@0B00001101 MOV P5,A RET LED2 MOV A,@0B00001011 MOV P5,A RET LED3 MOV A,@0B00000111 MOV P5,A RET
delay: mov a,@130 mov data1,a joop2 mov a,@100 mov data2,a joop1 djz data2 jmp joop1 djz data1 jmp joop2 ret END |