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.
Hi everyone, In my code receive session is not working.. what changes should i made to receive a character from my keyboard?
// Program to test serial communication of controller with PC using hyper terminal #include<reg51.h> void ini() // Initialize Timer 1 for serial communication { TMOD=0x20; //Timer1, mode 2, baud rate 9600 bps TH1=0XFD; SCON=0x50; TR1=1; } void recieve() //Function to receive serial data { unsigned char value; while(RI==0); value=SBUF; P1=value; RI=0; } void transmit() // Funtion to transmit serial data { P2=P1-32; SBUF=P2; while(TI==0); TI=0; SBUF=P1; while(TI==0); TI=0; } void main() { while(1) { ini(); recieve(); transmit(); } }
Thank in advance
Isn't that effectively saying that all of the standard 'C' string functions are "inherently dangerous"...?! well, replacing say 100 - I did not count - strcpy in a project with strncpy made 3 functions dysfunctional i.e. a buffer overflow was there with strcpy.
Erik