8051 Microcontroller Projects AVR PIC Microcontroller Projects Tutorials Ebooks Libraries, interfacing tutorials, lcd tutorial, stepper motor, dc motor 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems

 
8051 microcontroller 8051 microcontroller
Forums

Moderators: Ajay, Junied , abbas1707, Arun Kumar V, pdi33, Shailesh NAYAK, ۞ TPS ۞, shyam, sashijoseph
Author Post
zen bEaR
Thu Jul 03 2008, 02:10AM

 User Offline
Registered Member #4494
Joined: Tue Oct 23 2007, 01:59AM

Posts: 15
Thanked 0 times in 0 posts
Hi guys, I've been having problems getting my 8052 to communicate serially. I have a handmade board with a max 232 and 8052 and other supporting circuitry.

I am trying to use windows (xp) hyper terminal to send/ receive data serially.
This is what I do to setup hyperterm:
New connection(enter some name)>select com1>Properties(bits per sec=9600,data bits=8,parity=none,stop bits=1,flow control=none)> Now we have a window with a cursor thats blinking.

Then I go to File>Properties >and under ascii settings I say echo typed characters locally

The program I have written sends the word ALOHA continuously at 9600 bits per sec to the serial port( see code). It simulates correctly in keil micro vision 3 and I can see that it sends ALOHA continuously in the serial window.

My hardware seems to be fine- to test it I short the Tx and Rx pins (10 and 11) after removing the microcontroller from its zif socket in my board and type something in hyper term and it echoes back. So max 232 seems to be fine.

despite doing this I have had no luck Am I doing something wrong or stupid? Any help would be very much appreciated. This thing is driving me nuts!


CODE:
#include <reg52.h> //

void main(void)                   //main function
{       
    unsigned char sdat[5]={"ALOHA"};
    unsigned char m;
        TMOD=0x21;
    TH1=0xFD;       /* 9600 baud rate*/
    SCON=0x50;      /* 8 bit uart        */
        IP=0x32;        /* highest priority to serial int*/  
        TR1=1;          //start serial data timer
        while(1)
        {
        TI=0; //clear flag
        for(m=2;m<5;m++)
        { SBUF=sdat[m];
           while(TI==0);    //wait till byte is txed
          TI=0;
        }
   }
}// belongs to main     

 





[ Edited Thu Jul 03 2008, 10:42PM ]
Back to top


sashijoseph
Thu Jul 03 2008, 05:09AM

 User Offline
Registered Member #5870
Joined: Mon Feb 04 2008, 06:26PM

Posts: 501
Thanked 114 times in 107 posts
Change TMOD value to 0x20.
Are you using a 11.0592 MHz xtal?
Is your micro working at all?Insert a small led blinky in your code and see if the led blinks... this would confirm that the 8052 is indeed working.

Let there be music........
Back to top


zen bEaR
Thu Jul 03 2008, 10:07AM

 User Offline
Registered Member #4494
Joined: Tue Oct 23 2007, 01:59AM

Posts: 15
Thanked 0 times in 0 posts
yikes! my mistake..the db9 pin no 5 wasnt grounded thank you for the reply

ok..but I still have a problem. Now that my MCU works fine (its now displaying data in hyper term) I want to write a short program on my pc to send data to my MCU. using C doesnt work (outportb()) since i am using win xp. I dont have win 98 or 95 and dont want to install it either... is there a way to "unlock" the ports on my comp so that i can use them in a c program i write while using xp?
Back to top


Ajay
Thu Jul 03 2008, 10:41PM
Rickey's World Admin

 User Offline

Registered Member #1
Joined: Fri Feb 24 2006, 04:56AM

Posts: 3533
Thanked 646 times in 610 posts
there is something called porttalk which unlocks your ports.

Porttalk Driver download:
http://www.beyondlogic.org/porttalk/porttalk.htm

Porttalk installation info (can also be found on download page):
http://www.qsl.net/dl4yhf/winpic/install_porttalk.htm



www.rickeyworld.info
If you feel satisfied with the user's forum reply please click on the thank button.

Obey forum rules!
Respect others!
Back to top


say2paul
Thu Jul 31 2008, 01:43AM
 User Offline
Registered Member #8461
Joined: Tue Jun 17 2008, 10:56AM

Posts: 123
Thanked 6 times in 6 posts
Why to change TMOD value to 0x20?

I am using TMOD 0x21 instead, please let me know what is the difference?
Back to top


Arun Kumar V
Thu Jul 31 2008, 03:25AM

 User Offline
Registered Member #426
Joined: Sun Jan 28 2007, 11:50PM

Posts: 379
Thanked 156 times in 128 posts
Hi Say2 paul,

there is a lot of difference !

with TMOD as 20H(0x20), you are using timer1 in mode2 ( 8 bit) auto reload mode to generate baudrate and timer0 is not initialized (not used/set)

with TMOD as 21H(0x21), timer1 is used as above and timer0 is also used but in mode1( 16 bit )


hope you got the idea !


Arun
Back to top



This post has been thanked 1 time
 say2paul 
say2paul
Thu Jul 31 2008, 07:05AM
 User Offline
Registered Member #8461
Joined: Tue Jun 17 2008, 10:56AM

Posts: 123
Thanked 6 times in 6 posts
mmm a bit

But I tried my code with both 20H and 21H and it is working fine with 9600 bps.

So unable to find the difference
Back to top


Ajay
Thu Jul 31 2008, 08:10AM
Rickey's World Admin

 User Offline

Registered Member #1
Joined: Fri Feb 24 2006, 04:56AM

Posts: 3533
Thanked 646 times in 610 posts
well TMOD just configure your timers,

20 means Timer 1 mode 2 and Timer 0 mode 0

21 means Timer 1 mode 2 and Timer 0 mode 1

timers will only get activated when u set their corresponding Timer Run Control Bit (TRx)

www.rickeyworld.info
If you feel satisfied with the user's forum reply please click on the thank button.

Obey forum rules!
Respect others!
Back to top


pdi33
Thu Jul 31 2008, 08:44AM

 User Offline
Registered Member #1329
Joined: Mon Jun 04 2007, 09:28AM

Posts: 558
Thanked 113 times in 109 posts
say2paul wrote ...

mmm a bit

But I tried my code with both 20H and 21H and it is working fine with 9600 bps.

So unable to find the difference


hi say to paul,
by changing the TMOD from 20h to 21h, u are changing the configuration of the timer0 only,but ur serial baud rate is determined by timer1 and is independent of timer0 configuration. so u did not find the difference.
u will find the difference only when u are using the timer0 for some other purpose.

* inspired to develop,developing to inspire *
Back to top



This post has been thanked 1 time
 say2paul 
say2paul
Fri Aug 01 2008, 06:48AM
 User Offline
Registered Member #8461
Joined: Tue Jun 17 2008, 10:56AM

Posts: 123
Thanked 6 times in 6 posts
pdi33 wrote ...

say2paul wrote ...

mmm a bit

But I tried my code with both 20H and 21H and it is working fine with 9600 bps.

So unable to find the difference


hi say to paul,
by changing the TMOD from 20h to 21h, u are changing the configuration of the timer0 only,but ur serial baud rate is determined by timer1 and is independent of timer0 configuration. so u did not find the difference.
u will find the difference only when u are using the timer0 for some other purpose.



Thanks pdi33, now I got it
Back to top


 

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System

8051 Microcontroller Projects 8051 AVR tutorials PIC microcontroller, 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems