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

help: how to setup serial port baud rate using T2

hi, all. I am a new comer to 8051.
It seems that I have problem in generating the baud rate of 19200 for serial port using timer 2. The uC is AT89C52. here is my code:

#include <at89x52.h>
#include <stdio.h>

void SPortISR (void) interrupt 4
{
unsigned char i = 0;
putchar (i);              /* output character i*/
TI = 0;                   /* clear flag */
}

void main (void){
T2CON = 0x34;             /* Set T2 Mode 1  */
RCAP2H = 0xFF;
RCAP2L = 0xEC;            /* RCAP2 = 65516  */
TH2 = RCAP2H;
TL2 = RCAP2L;

SCON = 0x50;              /*set serial port mode 1 */
ES = 1;                   /*Enable Serial Port interrupt*/
EA = 1;                   /*Enable Global Interrupt */
}
Can anyone figure out the problem? How to check the serial port output?
I would also like to know if there is any similar example.
thanks a lot.

0