vetinaspin
Joined: 19 Nov 2005 Posts: 5 Location: Devon, England
|
problems switching from Master to Slave in I2C |
Posted: Thu Dec 22, 2005 12:51 pm |
|
|
Hi.
I am using a PIC18F452 and for most of the time I want the PIC to act as a master on the i2c bus. Occassionally it needs to be a slave.
I initialise the i2c port with:
#use i2c(MASTER, sda=PIN_C4, scl=PIN_C3,FORCE_HW)
Later on in the code when I need to receive data from another device I try to change the I2c port by:
#use i2c(SLAVE, sda=PIN_C4, scl=PIN_C3, Address=0xA0)
But it doesn't work!! The PIC stays as a master.
If I look at the CCS listing there is no new code added where I want the change to take effect.
How do you change from master to slave and back again and why does the compiler ignore the directive?
Thanks. |
|