Keil Logo

Use 8051, How to transfer the correct signal and check it in putty

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

Details Message
Author
Y William
Posted
29-Apr-2019 00:15 GMT
Toolset
C51
New! Use 8051, How to transfer the correct signal and check it in putty

I used the KEIL software to program the AT89C51ED2 chip, and I used the USB port to view the data transfer by PUTTY. But in the PUTTY, I can't get accurate information.

The code looks fine, the COM port is also set successfully, there was no problem with the connection of the circuit, but there has a problem in the display of putty.

In the PUTTY, according to ASCII. enter a should get b. but in here a got q, b got r, d got t, and GPRMC got w\SM{

is UART have the problem? or the timer? or other......

There are some code below here

#include<reg51.h>
char uart_data;
/**
 * FUNCTION_PURPOSE: This file set up uart in mode 1 (8 bits uart) with
 * timer 1 in mode 2 (8 bits auto reload timer).
 * FUNCTION_INPUTS: void
 * FUNCTION_OUTPUTS: void
 */
void main (void)
{
PCON=0;
SCON = 0x50; /* uart in mode 1 (8 bit), REN=1 */
TMOD =  0x20 ; /* Timer 1 in mode 2 */
TH1 = 0xFD; /* 9600 Bds at 11.059MHz */
TL1 = TH1; /* 9600 Bds at 11.059MHz */
ES = 1; // Enable serial interrupt
EA = 1; /* Enable global interrupt */
TR1 = 1; /* Timer 1 run */
while(1); /* endless */
}
/**
 * FUNCTION_PURPOSE: serial interrupt, echo received data.
 * FUNCTION_INPUTS: P3.0(RXD) serial input
 * FUNCTION_OUTPUTS: P3.1(TXD) serial output
 */
void serial_IT(void) interrupt 4
{
if (RI == 1)
{ /* if reception occur */
 RI = 0; /* clear reception flag for next reception */
 uart_data = SBUF; /* Read receive data */
 SBUF = uart_data; /* Send back same data on uart*/
}
else TI = 0; /* if emission occur */
} /* clear emission flag for next emission*/
Author
Andrew Neil
Posted
29-Apr-2019 09:35 GMT
Toolset
None
New! RE: is UART have the problem? or the timer?

"Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see:

http://learn.sparkfun.com/tutorials/serial-communication

So how have you checked that your UART is really operating at the baud rate you think it is?

The easiest check is to transmit 'U' continuously, and look at the waveform on an oscilloscope.

Author
Y William
Posted
7-May-2019 15:06 GMT
Toolset
C51
New! RE: is UART have the problem? or the timer?

Hello, Thank you for your prompt, I used the oscilloscope to view the U waveform. I was trying RX and TX pin. there have 8 square waves are displayed on the oscilloscope. But the last square wave occupies a wider range than before.
when I try UU or UUUUU, there have 13 and 28 square waves, The last square wave also takes up more range than the previous square wave.
Do you know why this happens?

Author
Andrew Neil
Posted
7-May-2019 22:21 GMT
Toolset
None
New! RE: I used the oscilloscope to view the U waveform

Look again at that Sparkfun page:

http://learn.sparkfun.com/tutorials/serial-communication

It shows you how to interpret the waveform ...

Author
Y William
Posted
9-May-2019 03:59 GMT
Toolset
C51
New! RE: I used the oscilloscope to view the U waveform

I looked at the waveform on the website, when I check waveform on my oscilloscope and given the time pressure.

is that despite that set the baud rate to 9600, i.e. the bit time should be 104 microseconds, the scope shows that the duration of each bit is ~4*104 us.

Even by changing the baud rate, the duration of the transmitted bits seem to remain the same...which is strange

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

  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.