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 <dos.h> #include <stdio.h> #include <conio.h> #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 */ } //---------------------------------------------------------------------------------------------------------------------------------------
Unable to communicate through serial port
Started by ●July 10, 2007
Reply by ●July 10, 20072007-07-10
On Tue, 10 Jul 2007 05:15:31 -0700, in comp.arch.embedded Dibyendu <dib.mon@gmail.com> wrote:>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 > >;----------------------------------------------------------------------------------------------------------------------------------------- >snip PC stuff I would start off by using a terminal program on the PC, say terraterm, so that would rule out a problem on the PC side, and it would prove the cable is wired correctly martin
Reply by ●July 10, 20072007-07-10
> Hi,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??Did you try to look if you have data transfert on your serial line ? May be for the PC side you should start to try with a serial instead of your untested code ? (like windows hyperterminal or better tera term) Re-read your controler datasheet or try to find application notes (often availble on chip manufacturer website. Re-read the datasheet part on serial controler but not only, look for example if you need to configure the pin as a serial line and not as a standard IO, etc. Regards, Guillaume -- Guillaume Chevillot
Reply by ●July 10, 20072007-07-10
What operating system on the PC? What you describe is the DOS way of doing it. Under Windows, the ports are controlled by Windows drivers.
Reply by ●July 10, 20072007-07-10
On Jul 10, 7:55 am, martin griffith <mart_in_medina@ya___.es> wrote:> I would start off by using a terminal program on the PC, say > terraterm, so that would rule out a problem on the PC side, and it > would prove the cable is wired correctlyYes. And hold something shorting pins 2&3 of the PC cable (transmit looped back to receive) to verify that when you short them, anything you type is now displayed, or is being displayed twice if it was already being displayed once with the pins unshorted. Also, if using hyperterminal make sure you set flow control to none.
Reply by ●July 10, 20072007-07-10
On 2007-07-10, cs_posting@hotmail.com <cs_posting@hotmail.com> wrote:> Also, if using hyperterminal make sure you set flow control to none.Also, if using hyperterminal... don't. Use something reliable like teraterm. ;) -- Grant Edwards grante Yow! I am a traffic light, at and Alan Ginzberg kidnapped visi.com my laundry in 1927!
Reply by ●July 10, 20072007-07-10
In article <1184069731.211909.174350@i13g2000prf.googlegroups.com>, dib.mon@gmail.com says...> 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 > endYou haven't specified whether your board includes an RS-232 driver. If it does, does it require you to set or clear an enable pin for the driver? I would also program a nice long (perhaps 100 millisecond ) delay loop between character sends. That will make it much easier to track down the problems with an oscilloscope. Mark Borgerson
Reply by ●July 10, 20072007-07-10
On Jul 10, 10:23 am, Grant Edwards <gra...@visi.com> wrote:> On 2007-07-10, cs_post...@hotmail.com <cs_post...@hotmail.com> wrote: > > > Also, if using hyperterminal make sure you set flow control to none. > > Also, if using hyperterminal... don't. Use something reliable > like teraterm. ;)Yeah, but when a tool is so widely distributed, even if it's a very bad tool, it's worth knowing how to make it perform, because the day will come when you run into a situation where your preferred tool isn't available - co-worker's machine, customer on the phone, locked- down computer, won't let your laptop into the building, whatever.
Reply by ●July 10, 20072007-07-10
"Dibyendu" <dib.mon@gmail.com> wrote in message news:1184069731.211909.174350@i13g2000prf.googlegroups.com...> Hi, > > I am new on this field, and taking this as hobby, but the real fact<snip> It could be that the legacy serial port on your PC doesn't work properly. I'm having this problem literally right now as we speak. My P4 desktop is fine, it's old and clunky, and it's fine. My Dell laptop just reads gibberish inbetween odd bits of sense. Ah, I hear you say, install a USB<>Serial dongle. Except it won't install as anything lower than COM5, due to the infraport spoof ports which are turned off in the BIOS yet are still found. That and the internal modem, again, which keeps on installing itself. I'm using Termrite 1.5. It doesn't need installing and is 74KB in size. It's now running on a 486DX2-75 IBM 755C now used for RS232 data capture throughout this project. I despair!! We've finally reached the age where the indestructable serial port doesn't work. Aside from that lot it's probably your code but I don't code for the AVR so can't tell you. I can only tell you about what's up above.
Reply by ●July 10, 20072007-07-10
"> 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 > >Where is EI ? enable interrupts...timer won't run....