Hello to all. i have a software uart, writen in assembler, working fine, but i want to put a timeout if no byte is received or if dont have start bit. It is external interrupt driven at int1, but really need the timeout because the byte sometimes dont arrive.
the assembler code below have a line that says "Wait for Start Bit", is where i want to put the timeout.
Can i put a loop that expires after x counts without start bit? how to do this in assembler?
Or i can start a timer when int1 interrupts, when the timer interrupt i set a flag in C, how to read this flag in assembler and stop waiting the start bit?
Thanks a lot for help and sorry my bad english
the code:
RSEG ?SU?GETC getc: Push ACC Push PSW JB rxd_pin,$ ;Wait for start bit MOV R0,#BITTIM/2 ;Wait 1/2 bit-time DJNZ R0,$ ;To sample in middle JB rxd_pin,getc ;Insure valid MOV R1,#8 ;Read 8 bits getc1: MOV R0,#BITTIM ;Wait full bit-time DJNZ R0,$ ;For DATA bit MOV C,rxd_pin ;Read bit RRC A ;Shift it into ACC DJNZ R1,getc1 ;read 8 bits mov r7,a POP PSW pop ACC RET ;go home END