zen bEaR
Jul 3 2008, 2:10 AM
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!
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
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
sashijoseph
Jul 3 2008, 5:09 AM
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.
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.
zen bEaR
Jul 3 2008, 10:07 AM
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?
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?
Ajay
Jul 3 2008, 10:41 PM
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
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
say2paul
Jul 31 2008, 1:43 AM
Why to change TMOD value to 0x20?
I am using TMOD 0x21 instead, please let me know what is the difference?
I am using TMOD 0x21 instead, please let me know what is the difference?
Arun Kumar V
Jul 31 2008, 3:25 AM
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
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
say2paul
Jul 31 2008, 7:05 AM
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
But I tried my code with both 20H and 21H and it is working fine with 9600 bps.
So unable to find the difference

Ajay
Jul 31 2008, 8:10 AM
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)
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)
pdi33
Jul 31 2008, 8:44 AM
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.
say2paul
Aug 1 2008, 6:48 AM
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
