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

Subversion Repositories oms8051mini

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

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
__xdata __at (0x3000) unsigned char uart_reg0;
15
__xdata __at (0x3008) unsigned char uart_reg2;
16
__xdata __at (0x300C) unsigned char uart_reg3;
17
__xdata __at (0x3010) unsigned char uart_tdata;
18
__xdata __at (0x3014) unsigned char uart_rdata;
19
__xdata unsigned long *rx_des_base;
20
__xdata unsigned long *tx_des_base;
21
 
22
void main() {
23
 
24
    unsigned int cFrameCnt = 0;
25
    /***
26
     [4:3] = 0 -> No Parity
27
     [2]   = 1 - 2 Stop
28
     [1]   = 1 - Rx Enable
29
     [0]   = 1 - Tx Enable
30
    **/
31
    uart_reg0 = 0x7;
32
    uart_reg2 = 0x0; // Baud Clock
33
    while(1) {
34
       if((uart_reg3 & 0x2) == 0) { // Check the Rx Fifo  Counter
35
          // Read the Receive FIFO
36
          uart_tdata = uart_rdata;
37
          cFrameCnt  = cFrameCnt+1;
38
         }
39
    }
40
}

powered by: WebSVN 2.1.0

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