We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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
a timeout loop where my assembly code is waiting for start bit.
That's clearly not your assembly code by any useful interpretation. If it were, you wouldn't be asking the kind of question you are.
There's no visible reason you would even try to do this in assembly. So don't. Forget about it. Do it in C, and leave the nastier tools for people who know how to handle them.