This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

UART Communication help

Hi all,

I'm in the process of trying to add a UART interface to an existing program. I have initialized the UART port successfully (as far as I can tell), and before the meat of my program, I have it set in an infinite loop. In this loop, I just have two lines.

//This is my initialization of UART connection
GP1CON = 0x011;// Setup tx & rx pins on P1.0 and P1.1

// Setting up UART at 9600bps (CD=0)
COMCON0 = 0x80; // Setting DLAB
COMDIV0 = 0x88;
COMDIV1 = 0x00;
COMCON0 = 0x07; // Clearing DLAB
//This is my loop
while(1)
{ achar = getchar(); putchar(achar);
}

getchar and putchar are defined in serial.c that I pulled from ADuC7026 examples.

I'm just trying to test the communication by waiting for a character from the terminal and then spitting that same character back to the terminal. Unfortunately, I do not at all get the same character back. I really don't know how this works, and I'm trying to figure all of this out. I think it might be a problem with how I'm configuring my terminal, but I can't find a combination of settings that will make it spit out the correct character. I wrote down a set of keys pressed and their associated character thrown back at me.

Input/output
q/~
w/
e/~
r/x
t/~
y/~
u
i/x
o
p/x
a/x
s/f
d/f
f/f
g/~
h/'
j/'
k/
l/f
z/x
x/x
c/f
v/~
b/'
n/f
m/

etc

The blanks indicate that the terminal did not respond to those keys. I just went back to play with it again, and now I'm getting a bunch of symbols, mu's, and alpha's. If someone could just point me in the right direction here, that would be great. I don't really understand how the two machine communicate with each other in terms of hex/binary/ascii. Is this the source of my problem? Thanks in advance.

-Larry

  • So I lied. I just went back to it. I simply had it set for 9600 baud when it wanted 4800. Thanks anyway.

    Well, while I'm at it, maybe I'll start a new thread for this if nobody comments, I've been trying to work in a way to interrupt my code by hitting a key at a terminal. (Such that it will run until I hit the space bar or something and it will prompt me for some parameters and then continue)

    I have an existing ISR, for other functions, but I figure I can logic filter out each task that the ISR has other ways. In any case, I have set my IRQEN to include the CMPOUT, XIRQ0, and UART. The code works fine as far as a CMP induced interrupt. I've even been able to induce an interrupt by hitting the XIRQ0 button on the ADuC7026 eval board. However, I can't figure out how to actually get a UART signal to interrupt my code..

    Any insight/hints/tips/tricks?

    Thanks.