- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hallo,
I wish to find a solution for an issue that I often found when using I2C bus. If I configure my PSOC as an I2C master and try to 'talk' on a connection where no slave is present or where a slave is in some critical condition the whole system hangs. Of course I can detect this by using the internal watchdog and disable the I2C hardware but in some cases this's not a good solution since it will disable also coomunication with slaves that are currently working. It's possibile to prevent this hang-over? It's possible to define a custom function to inspect the bus for 'working' slaves before starting the real communication?
Best Regards,
Michele Santucci
- Labels:
-
PSoC 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can use the low level function fSendStart to check if a Slave ACKed the start condition and then use high level functions only if the slave was present. Following are the steps.
1. Use fSendStart and see if the Slave ACKs. If no ACK, send a Stop and release the bus
2. If Slave ACKs, send a stop to release the bus, re-enable the I2C interrupt (as fSendStart disables the I2C interrupt), and start using the high level API
Check out the project here.
Interfacing an I2C EEPROM to PSoC
This project shows a method to use the fSendStart function to poll if a slave is active on the bus before using a high level API.
Best Regards,
Ganesh
The PSoC Hacker
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Those are some good points to prevent stalling of the CPU when I2C is involved.
But I did face some issues when the software I2C module is used (I2Cm user module).
Specifically, any command after I2Cm_fSendStart is not executed.
Any thoughts on this anyone?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you please create a small project (preferably for a 29466) which creates that issue to have a look on it?
Think it would clarify what exactly doesn't work as you expect.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Would you happen to have a CY3240 and the little I2C slave board with you? I have a project for this hardware combination.
If not, I'll port to 29466 and post it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No, no 3240 avail.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have up to six slaves on a board and I would like to know which ones are present. I implemented the routine and code suggested above but every thing hangs up after the the master recieves an ACK from 4th slave and. The routine hangs in during the I2CHW_fSendStart for the 5th slave.
Any Ideas or help?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a similiar problem, using I2Cm module. If the slave clock or data
line is disconnected the firmware hangs in the clockstretch2 asm routine
the module uses. I have a Tech Case being looked at by Cypress. I will
pass on this thread to them.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Have you received any information back from cypress on solving this problem?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, the SW team is going to, in the next release, date unknown, implement
a timeout function associated with the I2C clocking routines.
This will fix disconnected pins, SCL, SDA, pullups, from hanging main().
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Dana, I know that this is an old post but I seem to have a similar problem with the IIC bus hanging. It hangs in the
uint8 SensorIIC_MasterReadByte(uint8 acknNak) subroutine on the line while(SensorIIC_WAIT_BYTE_COMPLETE(SensorIIC_CSR_REG))
Do you know if the timeout function has been implemented yet?
Best Regards
Stephen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Stephan,
Timeout has not been implemented, since I2C has no specification on the time limit.
I would like to point you to the discussion in this thread:
I2CHW - SDA line low problem - detection and solution
Best regards,
Sampath
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There is some more information about I2C "hangs" at http://www.mbedded.ninja/programming/microcontrollers/psoc/components#i2c (and how to overcome them).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a similar problem and I've been looking through the include files. If you change this #define to 1, #define I2C_TIMEOUT_ENABLE (1u) then it compiles in this function: #if (I2C_TIMEOUT_ENABLED) I2C_TimeoutStop(); #endif /* End (I2C_TIMEOUT_ENABLED) */ which is undefined. Can't seem to find this in the docs, but I'm assuming we're meant to implement I2C_TimeoutStop for cleanup in our main? thanks, Johann
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Johann, refer to the answer SAMP.CY gave: Timeout is not implemented.
On the other hand: A timeout would break the standards for I2C. A timeout was never defined in the protocol.
When a running connection dies and your code hangs in the I2C communication, you can reboot your machine (using WDT).
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Bob,
No, you cannot always just reboot to solve an I2C hang. When the communicator is also running a BLE session, a reboot closes the session and leaves it hanging. We need a clean way to keep I2C from hanging in the first place. FIX THE PROBLEM.
Right now I am fighting to interface a Nordic nRF51422 BLE as I2C master with a CY8C20666A/EzI2Cs slave. The Cypress part hangs with both SDA and SCL low every time the Nordic writes a single byte to the bus. Nothing but a full system reset gets it started again. I am starting to see why all the SWD interfaces abandoned I2C protocol.
Steve