This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

SOFTEARE UART TIMEOUT

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

  • I guess the reason you have a software UART is that you need more than one, else this is ridiculous.

    Can i put a loop that expires after x counts without start bit? how to do this in assembler?
    DJNZ

    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?
    jbc/jb/jnb

    are the questions how to do this in assembler ... how to read this flag in assemblerbased on "I found this assembly code, but have no knowledge of assembler programming"

    Erik

  • Hi again, and thanks for your reply.

    I need 2 uarts, 2 is working fine, the hardware and software uart.

    Really dont know assembly, we are trying to learn.
    I want to set a flag in C code and read this flag in the assembly loop that waits for my start bit, if flag == true then skip the assembly loop.
    I´m studing assembly, but this is an emergency solution.

    Lets trying.

    thanks a lot

  • It is external interrupt driven at int1
    nothing you have shown indicates that

    Erik

  • Please, somebody to example a timeout loop where my assembly code is waiting for start bit.

    After x loops skipt the routine.
    Thanks a lot

  • 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.