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

查看:173
本文介绍了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在屏幕上显示。是否有人可以帮助我的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设置,那么读取字符

也许不是做一个AND或TST 1,如果RDR位设置还是比不上?

同样的,如果设置,那么,否则发送一个字符循环,并再次尝试读取LSR和为0x10?当你写它会始终设置在R1和0x10位code,然后转移它的权利1,使0x08的总是被设置然后用零总是应该因为至少一个位总是置失败的比较,所以都是你看到一个无限循环?与TX 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]



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.

解决方案

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?

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

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