- Add a System Initialize block in the model. When a model includes the ‘System Initialize’ block, the ‘Simulink Code Generator’ adds external code, which is specified in the ‘SystemInitialize’ function that is generated by the block. You can specify code for the code generator to add to the declaration, execution, and exit sections of the function code. Please refer to the following link to understand more about the ‘System Initialize’ block: https://www.mathworks.com/help/releases/r2024b/rtw/ref/systeminitialize.html
- Add custom code in the ‘System Initialize’ block such that it assigns a higher priority to the ‘I2C’ block, than the ‘Interrupt’ block that drives the ‘I2C’ subsystem. This will ensure that the ‘I2C’ block can perform read or write operations effectively.
I am trying to use I2C block inside a interrupt but it not working
7 次查看(过去 30 天)
显示 更早的评论
I am using i2c module at i2c1 which works perfectly when it is in polling but i want to use inside a interrupt subroutine which is trigged from ADC end of conversion, i am using a nulceo stm32f466RE, i found a matlab link where it says somthing about these but i do not understand how to use it please help me this
0 个评论
回答(2 个)
Aabha
2025-5-6
This issue is commonly observed while using STM32 boards, where I2C is interrupt based. When the ‘I2C’ block is present inside an enabled subsystem, which is triggered by an ‘Interrupt’ block, the ‘I2C’ block does not read or write any data. This is because the interrupt which enables the subsystem has a higher priority than the ‘I2C’ block.
To fix this issue, you can try the following workaround:
The above workaround is also mentioned in the following link: https://www.mathworks.com/help/rtw/nucleo/ug/workaround-interrupt-workflow-sensors.html#mw_5d57635b-fab7-4fe7-8928-f35d11998407
I hope this helps.
0 个评论
Adit Kirtani
2025-6-3
Hi,
Kindly contact Technical Support for further assistance:
Thank you,
Adit Kirtani.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!