ARM汇编语言UART0输入输出,我在做什么错。 [英] ARM Assembly Language uART0 Input Output, What am I doing wrong.

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

问题描述

写两(2)ARM汇编语言子程序,称为output_char和read_char。
这些子程序将允许用户输入字符和通过UART显示腻子的字符。
所有的用户输入应回显到显示器

我试着写了code,但没有奏效。

  U0LSR EQU 0x14的
注册EQU 0xE000C000
    STMFD SP!,{} LRread_character
    LDR R0,= 0xE000C014
    LDRB R1,[R0]
    BIC R1,R1,#0xFFFFFFFE
    CMP R1,#0
    BEQ read_character
    LDR R6 =寄存器
    LDR R2,[R6]output_character
    LDR R0,= 0xE000C014
    LDRB R1,[R0]
    BIC R1,R1,#0xFFFFFFEF
    MOV R1,R1,LSR#1
    CMP R1,#0
    BEQ output_character
    LDR R6 =寄存器
    STR R2,[R6]    LDMFD SP !, {} LR
    BX LR


解决方案

这看起来是相关的。

http://csserver.evansville.edu/~blandfor/EE311/ ARMLecture / UARTNotes.pdf

考虑到这些被认为是两个分开的功能,上述previous评论适用。另外,我将承担起这个问题并不是指初始化UART,它确实成功,否则工作。所述STMFD / LDMFD / BX三缸应与这两种功能相关联。此外,考虑到ARM过程调用标准

http://infocenter.arm.com/帮助/主题/ com.arm.doc.ihi0042e / IHI0042E_aapcs.pdf

你应该,如果可能的话限制自己R0-R3在你的程序。如果您需要更多,你需要将它们添加到STMFD / LDMFD说明,以便您不要修改寄存器没有他们回到自己的previous状态。

问题的语句写入的方式,read_char功能需要调用函数write_char呼应输入到屏幕的字符。也就是说缺少你的答案。它看起来像寄存器,用于保存字符是相同寄存器发送的字符,所以这是很好的。否则read_character功能看起来不错。

您write_character功能看起来不正确但是,您的BIC 0xFFFF的FFEF看起来不正确的。你想寻找的发送器空位,您应该使用0xFFFF的FFBF。作为一个风格问题,我会建议使用和位设置要与BIC和逆。使得它更容易看到的。如果你没有在你的输出看到任何东西,这是最有可能的问题,因为在LSR的BI(休息指标)位[4]很可能永远不会高,所以你的code永远循环。

最后,问题的声明说,使用read_char和output_char为你的函数名,所以你需要将这些标签添加到每个STMFD说明。你BEQ是好的,它需要循环回从线状态寄存器读寄存器,因此它需要一个单独的目标标签。

Write two (2) ARM assembly language subroutines, called output_char and read_char. These subroutines will allow a user to enter a character and display the character in PuTTy via the UART. All user input should be echoed back to the display

I tried writing the code but it did not work.

U0LSR EQU 0x14          
register EQU 0xE000C000


    STMFD SP!,{lr}  

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



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

    LDMFD sp!, {lr}
    BX lr

解决方案

This looks like it is related

http://csserver.evansville.edu/~blandfor/EE311/ARMLecture/UARTNotes.pdf

Considering these are supposed to be two separate functions, the previous comments above apply. Also, I will assume since the problem does not refer to initializing the UART, that it does work successfully otherwise. The STMFD/LDMFD/BX triplex should be associated with both functions. Also, considering the ARM procedure call standard

http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042e/IHI0042E_aapcs.pdf

you probably should limit yourself to R0-R3 in your procedures, if possible. If you need more, you need to add them to the STMFD/LDMFD instructions so you don't modify registers without returning them to their previous state.

The way the problem statement is written, the read_char function needs to call the write_char function to echo the character typed back to the screen. That is missing in your answer. It looks like the register holding the character is the same as the register sending the character, so that's good. Otherwise the read_character function looks OK.

Your write_character function doesn't look quite correct however, your BIC 0xFFFF FFEF doesn't look right. You want to be looking at the Transmitter Empty bit, you should be using 0xFFFF FFBF. As a point of style, I would recommend using AND with the bit set you want versus BIC and the inverse. Makes it easier to see. If you aren't seeing anything on your output, this is most likely the problem since the BI (break indicator) bit at LSR[4] is probably never going high, so your code is looping forever.

Lastly, the problem statement says to use read_char and output_char as your function names, so you need to add those labels to the STMFD instructions for each. Your BEQ is fine, it needs to loop back to the register read from the line status register, so it needs a separate target label.

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

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