ARM UART0 input output. LPC2138 What am I doing wr

2020-05-07 02:13发布

read_character
    LDR r0, =0xE000C014
    LDRB r1, [r0]
    BIC r1, r1, #0xFFFFFFF0
    CMP r1, 0
    BEQ read_character
    LDR r6, =r1
    LDR r2, [r6]



output_character
    LDR r0, =0xE000C014
    LDRB r1, [r0]
    ORR  r1, r1, #0x00000010
    MOV r1, r1, LSR #1
    CMP r1, 0
    BEQ output_character
    LDR r6, =r1
    STR r2, [r6]

What am I doing wrong? My motive is to create a routine to take in the character and display it on the screen using UART0. Can someone please help me with the code.

1条回答
女痞
2楼-- · 2020-05-07 02:35
read_character
    LDR r0, =0xE000C014
    LDRB r1, [r0]
    BIC r1, r1, #0xFFFFFFF0
    CMP r1, 0
    BEQ read_character
    LDR r6, =r1
    LDR r2, [r6]

that BIC leaves bits 3:0 unchanged so if RDR, OE, PE or FE is set then read a character.

maybe instead do an AND or TST with 1 and compare if the RDR bit is set or not?

Likewise on the read the LSR and with 0x10 if set then send a character otherwise loop and try again? the code as you have written it will always set the 0x10 bit in r1, then shift it right 1 so that 0x08 is always set then compare with zero which should always fail since at least that one bit is always set, so are you seeing an infinite loop? with your tx code?

查看更多
登录 后发表回答