Hi i m finding a problem in moving SBUF value to someother variable . My Code is
serial () interrupt 4 { unsigned int ch[2]; static int i=0; if (RI) { if (i<2) { ch[i]=SBUF; i=i+1; } if (i==2){ RI=0; Move(ch[0],ch[1]); RI = 0; i=0; SBUF='M'; TI=1; } RI = 0; } if (TI) { TI = 0; } }and here is the Move Function void Move(unsigned int j,unsigned int y) { unsigned int c=0,d=0; SBUF=y; TI=1; c=j*12; c=c*(133/60); d=y*12; d=d*(133/60); c=c-86; d=d-79; SBUF=c; TI=1; }
Ralph = SBUF; will unconditionally copy SBUF to Ralph. thus your problem is NOT with Transfering SBUF value. I would really like to know what the screwy logic shown is supposed to do. Erik
Move() writes to SBUF whether it's ready or not, then upon return, SBUF is written to again whether it's ready or not.
Would you please tell me the way to do it? I always do serial communication like this i never used any protocol for it . if there is any protocol please do tell me. Thanks for help
"I always do serial communication like this ..." Really? Anyway, this very website has an example of interrupt-driven serial I/O demonstrating proper use of RI and TI interrupt bits to pace SBUF reads and writes: http://www.keil.com/download/docs/200.asp