CPU 8052 INCLUDE stddef51.inc CLOCK equ 115200*16 defbaud equ 115200 powers EQU 20h jmp overvec t0start: REPT 0bh-t0start nop ENDM reti ;================================= overvec: mov sp, #12 mov p1, #00000111b mov p3, #11111111b mov ie, #0 ; mov ien1, #0 mov tcon, #01000000b mov tmod, #00100011b mov scon, #01110000b ;mode 1 mov th1, #256-CLOCK/16/defbaud ;rs232 baud orl pcon, #10000000b ;rs232 clock /16 mov powers, #00011100b mainloop: rxwait: jnb ri, rxwait ;wait for rs232 byte received clr ri mov a, sbuf ;bit0=reply, bit1=powerswitch mov b, a jnb acc.1, nopower mov powers, a jmp mainloop nopower: anl a, #11111000b mov c, powers.2 mov p3.7, c ;Vpp=0v mov c, powers.3 mov acc.1, c ;Vpp=12v mov c, powers.4 mov acc.2, c ;Vcc=5v mov p1, a jnb b.0, mainloop ;no reply mov a, p1 mov sbuf, a ;send p1 jmp mainloop END