$NOMOD51 ;Disable standard predefined 8051 register definitions. $INCLUDE(reg515.inc) ;Include the predefined 80C515/535 register definitions. ;Note that the file "reg515.inc" must reside somewhere ;in the parent directory where your assembly code files ;are stored. Name RPM public in0srv int0er SEGMENT CODE RSEG int0er EXTRN CODE (poll, Display1,seroutb) in0srv: mov A,TL0 ;set timer 0 value to R3 mov B,A add A,B mov R3,A mov 39h,R3 mov TL0,#00h mov A,36h jz notclf mov 3Ah,#01h ;Set closed loop flag notclf: clr c mov a,34h ;CLUTCH***** jz noteng ;*********** clr P4.5 ;0 = off**** ljmp eng1 ;*********** ;*********** noteng: setb P4.5 ;1 = on***** eng1: mov a,35h ;GENERATOR LOAD* jz noteng2 ;*************** clr P4.4 ;0 = off******** ljmp eng ;*************** ;*************** noteng2: setb P4.4 ;1 = on********* eng: mov a, 71h jnz NotCL NotCL: mov A,1Ch ;1C is the register for timeing add A,#01h ;polling for joystick mov 1Ch,A mov B,1Dh CJNE A,B,next ;R6 is the register for polling time lcall poll mov A,#0h mov 1Ch,A next: mov A,7Bh JNZ recset mov A,#04h mov 7Bh,A ;Set the record time to 255*4 [ms] if none is set recset: mov A,7Fh ;7F is # of write times (1-255) jz notrec mov A,7Dh ;7D is current count inc A mov 7Dh,A CJNE A,7Bh,tic ;7B is count up to, determinded by user mov 7Dh,#0h push DPH push DPL mov A,7Fh mov DPH,#095h mov DPL,A mov A,R3 movx @DPTR,A pop DPL pop DPH mov A,7Fh inc A mov 7Fh,A ljmp notrec tic: notrec: mov A,1Bh JNZ next3 mov a,7Eh add A,#01h ;low byte for .5 second timeing #E8 mov 7Eh,A jnc next2 ;if overflow to 256 then carry will be set inc 1Fh ;High byte of .5 sec timeing #03 next2: mov A,7Eh CJNE A,#0F4h,next3 ;Check for .5 sec mov A,1Fh CJNE A,#01h,next3 ;second check mov A,#0h mov 7Eh,Acc ;clear counter mov 1Fh,Acc cpl p4.0 ;1 sec mov A,38h JNZ next3 lcall Display1 next3: mov A,78h JZ notsend push DPH push DPL mov DPH,#095h mov DPL,A movx A,@DPTR lcall seroutb mov A,78h inc A mov 78h,A pop DPL pop DPH CJNE A,#00h,notime mov A,7Bh lcall seroutb mov A,7Bh anl A,#80h RR A lcall seroutb notime: notsend: ;pop acc ;***************************REALTIME*************** mov A,73h ;realtime on or off JZ norealtm DJNZ 51h,norealtm mov 51h,#01h mov A,R3 lcall seroutb norealtm: ;************************************************** reti end