Hello,
I resolved the issue. I think my issue is a combination of execution order and power line noise.
I first used tips from https://community.nxp.com/thread/449904#comment-899761 to make sure that execution order is correct.
Then FreeMaster somehow worked.
Then I was encountering the same problem documented in Event ReadHallSensors Count and Crash
I turned on the filtering option as documented. Then it works fine.
Thanks dumitru-daniel.popa and jjacp for the great material, tips, and discussion.
I think a great take away is that even we are modeling stuff using more user-friendly MBD tool, we still need to keep in mind that execution order does matter. Especially, for peripheral units, initialization first, operation second. We still encounter the noise issue, which does not disappear because we transferred from C code and IDE to MATLAB MBD.
Sincerely,
Yujiang Wu