Unable to communicate through serial port

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 */ }

//---------------------------------------------------------------------------------------------------------------------------------------

Reply to
Dibyendu
Loading thread data ...

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 to
martin griffith

Hi

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 to
Guillaume Chevillot

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 to
mc

Yes. 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 to
cs_posting

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 to
Grant Edwards

;-----------------------------------------------------------------------------------------------------------------------------------------

You 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 to
Mark Borgerson

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 to
cs_posting

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 USBSerial 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 to
Aly

"> The code for the board:

;-----------------------------------------------------------------------------------------------------------------------------------------

Where is EI ? enable interrupts...timer won't run....

Reply to
TT_Man

;-----------------------------------------------------------------------------------------------------------------------------------------

Hi, I am trying to follow the books of Mazidi, to build this board and code also.

At the first glance I has not find the use of EI. I think I have to read more (In depth also). keep in touch.

thanks.

Reply to
Dibyendu

Windows XP is my operating system. is it the main problem?? I had tried by hyperterminal program first but failed too. thanks

Reply to
Dibyendu

;-----------------------------------------------------------------------------------------------------------------------------------------

I am using MAX 232 chip with 22uF electrolyte capacitor, as it described on the 8051 Books of Mazidi and max 232 data sheets.

Waiting for your response.

Reply to
Dibyendu

This is very good idea I am trying it by today evening. thank you

Reply to
Dibyendu

Of course it will run. It just doesn't produce interrupts...

Meindert

Reply to
Meindert Sprang

I rarely use hyperterm in dev environment but I couldn't count the number of times its saved my arse in the field.. :)

Reply to
The Real Andy

Find out which end is failing first. Use a loopback on your PC (pin 2 connected to pin 3) and make sure PC is working. Once that is verified you know where to look.

Reply to
The Real Andy

I am fabricate the board for myself.

Reply to
Dibyendu

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!

So the recommendation is to drop hyperterminal if you possibly can, and use something simple and decent like Tera Term. Hyperterminal *may* work, but why add more uncertainty to your problems?

Reply to
David Brown

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.

Reply to
cs_posting

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.