• AVR Freaks

Hot!UART asm code shortening

Author
Andrius_Vaiceliunas
Starting Member
  • Total Posts : 25
  • Reward points : 0
  • Joined: 2013/11/15 05:03:22
  • Location: 0
  • Status: offline
2020/04/17 14:03:45 (permalink)
0

UART asm code shortening

Conditions: 16 bit PIC's, language asembler.
 
If i want send UART symbols row to PC terminal, but not want write long code to send everyone letter separately, is there any form in MPLAB? Roughly speaking, sending row ABC separately simbols:
mov   #0x41, W0 ; Letter A
mov   W0, U1TXREG
.....
mov   #0x42, W0 ; Letter B
mov   W0, U1TXREG
.....
mov   #0x43, W0 ; Letter C
mov   W0, U1TXREG
 
Sending row ABC non separately:
mov   'ABC', W0 ; <- How implement?
mov   W0, U1TXREG
post edited by Andrius_Vaiceliunas - 2020/04/17 14:04:50
#1

1 Reply Related Threads

    Beau Schwabe
    Starting Member
    • Total Posts : 29
    • Reward points : 0
    • Joined: 2019/09/23 21:16:53
    • Location: 0
    • Status: online
    Re: UART asm code shortening 2020/04/17 14:52:38 (permalink)
    0
    You could use indirect addressing and a loop or a specific termination character.  Just point to the beginning of the address location with the FSR.
     
    Note: After loading the TX REG, you will need to wait before processing the next data BYTE or you will get an overflow error in the transmit buffer, or just miss sending data.
     
    On the PIC18f57k42 I do something like this after the TX register is loaded.  Your mileage may vary.

        btfss    U1ERRIR        ,TXMTIF
        goto    $-2

    #2
    Jump to:
    © 2020 APG vNext Commercial Version 4.5