Keil™, An ARM® Company

Discussion Forum

How can I set Uart2 to exchange data?

Next Thread | Thread List | Previous Thread Start a Thread | Settings

DetailsMessage
Read-Only
Author
Jonas zhuo
Posted
12-Aug-2002 05:00 GMT
Toolset
C51
New! How can I set Uart2 to exchange data?
void initialize_system (void)
{
// Initialize the serial port (9600, 8, N, 1)
PCON &= 0xBF; // Clear bit 7 of the PCON register (SMOD1 = 0)
SCON2 = 0x50; // 0101,0000 (Mode 1 and RxD enable)
TMOD |= 0x20; // Timer #1 in autoreload 8 bit mode
TCON = 0x40; // Set Timer #1 to run mode
TH1 = 0xFD; // Baud rate is determined by
// Timer #1 overflow rate
// Baud Rate = (Fcpu / 384) / (256 - TH1)
// Fcpu = 11.0592 MHz
// TH1 = 253
TR1 = 1; // Turn on Timer 1
TI2 = 1; // Set UART2 to send first char
}
void main (void)
{
unsigned char aaa;
initialize_system();

while(1)
{ aaa=_getkey();
printf("%c",aaa);
putchar(aaa);
}
}
Read-Only
Author
Jon Ward
Posted
12-Aug-2002 05:24 GMT
Toolset
C51
New! RE: How can I set Uart2 to exchange data?
Since I'm not sure which chip you are using, I'll assume it's the Dallas 320. If that's the case, take a look at the following knowledgebase article:

http://www.keil.com/support/docs/1324.htm

Jon
Read-Only
Author
Jonas zhuo
Posted
12-Aug-2002 05:36 GMT
Toolset
C51
New! RE: How can I set Uart2 to exchange data?
to Jon,

Thank u first.

I use the ST Microcontroller uPSD3234A.

I can use Uart0 to exchange data with PC.

But I can't echange date with PC by Uart1.

I think my code must have some bug.
Please help me. Thank u.


Read-Only
Author
Eric VAN OLDEN
Posted
14-Aug-2002 07:37 GMT
Toolset
C51
New! RE: How can I set Uart2 to exchange data?
I think _getkey(), printf() and putchar() in the library use first Uart in a standard 8051. If you to use 2nd Uart you must write a new _getkey() and a new putchar() in your application.
Read-Only
Author
Jonas zhuo
Posted
14-Aug-2002 07:45 GMT
Toolset
C51
New! RE: How can I set Uart2 to exchange data?
Eric,

Thank you first for your suggestion.

I have rewritten the putchar() and _getkey(). But it still had no response.

I suspect the setting of my code.

Thank you again.



Next Thread | Thread List | Previous Thread Start a Thread | Settings