We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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
http://www.keil.com/forum/docs/thread13537.asp
anyone suggest please
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";
By the way - have you connected your processor correctly to the PC? With a RS232 level converter such as MAX232? With RX, TX and GND to the correct pins?
Yes - I made the following suggestion in your other thread:
Have you tried looking at any of the samples available for download from this site, and also included with the C51 installation?
If you're going to create multiple threads on the same topic, then you should at least keep track of all the responses that you receive in all those threads...