View previous topic :: View next topic |
Author |
Message |
xlh1460
Joined: 28 Jul 2010 Posts: 10
|
I2C Slave: Detecting stop bit from master-transmitter |
Posted: Thu Dec 30, 2010 2:37 pm |
|
|
I have a master that is transmitting a variable length sequence of bytes to a slave.
I am wondering if there is any way for the slave to detect when it has received the last byte of the sequence.
I have considered using a count or termination byte but would prefer to avoid those approaches.
Any examples or tips would be greatly appreciated.
I am using compiler version V4.108
Thanks. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9273 Location: Greensville,Ontario
|
|
Posted: Thu Dec 30, 2010 3:17 pm |
|
|
You could trigger a timer watchdog subroutine, that starts when the slave sees data coming...then sets a flag 'no more data' when the data line goes idle longer than the pulse width of the data bits.
As you know the I2C bus rate in KHz, figure out the bit rate, set WDT for 1.5 to 2 bit widths. Try it and 'fine tune' as required.
It's a simple, effective way to do what you want and I've done it for almost 3 decades with up to 255 slaves per master so I know it does work! |
|
|
xlh1460
Joined: 28 Jul 2010 Posts: 10
|
|
Posted: Thu Dec 30, 2010 4:19 pm |
|
|
I was thinking more along the lines of solving this just using the MSSP module.
I have made some progress but I am starting to think your approach may end up being simpler.
Thanks. |
|
|
|