PIC 16F877 & I2C probleme

Hi !

I am using PIC 16F877 and i have a little prob...Any code which is written after datahi = donnee[1] doesn't work...Actually the PIC blocks ..... It must normally work but it didn't... I don't know where the error is...:-/

This is my code (I made a I2C communication): The Slave took delivery from a 5 Byte Array (This program is in the slave)

if(test_bit(sspstat,S) && !test_bit(sspstat,R_W) && test_bit(sspstat,BF) && test_bit(sspstat,D_A)) //&& !test_bit(sspstat,R_W) {

// each times I fill the Array with a char

donnee[idx] = sspbuf; idx++; set_bit(portb,6); if(donnee[4] == 0xAA) { valide = true;

} }


// In my main programm, I try to read two value from my array

set_bit (portb,0); datalo = donnee[2]; datahi = donnee[1]; //unsigned char lo = donnee[2]; //unsigned char hi = donnee[1]; set_bit (portb,2); MAKESHORT( distance,datalo,datahi);

I tried a simple addition, but unfortunately it didn't work too... Have someone an idea how i can soluce my prob ?



Reply to
Loading thread data ...

"chris" schreef in bericht news: snipped-for-privacy@z14g2000cwz.googlegroups.com...

Try this:

unsigned char lo; unsigned char hi; set_bit (portb,0); datalo = donnee[2]; datahi = donnee[1]; lo = donnee[2]; hi = donnee[1]; set_bit (portb,2); MAKESHORT( distance,datalo,datahi);

Thanks, Frank.
(remove 'q' and '.invalid' when replying by email)
Reply to
Frank Bemelman

Hi Frank !

I already tried this, the probleme is that the portb 2 haven't been set yet :-( It is possible that the probleme is due to a memory probleme ? full memory ?



Reply to

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.