首页 > 解决方案 > 通过 LM3S811 Qemu Simulation 中的中断在 UART 中回显数据

问题描述

我正在尝试使用 Qemu Simulation 通过 LM3S811 中的中断在 UART 中传输和接收字符。我在此https://www.electronicwings.com/arm7/lpc2148-uart0的帮助下编写了此代码。我不确定它是否正确并且它不起作用。有人可以建议如何完成任务。

启动代码:

.thumb
.global start
start:
.word 0x20001000
.word main

闪存.ld

MEMORY
{
    FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x00010000
    SRAM (rxw)  : ORIGIN = 0x20000000, LENGTH = 0x00002000
}

SECTIONS
{
    .text : {
        *(.vectors);
        *(.text);
        etext = .;
    } > FLASH

    .rodata : {
        *(.rodata);
    } > FLASH

    .data : {
        sdata = .;
        *(.data);
        edata = .;
    } > SRAM AT > FLASH

    .bss: {
        sbss = .;
        *(.bss);
        ebss = .;
    }  > SRAM
    
}

主程序

#define  UARTDR (*((volatile unsigned int *) 0x4000C000))  // Data register for UART...
#define UARTIFLS (*((volatile unsigned int *) 0x40000034)) // Interrupt identification register...
#define  UARTFR (*((volatile unsigned int *) 0x4000C018))  // Register which holds the status of the FIFO...
char rx;

_irq void UART0_Inerrupt(void)
{
    int iir_value;
    iir_value = UARTIFLS  // Interrupt Identification register...

    if (iir_value & 0x00) {  // If interrupt is received, i.e data is present... 
        rx = UARTDR; 
    }
    UARTDR = rx; // Write to data register for writing to transmit FIFO...
    while ( (UARTFR & 0x20) == 1) continue; 
}

int main(void)
{
    NVICVectAddr0 = (unsigned) UART0_Inerrupt;
    while(1);
}
``

标签: armmicrocontrollercortex-mmicroprocessorscortex-m3

解决方案


推荐阅读