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

AT89C51ED2 UART not work?

I downloaded AT89C51ED2 UART source code from ATMEL web.
when I connected from PC COM1 to AT89C51ED2 and sended a byte data, it sended a wrong byte data back.

Have some solutions about this @@?

Parents
  • 1) actually, i didnt modify source code that download from ATMEL's website.


    #include "reg_c51.h"
    char uart_data;
    void main (void)
    {
    SCON = 0x50; /* uart in mode 1 (8 bit), REN=1 */
    TMOD = TMOD | 0x20 ; /* Timer 1 in mode 2 */
    TH1 = 0xFD; /* 9600 Bds at 11.059MHz */
    TL1 = 0xFD; /* 9600 Bds at 11.059MHz */
    ES = 1; /* Enable serial interrupt */
    EA = 1; /* Enable global interrupt */
    TR1 = 1; /* Timer 1 run */

    while(1); /* endless */
    }
    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*/
    }


    2) there are a 11.0592MHz mark on the crystal.
    I can programming with ISP in this development kit board.
    So, I think the crystal is fine.

    3) scope? you mean the oscilloscope figure?
    if this is, i dont have one.
    (i have no money to buy one...sorry)

    Regard.

Reply
  • 1) actually, i didnt modify source code that download from ATMEL's website.


    #include "reg_c51.h"
    char uart_data;
    void main (void)
    {
    SCON = 0x50; /* uart in mode 1 (8 bit), REN=1 */
    TMOD = TMOD | 0x20 ; /* Timer 1 in mode 2 */
    TH1 = 0xFD; /* 9600 Bds at 11.059MHz */
    TL1 = 0xFD; /* 9600 Bds at 11.059MHz */
    ES = 1; /* Enable serial interrupt */
    EA = 1; /* Enable global interrupt */
    TR1 = 1; /* Timer 1 run */

    while(1); /* endless */
    }
    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*/
    }


    2) there are a 11.0592MHz mark on the crystal.
    I can programming with ISP in this development kit board.
    So, I think the crystal is fine.

    3) scope? you mean the oscilloscope figure?
    if this is, i dont have one.
    (i have no money to buy one...sorry)

    Regard.

Children