ARM UART0 input output. LPC2138 What am I doing wrong. [duplicate]

a 夏天 提交于 2019-12-31 05:28:25

问题


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:


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?



来源:https://stackoverflow.com/questions/22025929/arm-uart0-input-output-lpc2138-what-am-i-doing-wrong

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!