Hello Ben,
Thank you very much for your reply. I have two questions to ask now.
1. I burned your code and displayed the value I got in SSPBUF in PORTB.But all the LEDs gets on at the same time.ie FF.In the data sheet , for the buffer flag, it is given as "if BF=1,Recieve complete , SSPBUF is full". So my understanding is that, we should check the buffer flag only when we are only recieving any data. Is my understanding correct?
2. "The conditions that will set the SSPIF flag are a Transmission or Reception has taken place".This is from the data sheet . I am just going to check whether that flag is set or not.If it is set,Transmission or Reception has taken place.Thats all I am doing.Why do we need a Interrupt service there.?
I am giving my code below. This code just gives a value of FF in PORTB.Help me to solve this please....
void write_enable()
{
while(1)
{
unsigned char i;
RC1=0; //reset is 0
delay_200mS();
RC1=1;RA5=0;RC3=0;RC3=1; //reset=1;slave select=0;clock=0;clock=1;
i=0X80;
SSPBUF=i;
while((SSPSTAT & 0x01)==0); //checking buffer flag
delay_200mS();
PORTB=SSPBUF;
RA5=1;
}
}
PS*afer sending 0x80 , I am expecting a 0xc1 from the slave