Hello,
I'm working on a module I2CSlave (HW mode) that currently works well in read mode ( Master> Slave) while when it relates to writing (Slave > Master) the master fails to receive more than 2 bytes and it seems to hang at the third reading in sequence.
To read Master side I used the module I2C.BAS with this sequence :
I2C.Start
I2C.WriteByte ( SLAVE_ADDR +1) / / Slave in STATE3
I2C.ReadByte PORTB = (1) / / Slave STATE4
I2C.ReadByte PORTB = (1) / / no interrupt generated slave and master halt
PORTB = I2C.ReadByte (1)
PORTB = I2C.ReadByte (0)
I2C.Stop
I would like to know if it is correct to use the wait for the ACK to continue.
Currently Slave side are generated interrupts reception until the STATE4 ( refer to AN734/AN736 MC ) but only up to the reading of the second byte .. there is a special configuration slave side to respond with ACK to the Master ? I could not find anything about it.
I2C Slave Module
Moderators: David Barker, Jerry Messina
-
- Swordfish Developer
- Posts: 1469
- Joined: Fri Jan 30, 2009 6:27 pm
- Location: US
Re: I2C Slave Module
I've had trouble getting the I2C slave code from AN734 to work reliably... it seems there are some "undocumented states" that can appear. I think it might depend on exactly which chip you're using, as there are several MSSP hardware implementations, and I got different results depending on which chip I was using.
Check out the discussion here http://www.microchip.com/forums/m283301.aspx
That thread mentions a PICDEM System Management Kit, which you can download the example C code.
Check out the discussion here http://www.microchip.com/forums/m283301.aspx
That thread mentions a PICDEM System Management Kit, which you can download the example C code.
Re: I2C Slave Module
Hello,
is exactly my situation .. no interrupt occurs after the first reading that will allow me any kind of action in ISR routine. Before I used the 18F4685 but now even replacing it with the 18F46K22 I get the same situation.
I have to try with a '18 device that uses the logic of series '16 .. if you can you can tell me a device like that with the internal oscillator, I would save a lot of research .. if you can not thanks anyway!
is exactly my situation .. no interrupt occurs after the first reading that will allow me any kind of action in ISR routine. Before I used the 18F4685 but now even replacing it with the 18F46K22 I get the same situation.
I have to try with a '18 device that uses the logic of series '16 .. if you can you can tell me a device like that with the internal oscillator, I would save a lot of research .. if you can not thanks anyway!
-
- Swordfish Developer
- Posts: 1469
- Joined: Fri Jan 30, 2009 6:27 pm
- Location: US
Re: I2C Slave Module
I think you need to get one of the first generation 18F parts to get one that acts like a 16F does... like the PIC18F252