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

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*/

Parents
  • 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?

Reply
  • 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?

Children