-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nordic RF52 does not correctly support simultaneous use of I2C and SPI #4357
Comments
cc @nvlsianpu @pan- |
Thank you for describing this bug. |
@nvlsianpu, we are experiencing the same bug here as well. Is there a patch to solve this issue? I tried taking the latest code but the problem is still there. |
@NeilMacMullen , I also tried your solution (modifying the i2c_init), but it didn't work for me. Is there something else I can try? Which version did you base your patch on? |
did you test the path #4491? |
I've tried c416fdf, after you added the central resource manager. It still doesn't work (both I2C and SPI). |
It seems like the system hangs with your branch when I call "wait". |
@nvlsianpu - apologies, I didn't get any notification of #4491 so have only just seen this change. @shayo - I will try this here and let you know whether it works for me. |
@nvlsianpu @shayo I agree that this seems at first sight to be broken. I did... "git pull origin pull/4491/head" in a new project then verified that the i2c_api file does include the latest changes then copied my application source to the new project and built it. In my case, the symptoms are that "i2c->write(address, NULL, 0);" returns 0 for any address, indicating that the entire bus is populated with devices. The same code without these changes (and with my original workaround) correctly identifies the few I2C devices I have on the bus. |
@NeilMacMullen , which branch/version did you apply your changes to? |
@nvlsianpu, any news on this? |
@shayo -see the comment on the PR - looks like there will be another attempt at this. |
Status in progress: #4491 (comment) |
@NeilMacMullen Are you able to test whether #4634 fixes the issue? |
Use serial-box of Nordic nRF5 SDK to share resource between SPI and I2C. SPI is allocated from highest hw instance number resource in order to allocate as many I2C instances as possible.
@nvlsianpu - sorry for not getting back to you earlier. Unfortunately #4634 also appears to have problems. Although I can successfully now detect I2C devices on the bus and also use a serial flash on the SPI bus, the application appears to crash on a subsequent call to Thread::wait. This does not occur with my original changes on earlier mbed. |
@nvlsianpu - actually the issue above may be a red herring. It looks like something else has changed between 4.5 and 5.5 to break my application. |
OS 5.5 upgrades to the latest CMSIS version, CMSIS5, including the CMSIS-RTOS2 kernel. So changes were big. Did you tried latest minor release 5.5.1? |
@nvlsianpu I've raised this issue as #4686 - it appears to be a regression on the Serial driver. |
…ultaneously Fix the issue #4357: NRF52 doesn't support simultaneous use of I2C and SPI.
Use serial-box of Nordic nRF5 SDK to share resource between SPI and I2C. SPI is allocated from highest hw instance number resource in order to allocate as many I2C instances as possible.
What's the status of the issue? We are also experiencing weird problems with I2C interface that might be explained by this issue (branch based on mbed-os 5.4.7). It looks like this issue was fixed in PR #4634, but this issue is still open. Is there a reason for this? |
@seppestas Sorry not to reply earlier. From my testing the issue appears to be resolved on 5.6. Having said that, I am interested in the nature of the problems you are seeing. We still see a high level of I2C failures and SPI lockups even with this fix. I'm still trying to establish whether this is actually a hardware issue or further issues with software/digits. |
This is what I have on output form ci-test-shield test for concurrent I2C/SPI verification (see https://github.com/ARMmbed/ci-test-shield/blob/master/TESTS/concurrent/Comms/Comms.cpp): I ran it by hand for mitigating any IF firmware problems we have. |
Thanks @NeilMacMullen and @nvlsianpu for the updates |
Mbed OS 5
Target UBLOX_EVK_NINA_B1
Toolchain GCC_ARM
The Nordic RF52 SoC uses digital 'TWI' control blocks to control both I2C and SPI. When declaring an I2C object, the Nordic platform code in targets/TARGET_NORDIC/TARGET_NRF5/i2c_api.c uses the method "i2c_init" to allocate the first available TWI by examining previously-allocated I2C instances. Similar code is used in the SPI drivers (spi_api.c) where previously-allocated SPI instances are checked.
This approach fails when allocating a mixture of I2C and SPI instances since both _init methods then consider TWI0 to be available and allocate it to both the I2C and SPI interfaces. This leads to unpredictable results when the interfaces are used.
If you only have a single I2C and SPI instance, it's possible to work around this by forcing one of the allocators to allocate TWI1 (example code below) but the correct fix would be to implement a central allocator which would be used for both types of interface.
Copying @MarceloSalazar by request
The text was updated successfully, but these errors were encountered: