- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I need to read an I2C slave device in a pin ISR in order to avoid a polling in main(). I can read the I2C slave from main() without any issue, but when I run exactly the same code in pin ISR to read the I2C slave device, the read function never returns.
What would be wrong? Is it because I2C reading also generate an interrupt that is blocked by current pin ISR?
Thanks,
Winston
Solved! Go to Solution.
- Labels:
-
PSOC5 LP MCU
- Tags:
- I2C ISR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @yaga_3967241,
Are you using the pin interrupt only for checking activity on the bus? You can do so by enabling the callback function in the cyapicallback.h file. There is an exit callback present in the I2C code, please see I2C_INT.c file for more details. The I2C_1_ISR_ExitCallback(); function is called by the component if I2C_1_ISR_EXIT_CALLBACK is defined in cyapicallback.h.
If you still wish to do so with the pin, the issue might be with the interrupt priority and on how it is handled. Please make sure that you clear the pin interrupt and disable the interrupt as soon as there is any activity so that it does not trigger again during a read cycle. You can also change the interrupt priority by going to the interrupts tab in design wide resources to make sure that I2C interrupts have a higher priority than Pin interrupt.
Best regards,
Hari
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @yaga_3967241,
Are you using the pin interrupt only for checking activity on the bus? You can do so by enabling the callback function in the cyapicallback.h file. There is an exit callback present in the I2C code, please see I2C_INT.c file for more details. The I2C_1_ISR_ExitCallback(); function is called by the component if I2C_1_ISR_EXIT_CALLBACK is defined in cyapicallback.h.
If you still wish to do so with the pin, the issue might be with the interrupt priority and on how it is handled. Please make sure that you clear the pin interrupt and disable the interrupt as soon as there is any activity so that it does not trigger again during a read cycle. You can also change the interrupt priority by going to the interrupts tab in design wide resources to make sure that I2C interrupts have a higher priority than Pin interrupt.
Best regards,
Hari
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Hari,
I am not using the pin interrupt for checking the activity on the I2C bus. It is the reverse: when a pin interrupt happens, I need to read I2C register. The pin has no relation to I2C directly, it just indicates some work needs to be done, and one of the work is to read an I2C device. In this case, is there any good solution to do it?
I will try the approach in your second paragraph.
Thanks,
Yan