URL
https://opencores.org/ocsvn/amber/amber/trunk
Subversion Repositories amber
[/] [amber/] [trunk/] [hw/] [tests/] [uart_tx.S] - Rev 64
Go to most recent revision | Compare with Previous | Blame | View Log
/*****************************************************************// //// Amber 2 System UART Test //// //// This file is part of the Amber project //// http://www.opencores.org/project,amber //// //// Description //// Uses the tb_uart in loopback mode to verify the transmitted //// data. //// //// Author(s): //// - Conor Santifort, csantifort.amber@gmail.com //// ////////////////////////////////////////////////////////////////////// //// Copyright (C) 2010 Authors and OPENCORES.ORG //// //// This source file may be used and distributed without //// restriction provided that this copyright statement is not //// removed from the file and that any derivative work contains //// the original copyright notice and the associated disclaimer. //// //// This source file is free software; you can redistribute it //// and/or modify it under the terms of the GNU Lesser General //// Public License as published by the Free Software Foundation; //// either version 2.1 of the License, or (at your option) any //// later version. //// //// This source is distributed in the hope that it will be //// useful, but WITHOUT ANY WARRANTY; without even the implied //// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //// PURPOSE. See the GNU Lesser General Public License for more //// details. //// //// You should have received a copy of the GNU Lesser General //// Public License along with this source; if not, download it //// from http://www.opencores.org/lgpl.shtml //// //*****************************************************************/#include "amber_registers.h".section .text.globl mainmain:@ Put test_uart into loopback mode, and enable transmitldr r0, AdrTEST_UART_CONTROLmov r1, #0x3str r1, [r0]@ Write to and read back from UART0 registersldr r4, AdrUART0DRldr r5, =Messageldr r9, =Messageldr r7, =EndMessage1: bl wait_tx_fullldrb r6, [r5], #1@ transmit byte from test_uartstr r6, [r4]bl uart_rx_check@ keep doing this until get to the end of the messagecmp r5, r7bne 1b@ The complete message has now been transmitted@ but some bytes are still en route@ check the last few bytes receivedbl uart_rx_check@ check that all bytes were receivedadd r9, r9, #2cmp r9, r7movne r10, #100bne testfailb testpass@ -------------------------------------------wait_tx_full:@ with timeout loop of 0x400ldr r0, AdrUART0FRmov r2, #0x4001: subs r2, r2, #1moveq r10, #100beq testfailldr r1, [r0]ands r1, r1, #0x20bne 1bmov pc, lruart_rx_check:ldr r2, AdrUART0DR @ rx/tx byteldr r3, AdrUART0FR @ flags@ if rx fifo empty flag == 1, return without doing anything1: ldr r0, [r3]ands r0, r0, #0x10movne pc, lrldrb r0, [r2] @ uart rx byteldrb r1, [r9], #1 @ transmitted textcmp r0, r1movne r10, #20bne testfail@ check if there are more bytes in rx bufferb 1btestfail:ldr r11, AdrTestStatusstr r10, [r11]b testfailtestpass:ldr r11, AdrTestStatusmov r10, #17str r10, [r11]b testpass@ ------------------------------------------@ ------------------------------------------/* Write 17 to this address to generate a Test Passed message */AdrTestStatus: .word ADR_AMBER_TEST_STATUSAdrTEST_UART_CONTROL: .word ADR_AMBER_TEST_UART_CONTROLAdrUART0DR: .word ADR_AMBER_UART0_DRAdrUART0FR: .word ADR_AMBER_UART0_FRMessage: .ascii "\nThis message is brought to you by UART0\nThats all folks\n"EndMessage: .word 0
Go to most recent revision | Compare with Previous | Blame | View Log
