I am new to embedded c programing ,and have come up with this code to interface my hc05 with my AT89s52 . After programming this and burning it to my AT89s52 it is not doing anything irrespective of what i send to my Bluetooth module help.
#include<stdio.h>
#include<reg51.h>
sbit x=P2^0; sbit y=P2^1; sbit z=P2^2; char read[5]; void uart() { SCON=0x50; TMOD=0x20; TH1=0xFd; TR1=1; } void feedback() { if(x==1) {SBUF='A' while(TI!); TI=0; SBUF='H' while(TI!); TI=0; } if(y==1) {SBUF='B' while(!TI); TI=0; SBUF='H' while(!TI); TI=0; } if(z==1) {SBUF='C' while(!TI); TI=0; SBUF='H' while(!TI); TI=0; } } void main() { char i,j; x=y=z=0; i=3; j=0; delay(1); uart(); while(!RI&&i>0) { read[j]=SBUF; RI=0; j++;
} if(read[0]=='O'||read[0]=='o'&&read[1]=='N'||read[1]=='n') { switch(read[2]) { case'A': case'a': delay(5); x=1; delay(5); break; case'B': case'b':delay(5); y=1; delay(5); break; case'C': case 'c': delay(5); z=1; delay(5); break; default :delay(5); SBUF='N'; while(!TI) TI=0; SBUF='O'; while(!TI) TI=0;
} } if(read[0]=='O'||read[0]=='o'&&read[1]=='F'||read[1]=='f') { switch(read[2]) { case'A': case'a': x=0; break; case'B': case'b': y=0; break; case'C': case 'c'; z=0; break; default : } } feedback(); }
Look at the picture: www.danlhenry.com/.../keil_code.png - follow the instructions!
The thread continues: http://www.keil.com/forum/62978