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

assembler in c, UART

Hi i have got code for an assembler software UART in c51.
normally putchar() is of type unsigned char but with the assembler code how do i do this?

void putc()
{
#pragma asm
  * Transmit character in A via TXD line
  *
  putc  CLR     TXD             Drop line for start bit
        MOV     R0,#BITTIM      Wait full bit-time
        DJNZ    R0,*            For START bit
        MOV     R1,#8           Send 8 bits
  putc1 RRC     A               Move next bit into carry
        MOV     TXD,C           Write next bit
        MOV     R0,#BITTIM      Wait full bit-time
        DJNZ    R0,*            For DATA bit
        DJNZ    R1,putc1        write 8 bits
        SETB    TXD             Set line high
        RRC     A               Restore ACC contents
        MOV     R0,#BITTIM      Wait full bit-time
        DJNZ    R0,*            For STOP bit
        RET
  *
#pragma endasm
}

Parents
  • my UARTS have failed
    .......
    but it is still not working

    What do you connect to? if it is a 232 port (PC) is your MAX232(equivalent) working? if it is a modem (at TTL level or 232) do you know that in that case many are documented and labelled so tx connect to tx?

    Tell the whole story, till that is known discussing your code is immaterial.

    Erik

Reply
  • my UARTS have failed
    .......
    but it is still not working

    What do you connect to? if it is a 232 port (PC) is your MAX232(equivalent) working? if it is a modem (at TTL level or 232) do you know that in that case many are documented and labelled so tx connect to tx?

    Tell the whole story, till that is known discussing your code is immaterial.

    Erik

Children