ARM UART0 输入输出.LPC2138 我做错了什么. [英] ARM UART0 input output. LPC2138 What am I doing wrong.

查看:15
本文介绍了ARM UART0 输入输出.LPC2138 我做错了什么.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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]

我做错了什么?我的动机是创建一个例程来接收角色并使用 UART0 将其显示在屏幕上.有人可以帮我写代码吗.

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.

推荐答案

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

BIC 保持位 3:0 不变,因此如果设置了 RDR、OE、PE 或 FE,则读取一个字符.

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

也许可以用 1 进行 AND 或 TST 并比较 RDR 位是否设置?

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

同样在读取 LSR 时,如果设置了 0x10,则发送一个字符,否则循环并重试?您编写的代码将始终在 r1 中设置 0x10 位,然后将其右移 1,以便始终设置 0x08,然后与零进行比较,这应该总是失败,因为至少始终设置了一位,所以您看到无限循环?用你的交易代码?

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?

这篇关于ARM UART0 输入输出.LPC2138 我做错了什么.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆