This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

hi plz help i have to receive data on hyperterminal buti m no getting

i have to get data serially on hyperterminal window as well as p2.
i have checked circuit 1000 of times but not getting ny
output there.
i am using following code plz verify it.

#include<reg51.h>
void delay(unsigned int); //prototype declration of delay function
void main(void)
{

unsigned char z,X;
unsigned char mess[]="ADITYA";
TMOD=0x20;
TH1=0xFD; //9600 bits /sec
SCON=0x50;
TR1=1; for(z=0;z<6;z++) { SBUF=mess[z]; X=mess[z];
while(!TI); //check the transmit interrupt P2=X;
delay(10000); TI=0; }
}

void delay(unsigned int time)
{ unsigned int i,j;
for(i=0;i<time;i++)
for(j=0;j<100;j++);
}

please help

aditya

Parents
  • 1) In what way do you think this comment improves your code?

    void delay(unsigned int); //prototype declration of delay function
    

    2) Why test your output thousands of times? If you test five times and it doesn't work, then I would suggest another strategy than continuing to just look at the output.

    3) In what way do you not get anything? No single bit change at all on the TX pin? No change at all on P2? Have you verified if your code gets past the while (!TI) loop?

    4) Don't do delay loops as empty for constructs - you really do not know how long the delay is - it may change with compiler version, memory model, optimization level...

    5) How have you verified that you really get 9600 baud?

    6) Yes, your code is in a mess. It would look better if you read the posting instructions - available just above the text box where you enter your messages.

    unsigned char mess[]="ADITYA";
    

Reply
  • 1) In what way do you think this comment improves your code?

    void delay(unsigned int); //prototype declration of delay function
    

    2) Why test your output thousands of times? If you test five times and it doesn't work, then I would suggest another strategy than continuing to just look at the output.

    3) In what way do you not get anything? No single bit change at all on the TX pin? No change at all on P2? Have you verified if your code gets past the while (!TI) loop?

    4) Don't do delay loops as empty for constructs - you really do not know how long the delay is - it may change with compiler version, memory model, optimization level...

    5) How have you verified that you really get 9600 baud?

    6) Yes, your code is in a mess. It would look better if you read the posting instructions - available just above the text box where you enter your messages.

    unsigned char mess[]="ADITYA";
    

Children