Hi,
I am new on this field, and taking this as hobby, but the real fact is, I can't communicate my 8051 microcontroller board to my PC via serial port. can any body help me for that issue??
Specification of my board:
8051 microcontroller: AT89C52 24pc. Cristal Oscillator: 11.0592 Mhz. Compiler: Keil.The code for the board:
;----------------------------------------------------------------------------------------------------------------------------------------- org 0 mov TMOD, #20H ;timer 1, mode 2 mov TH1, #-3 ;9600 boud rate mov SCON, #50H ;8-bit, 1 stop bin, REN enabled setb TR1 ;start timer 1
again: mov SBUF, #"X" ;letter "X" to be transferred
here: jnb TI, here ;wait for the last bit clr TI ;clear TI for next char sjmp again ; keep sending "X" ret end
;-----------------------------------------------------------------------------------------------------------------------------------------
On the PC side I am using a simple "turbo C" code [Downloaded :-) ] like:
//--------------------------------------------------------------------------------------------------------------------------------------- #include #include #include
#define PORT1 0x3F8
void main(void) { int c; int ch; outportb(PORT1 + 1 , 0); /* Turn off interrupts - Port1 */
/* PORT 1 - Communication Settings */
outportb(PORT1 + 3 , 0x80); /* SET DLAB ON
*/ outportb(PORT1 + 0 , 0x0C); /* Set Baud rate - Divisor Latch Low Byte *//* 0x0C = 9,600 BPS */
outportb(PORT1 + 1 , 0x00); /* Set Baud rate - Divisor Latch High Byte */ outportb(PORT1 + 3 , 0x03); /* 8 Bits, No Parity, 1 Stop Bit */ outportb(PORT1 + 2 , 0xC7); /* FIFO Control Register */ outportb(PORT1 + 4 , 0x0B); /* Turn on DTR, RTS, and OUT2 */ printf("\nSample Comm's Program. Press ESC to quit \n");
do { c = inportb(PORT1 + 5); /* Check to see if char has been */ /* received. */ if (c & 1) { ch = inportb(PORT1); /* If so, then get Char */ printf("%c",ch); } /* Print Char to Screen */
if (kbhit()) { ch = getch(); /* If key pressed, get Char */ outportb(PORT1, ch); } /* Send Char to Serial Port */ } while (ch !=27); /* Quit when ESC (ASC 27) is pressed */ }
//---------------------------------------------------------------------------------------------------------------------------------------