FTM Input Edge Capture - Stops working with FTM Input TOF ISR and ADC

cancel
Showing results for 
Search instead for 
Did you mean: 

FTM Input Edge Capture - Stops working with FTM Input TOF ISR and ADC

Jump to solution
293 Views
Sam_ECU
Contributor III

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.

Sam_ECU_0-1634657280077.png

Sam_ECU_1-1634657313908.png

Below a screenshot of the timestamp from the FTM Input Edge.

Sam_ECU_2-1634657425420.png

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.

Sam_ECU_4-1634657651169.png

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.

Sam_ECU_5-1634658381117.png

Sam_ECU_6-1634658511749.png

What is the issue?

 

 

 

0 Kudos
1 Solution
205 Views
mariuslucianand
NXP Employee
NXP Employee

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.

mariuslucianand_1-1635788854991.pngOf 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

 

View solution in original post

0 Kudos
7 Replies
224 Views
Hansen110
Contributor I

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.

 

sky light pay card

0 Kudos
281 Views
Sam_ECU
Contributor III

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.

 

0 Kudos
271 Views
mariuslucianand
NXP Employee
NXP Employee

Hello @Sam_ECU 

Can you please share with me the model which is not working with the FreeMaster?

Regards,

Marius

0 Kudos
241 Views
Sam_ECU
Contributor III

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.

0 Kudos
206 Views
mariuslucianand
NXP Employee
NXP Employee

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.

mariuslucianand_1-1635788854991.pngOf 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

 

View solution in original post

0 Kudos
166 Views
Sam_ECU
Contributor III

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

0 Kudos
141 Views
mariuslucianand
NXP Employee
NXP Employee

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

0 Kudos