EmbeddedRelated.com
Forums

Unable to communicate through serial port

Started by Dibyendu July 10, 2007
mc wrote:
> 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. > > >
Yes, but virtual DOS session detects that DOS program is trying to communicate to COM port and simulates that. If Windows simply locked up DOS programs, they would not work. I seen programs written in 1988 working under Win2k and WinXp and happily communicating over COM1.
Dibyendu 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 > > ;----------------------------------------------------------------------------------------------------------------------------------------- > > 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 */ > } > > //--------------------------------------------------------------------------------------------------------------------------------------- >
How are you providing the code in ROM? The 89C52 requires code to be in code memory. PSEN is used to select the external ROM. EA must be at +5V. If internal program memory is used, EA must be grounded. Do you program an EPROM? What? How? If you are trying to use internal memory, what are you programming it with? As mentioned earlier, IE must be set (MOV IE,#90H), also CLR PCON.7 to set SMOD = 0 (NEVER assume reset *really* inits values needed for control or port operations). A better test would be using an 8K EPROM with BASIC-52 loaded since it will talk back to you and can be downloaded. Any of several other monitors can be downloaded also. See the code lib at www.8051.com for BASIC-52 or for a simple RS232 Interfacing program to echo it's received data from the PC.
cs_posting@hotmail.com wrote:
> On Jul 11, 10:47 am, David Brown <d...@westcontrol.removethisbit.com> > wrote: > >> There are also times when you might have to use a cigarette lighter as a >> soldering iron. It might be better than nothing, but it's not exactly >> the tool of choice! > > To compare the usability of hyperterminal to the utility of a > cigarette lighter as a soldering iron is rediculous. Compare it to > some $4 soldering iron from radio shack. Not great, but easy to get a > hold of and usually practical... even for SMD if you are really really > careful. >
That's certainly a more realistic comparison - but I think mine was a little more colourful! I did once use a cigarette lighter for soldering, but thankfully it was just a few wires and not SMD...
On Jul 13, 6:55 am, David Brown <da...@westcontrol.removethisbit.com>
wrote:

> That's certainly a more realistic comparison - but I think mine was a > little more colourful! I did once use a cigarette lighter for > soldering, but thankfully it was just a few wires and not SMD...
I'm getting severly tempted to scare up a junk board at lunchtime, spread some paste, drop an 8 pin SMD package in it, and see if I can reflow it with a cigarette lighter as a heat source. Except that the new car doesn't have one... it has an accessory jack with a little plastic door and no lighter in it. Now what am I going to do when I need to make emergency repairs????
On Jul 13, 6:49 pm, cs_post...@hotmail.com wrote:
> On Jul 13, 6:55 am, David Brown <da...@westcontrol.removethisbit.com> > wrote: > > > That's certainly a more realistic comparison - but I think mine was a > > little more colourful! I did once use a cigarette lighter for > > soldering, but thankfully it was just a few wires and not SMD... > > I'm getting severly tempted to scare up a junk board at lunchtime, > spread some paste, drop an 8 pin SMD package in it, and see if I can > reflow it with a cigarette lighter as a heat source. > > Except that the new car doesn't have one... it has an accessory jack > with a little plastic door and no lighter in it. > > Now what am I going to do when I need to make emergency repairs????
**************************************** **************************************** **************************************** **************************************** Hi all, I had got success. (Because of the expert help from you all). ....... :-) ****************************************
>**************************************** >**************************************** >**************************************** >**************************************** > >Hi all, >I had got success. (Because of the expert help from you all). > >....... :-) >**************************************** > >
Hey ^^;; i'm new to this forum and also just started embedded programming. I studied 68HC11 and 68HC12 in uni but at home i'm using a 8051. My uni project that i'm thinking of doing involves serial port programming + assembler and socket programing. I have a few knowledges of everything and kinda have an idea of how to put things together. At the moment, i'm trying to get my 8051 board + relays to control 2 AC servos. I'm thinking of controlling it through the computer and then further on i would control it over the net with the help of socket programming. Do you know any good books that might help? I'm struggling with the serial port signal from PC to programming board too. Is it corrected to sort RTS and CTS on PC side? Also, thank you for posting this thread and your draft program. I'm using it as a reference to build my own now.