OpenCores
URL https://opencores.org/ocsvn/oms8051mini/oms8051mini/trunk

Subversion Repositories oms8051mini

[/] [oms8051mini/] [trunk/] [verif/] [sw/] [C/] [uart_lb.c] - Blame information for rev 13

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 dinesha
/*
2
 * UART Software Loop Back.
3
 * Software continously check the Uart Rx Buffer, If the RX Buffer is not zero,
4
 * Then it read the Rx data and copy the information back to tx fifo
5
 */
6
 
7
/*---------------------------------------------------------------------------*/
8
 
9
#include <8051.h>
10
 
11
char cErrCnt;
12
/*---------------------------------------------------------------------------*/
13
 
14 7 dinesha
__xdata __at (0x9000) unsigned char uart_reg0;
15 11 dinesha
__xdata __at (0x9001) unsigned char uart_reg1;
16
__xdata __at (0x9002) unsigned char uart_reg2;
17
__xdata __at (0x9003) unsigned char uart_reg3;
18
__xdata __at (0x9004) unsigned char uart_reg4;
19
__xdata __at (0x9005) unsigned char uart_tdata;
20
__xdata __at (0x9006) unsigned char uart_rdata;
21 6 dinesha
__xdata unsigned long *rx_des_base;
22
__xdata unsigned long *tx_des_base;
23
 
24
void main() {
25
 
26
    unsigned int cFrameCnt = 0;
27
    /***
28
     [4:3] = 0 -> No Parity
29
     [2]   = 1 - 2 Stop
30
     [1]   = 1 - Rx Enable
31
     [0]   = 1 - Tx Enable
32
    **/
33
    uart_reg0 = 0x7;
34
    uart_reg2 = 0x0; // Baud Clock
35 11 dinesha
    uart_reg3 = 0x0; // Baud Clock
36 6 dinesha
    while(1) {
37 11 dinesha
       if((uart_reg4 & 0x2) == 0) { // Check the Rx Fifo  Counter
38 6 dinesha
          // Read the Receive FIFO
39
          uart_tdata = uart_rdata;
40
          cFrameCnt  = cFrameCnt+1;
41
         }
42
    }
43
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.