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
  • "i have only one working board, the other i was previously working and does not work with the same code that works on the other."

    you really need to fix the underlying problem here - throwing in more untried and untested software into an already unreliable system is a really bad idea!!

    "need a software version to show in a presentation next week"

    On a deadline like that, now is most certainly not the time to start mucking about with software uarts!

    You cannot buy extra time - but you can buy a new chip!

Reply
  • "i have only one working board, the other i was previously working and does not work with the same code that works on the other."

    you really need to fix the underlying problem here - throwing in more untried and untested software into an already unreliable system is a really bad idea!!

    "need a software version to show in a presentation next week"

    On a deadline like that, now is most certainly not the time to start mucking about with software uarts!

    You cannot buy extra time - but you can buy a new chip!

Children
No data