Hallo,
I've an application using the FTM Input Edge Capture Block to measure the tooth of a crankshaft. Within the model is also an ADC Block to measure the voltage of the passive crankshaft sensor. The application is working in Freemaster and with an oscilloscope.
Below a screenshot of the timestamp from the FTM Input Edge.
I've encountered two issues that I need help with.
Issue #1
As soon as I add a FTM Input TOR ISR to the model, the FTM Input Edge Capture appears in the application to generate rubbish (Freemaster + Oscilloscope). Generally it looses all connection to the board in Freemaster as well. The Block has been used as in the example "ftm_hall_sensor_tof_s32k14x.slx". It's the only change to the model.
What is the issue?
Issue #2
As soon as I change ADC Block to generate the data from the Potentiometer on the evaluation board (rather then look at the other sensor), the FTM Input Edge Capture appears in the application to generate rubbish or nothing at all. It's the only change to the model.
What is the issue?
解決済! 解決策の投稿を見る。
Hello @Sam_ECU ,
The issue you are facing is caused by the Simulink priorities of the blocks, taken in account by the Embedded coder when generating the code. The FTM Input TOF ISR block has priority 1, while the FTM has no priority so it will first generate the code for the TOF ISR.
Of course, at first glance, there should be no issue here because both of the blocks are not executed every step time. But the problem is that in the initialize function, the code will start first to enable the TOF interrupt in the FTM and then to enable the FTM peripheral which causes the issue you may see with the board.
So please set the priority value 1 for the FTM input Edge Capture and priority 2 for the TOF ISR, and this should solve the issue.
Hope this helps,
Marius
But with that not only did I get Channel 0 capture events for the missing edges, I also got Channel 1 capture events for them. Until now Channel 0 was configured for input capture with no edges (ELS0A and ELS0B = 00) which apparently not only disables the Channel 0 capture function, it also disconnects the Channel 0 input from the XOR feeding Channel 1.Now it appears that my code is working correctly with Channel 0 configured for capturing both edges (probably any configuration for Channel 0 except ELS0A,B = 00 would work.
Changing to Module 2 and another channel I've been able to make the ADC-Potentiometer work.
The TOF just causes the board to timeout and the code to not work at all.
Hello @Sam_ECU
Can you please share with me the model which is not working with the FreeMaster?
Regards,
Marius
Hello @mariuslucianand
Please find attached.
One model is without the FTM Timer Overflow Block. Works fine.
The second model is with the FTM Timer Overflow Block. It corrupts the code and can't make any connection to freemaster.
Hello @Sam_ECU ,
The issue you are facing is caused by the Simulink priorities of the blocks, taken in account by the Embedded coder when generating the code. The FTM Input TOF ISR block has priority 1, while the FTM has no priority so it will first generate the code for the TOF ISR.
Of course, at first glance, there should be no issue here because both of the blocks are not executed every step time. But the problem is that in the initialize function, the code will start first to enable the TOF interrupt in the FTM and then to enable the FTM peripheral which causes the issue you may see with the board.
So please set the priority value 1 for the FTM input Edge Capture and priority 2 for the TOF ISR, and this should solve the issue.
Hope this helps,
Marius
Hallo @mariuslucianand
That was indeed the issue and makes perfect sense.
As an information point, the example provided in "ftm_hall_sensor_tof_s32k14x.slx" has the priority set as 1 for the "FTM Timer Overflow" Block.
Also, when I import the "FTM Timer Overflow" Block from the MBDT-Toolbox, by default the priority is set as 1.
Thanks for the help.
Sam
Hello @Sam_ECU,
I am glad it works now!
Also, thank you for noticing the priority behavior with a freshly added block from our Simulink Library, I will open an internal ticket for that!
Regards,
Marius