electronics forum

Rules | Recent posts | topic RSS | Search | Register  | Log in

debugging AT89s52 -my whole circuit is not working


Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers -> debugging AT89s52 -my whole circuit is not working
Author Message
siva0182



Joined: 24 Jun 2009
Posts: 15
Location: singapore


Post24 Jun 2009 13:02   

at89s52 debug


I am a mechanical engineering student and having a tough time working with microcontrollers..PLease do help me solving this problem..

I have made the circuit for my AT89s52 in a PCB board and have written the .Hex file inside the controller.
The program recieves input thro serial port from the computer thro RS232 and pgm processes the input and sends suitable output to port 2..which then goes into a multiplexing circuit..
But right now my whole circuit is not working...I dont know where there is problem...
How can i measure the output of port 2.? And also how do i check if the serial port is transferring input ?(Baud rate bits etc wer same..but the for flow control type i am not sure which one i should use XOn/XoFF or None or hardware..

Any ways I am uploading my circuit diagram schematic and also the Rxd is connected to transmit pin of Rs232 and Txd is connected to Read pin of Rs232.
Also the output in the diagram is shown as port 1 but it is actually port 2.
I tried sending data thro hyperterminal..The pgms shows status as connected but the circuit is not working.

Please suggest debugging measures and methods.Also I want to verify my PCB circuit so is there any reference circuits for AT89S52.

(P.s:internal pgm has worked in previous projects.)



Sorry, but you need login in to view this attachment

Back to top
user1111



Joined: 24 Mar 2007
Posts: 56
Helped: 4


Post24 Jun 2009 13:26   

debugging at89s52


you can use Proteus software for simulation of microcontroller based circuits.
For software portion,you can use Keil or SDDC compilers.

You can use flow control NONE
Back to top
CMOS



Joined: 06 Jan 2004
Posts: 810
Helped: 39
Location: USA


Post24 Jun 2009 17:21   

at89s52 connection


What is the crystal frequency and what baud rate are you trying ?
Back to top
siva0182



Joined: 24 Jun 2009
Posts: 15
Location: singapore


Post25 Jun 2009 3:20   

at89s52 serial communication port circuit


I am using crystal frequency of 11.059200Mhz. (In the pgm soft copy it is rounded off to 12MHz )
Baud rates is 9600
Back to top
CMOS



Joined: 06 Jan 2004
Posts: 810
Helped: 39
Location: USA


Post25 Jun 2009 3:36   

Re: debugging AT89s52


siva0182 wrote:
In the pgm soft copy it is rounded off to 12MHz

Thats your problem! 11.0592 != 12MHz. You need to change the timer reload value considering 11.0592MHz crystal.

If using Timer-1 with SMOD=1, your reload value should be 0B8h and if SMOD=0, it should be 0DCh.


Last edited by CMOS on 25 Jun 2009 3:45; edited 1 time in total
Back to top
IanP



Joined: 05 Oct 2004
Posts: 6490
Helped: 1542
Location: West Coast


Post25 Jun 2009 3:43   

Re: debugging AT89s52


First of all, if 89S52 is programmed to use 11,0952MHz crystal for 9.6kbps then you have to use 11,0952MHz one as 12MHz will NOT work (unless you change the relevant Timer's reload values) ..

And second, I can't see any RS-232 line driver ..
Most common driver is the MAX232(or equivalent) ..
As an absolute minimum, you need two one-transistor inverters for RX and Tx lines ..

So, how did you connect the At89S52 to the serial port?

Rgds,
IanP
Back to top
siva0182



Joined: 24 Jun 2009
Posts: 15
Location: singapore


Post25 Jun 2009 4:21   

Re: debugging AT89s52


I am uploading the source code I have written inside the controller.
Actually the pgm was the same I used ina different similar set up and it worked.
Only the hardware has changed this time.

Regarding the Connection of serial port to RXD and TXD

I connected 16 WR to pin 2(RXD) of rs232 and 17 RD to pin 3(TXD) of RS232 directly.
There is no driver inbetween becasue i was told it would work.

I am not able to upload the .Txt or .C file.I will try the same in the next post

Added after 2 minutes:

I am attaching the source code here.ONly .doc or .pdf files get attached I did not know it before.



Sorry, but you need login in to view this attachment

Back to top
IanP



Joined: 05 Oct 2004
Posts: 6490
Helped: 1542
Location: West Coast


Post25 Jun 2009 4:28   

Re: debugging AT89s52


siva0182 wrote:

Regarding the Connection of serial port to RXD and TXD

I connected 16 WR to pin 2(RXD) of rs232 and 17 RD to pin 3(TXD) of RS232 directly.
There is no driver inbetween becasue i was told it would work.


Then you have also hardware problem ..
You need drivers (or at least inverters) on both lines (Rx and Tx) ..
See: http://www.freewebs.com/maheshwankhede/rs232.html

Rgds,
IanP



Sorry, but you need login in to view this attachment

Back to top
siva0182



Joined: 24 Jun 2009
Posts: 15
Location: singapore


Post25 Jun 2009 10:59   

Re: debugging AT89s52


thanks alot.I will try to interface using this MAX232 driver and let you know the result later..

But so far bu direclty connecting Rs232 to microcontroller have I damaged the microcontoller?

Added after 2 hours 58 minutes:

I also Found another website where they use MAX232..
http://www.8051projects.net/serial-communication/introduction.php

BUt there is no extra capacitor as shown in the above recommended circuit ie between pin 15 and pin 2 .
IS it required or not?

Also let me know if there are any more errors in the hardware and software part so that i can correct

Added after 35 minutes:

i am referring to the capacitor between 5V and Ground.IS it required?
AS I found so in one of the links refferred and did not find in the another link i have quoted above.

Added after 8 minutes:

I did refer to MAx232 specificaiton sheet and id get the typical circuit diagram which i am attaching here.
The link referred to me first has the correct circuit diagram.Sorry for the confusion

BUt there is one more problem the polarity of the capacitor in pin 6 is not shown in the first diagram and in the specification sheet shows that -ve polarity is connected to pin 6 is that correct?

Added after 16 minutes:

another confusion is do i have to use WR/RD 16 and 17 for read and write or do ihave to use RXD and TXD 10 and 11 of the micro controller for serial communication?

Added after 11 minutes:

Again another inconsistency i observed was that the pin 2 and pin 3 of Rs232 connection to MAx232 differes in the link i quoted and in the one i was referred to.
However I think the one in mahesh wankhede site seems to be correct one just wanted to check it out.
Back to top
leoren_tm



Joined: 19 Dec 2005
Posts: 649
Helped: 20


Post26 Jun 2009 5:54   

Re: debugging AT89s52


about the max232, refer to datasheets sample application....for serial communication, you only need RX and TX pin... and i think you need to do some research and read some books..
Back to top
siva0182



Joined: 24 Jun 2009
Posts: 15
Location: singapore


Post30 Jun 2009 11:41   

Re: debugging AT89s52


I did refer ro max 232 and did the wiring and then tested it using an oscilloscope.
The one I got was MAX232 CPE I hope it is same as MAax232.
I have uploaded the specification circuit of the same.However I did find in other wesites like this one
http://www.8051projects.net/serial-communication/introduction.php

I got confused and some of my frends said that using ahighere capacitor is not a problem as it will tend to give more stability so i soldered five 10 micro farads.

but now i tried sending output from hyperterminal and measure the serial output from pin 9 (as 8 is connected to rs232 transmit pin 3 of DB9) using an oscilloscope probe and grounded the probe ground pin.
I sent AA55 etc thro hyperterminal..
But i dont see any output in the scope.
Could it be because of the capacitor value i have used?

debugging AT89s52 -my whole circuit is not working
Back to top
leoren_tm



Joined: 19 Dec 2005
Posts: 649
Helped: 20


Post01 Jul 2009 1:22   

Re: debugging AT89s52


you should first measure the output at TX pin..considering your new in programming, maybe your problem is on setting up the serial com. but if you have output, then it should be easy to determine your problem.
Back to top
CMOS



Joined: 06 Jan 2004
Posts: 810
Helped: 39
Location: USA


Post01 Jul 2009 1:25   

Re: debugging AT89s52


siva0182 wrote:
But so far bu direclty connecting Rs232 to microcontroller have I damaged the microcontoller?

Yes probably your microcontroller is damaged. RS232 operates at ±12V typical (±25V max) and microcontroller's pins are not meant to handle such high voltages.

10uF capacitor should work. I use it all the time with MAX232.
Back to top
siva0182



Joined: 24 Jun 2009
Posts: 15
Location: singapore


Post01 Jul 2009 7:54   

Re: debugging AT89s52


I am not using micrcontroller now..i am just using a Rs232 cable connected to the MAX232 and measure the output using oscilloscope probe.

THe data from Rs232 enters MAx232 thro R2in and leaves out thro R2out so i measure the oupput across R2out and gnd.
But I dont get any output.
I even tried another MAx232 but still it does not work...

Added after 2 hours 41 minutes:

I removed all hardware and just tested with only the rs232 cable.
I shorted pin 2 and 3 and sent data thro hyperterminal but the data ws not returned back.
What could be the reason?
I have only one com port and so i am specifying the correct COM port.
The bottom line of hyperterminal sys it is connected.
Back to top
saDesigner81



Joined: 15 Jun 2009
Posts: 17
Helped: 1
Location: UK


Post01 Jul 2009 10:23   

Re: debugging AT89s52


siva0182 wrote:

I removed all hardware and just tested with only the rs232 cable.
I shorted pin 2 and 3 and sent data thro hyperterminal but the data ws not returned back.
What could be the reason?
I have only one com port and so i am specifying the correct COM port.
The bottom line of hyperterminal sys it is connected.


Test your cable
Back to top
siva0182



Joined: 24 Jun 2009
Posts: 15
Location: singapore


Post01 Jul 2009 12:30   

Re: debugging AT89s52


I have used the same cable in the same port of the same computer to connect to a data acquistion unit..and it did communicate properly.
Back to top
saDesigner81



Joined: 15 Jun 2009
Posts: 17
Helped: 1
Location: UK


Post01 Jul 2009 13:08   

Re: debugging AT89s52


siva0182 wrote:
I have used the same cable in the same port of the same computer to connect to a data acquistion unit..and it did communicate properly.

Do the continuity check of the cable using a multimeter
Back to top
siva0182



Joined: 24 Jun 2009
Posts: 15
Location: singapore


Post02 Jul 2009 11:46   

Re: debugging AT89s52


Pin 5 as ground
Voltages at various pins

Voltage at end of cable -0.15 at pin 1
-11.45 at pins 4,7 ,9.

Voltage on PC port -11.3 at pin 3 and 4
-11.45 at pin 7.

The remianing pins have either 0 Volt or very small voltage like 0.15 V.

I have tested the working of the port and cable by connecting the same to a Data acquistion unit and the data was read correctly.

So There is problem in the way I am using hyperterminal or I am using the wrong pins while testing using hyperterminal.

Added after 3 hours 22 minutes:

My hyperterminal does not display any characters even when echo mode is on.
Any idea on why this could be?
Back to top
Google
AdSense
Google Adsense




Post02 Jul 2009 11:46   

Ads




Back to top
CMOS



Joined: 06 Jan 2004
Posts: 810
Helped: 39
Location: USA


Post02 Jul 2009 16:15   

Re: debugging AT89s52


siva0182 wrote:

So There is problem in the way I am using hyperterminal or I am using the wrong pins while testing using hyperterminal.
My hyperterminal does not display any characters even when echo mode is on.
Any idea on why this could be?

Have you selected the right COM port and opened it? Can you post the screenshot of hyperterminal?
Back to top
siva0182



Joined: 24 Jun 2009
Posts: 15
Location: singapore


Post03 Jul 2009 11:03   

Re: debugging AT89s52


I was able to solve the hyperterminal pgm when i used a different computer.I still dont know why my first computer did not respond..(even though it was able to communicate to a DAQ instrument).

And secondly my cable was cross wired and so my max232 output was not as expected so when i changed to a custom made straight cable the output of the max232 worked in aloop back test and as well in an oscilloscope.

BUt now the output of the max232 is fed to the micro controller circuit as posted earlier.(the first post..(which had a mistake of RXD and Txd pins ..whcih i have corrected now to the correct pin 10 and 11.)..but still the circuit does not work..
I have changed to a new microcontoller fearing the old one might have died.
IS ther any problem in my micrcontroller circuit.
How do I trouble shoot the output of port 2 8 pins?
Back to top
siva0182



Joined: 24 Jun 2009
Posts: 15
Location: singapore


Post05 Jul 2009 11:50   

Re: debugging AT89s52


please can somebody reply?
Back to top
GetDeviceInfo



Joined: 30 Mar 2009
Posts: 103


Post05 Jul 2009 16:43   

Re: debugging AT89s52


Can you now read the transmitted data at the micro's Rx pin?

what's your intent on loading the SCON with 0x72 ?
your specifying a 12Mhz crystal in your code ?
Back to top
siva0182



Joined: 24 Jun 2009
Posts: 15
Location: singapore


Post06 Jul 2009 3:54   

Re: debugging AT89s52


I am able to see the output in an oscilloscope.

The SCON I really dont remember BUt I got if from a micro controller pgmming book and modified only what I want.BUt neverthless the same pgm worked in my previous project which used the same microcontroller and same program.
BUT the rest of the circuitry has been rebuilt and I am not sure of the old circuitry as I was not the one who built it alst time and I dont have the circuitry with me too..

Regarding 12 MHz I was said the computer can communicate only in round off integers like 11 or 12..and it did work last time .but now I have tried both 11.059 and 12 still it does not work...

I suspect the hardware part is the problem..

LAst time when I conected Rs232 directly would the crystal have been destroyed?
Back to top
GetDeviceInfo



Joined: 30 Mar 2009
Posts: 103


Post06 Jul 2009 17:07   

Re: debugging AT89s52


Are you ISPing this device. Are you resetting it from ISP control or at device level. Is your ISP connected? I usually reset from ISP up until things are done and the cable comes off. Reseting at device level while the cable/buffer is still connected can be unpredictable.

Quote:
LAst time when I conected Rs232 directly would the crystal have been destroyed?

what does your scope say when you check the ALE pin? It should be clocking. You can drop your EA line then observe if your external address port is advancing.
If I'm not mistaken, a reset condition halts the clock. Make sure your reset is performing.

So, with a proper reset, a clocking ALE, and a high on EA, you should then load in a simple looping routine to toggle a port pin. If that works, then I'd go straight to that baud rate issue and nail that down.
Back to top
siva0182



Joined: 24 Jun 2009
Posts: 15
Location: singapore


Post07 Jul 2009 6:36   

Re: debugging AT89s52


I finally connected 8 leds to my port 2 which is my output port and did send input thro rs232 and lo the right pins did glow according to the pgm output!!!..

So the circuit is fine pgm is fine and RS232 communication is fine...

BUt the voltage measured across the high pins were only 1.7 volt is it because of using LED? does the voltage generated on high pins dependent on the components placed at the ouput pin or should they be always 5V.(My power input is around 4.98V)
Back to top
siva0182



Joined: 24 Jun 2009
Posts: 15
Location: singapore


Post07 Jul 2009 14:52   

Re: debugging AT89s52


The voltage problem is also solved now .BEcause previously i connected the led positive to the pin and negative to the ground.
However Now I reversed the polarity and connected aresitor inbetween it shows 4.5V.
Uh..Finally after struggle for fifteen days!!!!
Back to top
leoren_tm



Joined: 19 Dec 2005
Posts: 649
Helped: 20


Post08 Jul 2009 5:49   

Re: debugging AT89s52


Very Happy that takes long...congrats anyway
Back to top
Arabic versionBulgarian versionCatalan versionCzech versionDanish versionGerman versionGreek versionEnglish versionSpanish versionFinnish versionFrench versionHindi versionCroatian versionIndonesian versionItalian versionHebrew versionJapanese versionKorean versionLithuanian versionLatvian versionDutch versionNorwegian versionPolish versionPortuguese versionRomanian versionRussian versionSlovak versionSlovenian versionSerbian versionSwedish versionTagalog versionUkrainian versionVietnamese versionChinese version
Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers -> debugging AT89s52 -my whole circuit is not working
Page 1 of 1 All times are GMT + 1 Hour
Similar topics:
working circuit not simulating (6)
the circuit not working (8)
555 circuit not working (10)
This is a working ISP cable for Atmel AT89S52 (2)
Two identical circuit boards, one working one not (2)
how offset of op affect whole circuit? (1)
current measurement of whole circuit - need help (1)
RTC Not working (5)
Printer not working (2)
AT24C1024 Not Working!!! (2)


Abuse || Administrator || Moderators || Support us || sitemap
topic RSS