Hello,
I can’t use the interrupts for an i2c interface on an MBED nucleo-L432KC:
I manage to interface an i2c display in the “main” of the program, in particular via the “write” instruction (or all routines that use this i2c instruction). I used for this the lib_LCD_i2c_SPTLYI library with some minor modifications (to address the correct ports and adapt the frequency of the i2c bus).
But when I call the “write” instruction in an interrupt routine (a “Ticker”) the i2c interface no longer works.
I checked the electrical signals on the “scl” and “sda” lines, when I use the “write” instruction in a “Ticker” routine I observe a pulse sequence on the “scl” pin, then this pin remains low for a few hundred ms, in this case the display does not take into account the command. The “scl” pin should immediately return to high after sending the instruction (and returning ack).
I specify that the i2c bus works with the same library and “write” instructions in a “Ticker” routine on an MBED LPC1768.
If you have an idea on the origin of the problem I am interested.
Marc.
Hi,
what version of mbed library do you use? And do you use also same version with both boards (LPC1768 and L432KC)?
No serial output with an error?
Edit:
Usually the methods for write and read of peripherals (like are I2C, CAN, SERIAL and so on), are protected with a Mutex because of the RTOS (thread-safe).
When you check the write method of I2C, you will see the lock and unlock methods are called.
Finally, the Mutex are not allowed in interrupt context, it is not interrupt-safe.
- all of the above applies to RTOS - MbedOS 5.11+ (I not remmember correct number)
- maybe it will be possible with Mbed OS bare metal because there is no RTOS = no mutexes
- you can solve that with EventQueue
- In the past it was possible in older version of MbedOS 5 and MbedOS 2.
BR,Jan
Thank you for your reply,
I had used the LPC1768 in November 2018, I do not currently have access to it.
The lib_LCD_i2c_SPTLYI library is version 13 of May 2, 2018 in both cases.
I just did a test with the mbed library version 170 of September 6, 2018 (the same version as for the LPC1768), it does not work better.
I have a feeling that the mbed library does not know the EventQueue instruction.
I have never used the mbedOS library.
Marc.