FTM counter read inside interrupt / S32K144

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FTM counter read inside interrupt / S32K144

944 Views
CharlesAlbert
Contributor II

Hi there,

I am trying to read a FTM counter inside an interrupt raised on CnV match of the same FTM timer.

For example:

void vBIOS_CPG_Handler(oc_event_t event, void * userData)
{
u16CounterValue = FTM_DRV_CounterRead(5);
u16CounterValue2 = FTM_DRV_CounterRead(5);
}

A breakpoint on the last line will give me 2 values closed to each other for u16CounterValue and u16CounterValue2 as expected (few ticks difference).

But If I watch the FTM-> CNT register, the value is not the same?

Example:

FTM5->CNT               46442
u16CounterValue        22819
u16CounterValue2      22821

Any idea why there is a difference?

Thks.

 

 

0 Kudos
Reply
3 Replies

891 Views
CharlesAlbert
Contributor II

Hello,

Thx. I am using FTM5 on a S32K146!

I guess my issue is the debug, when breaking the FTM may continue to run or something.

If I make a breakpoint somewhere else in the code, the 2 variables seems to have an expected value.

i.e. if Cvn register is 500, I will see 525 for example which is ok as there is the time for the interrupt, few codes lines etc.

May the question is more if there is a way to do debug by breaking in the interrupt routine?

Thks!

0 Kudos
Reply

882 Views
_Leo_
NXP TechSupport
NXP TechSupport

Yes, you can put a breakpoint in the interrupt routine and then run step by step.

0 Kudos
Reply

914 Views
_Leo_
NXP TechSupport
NXP TechSupport

Hi @CharlesAlbert,

Thank you so much for your interest in our products and for using our community.

I'm very sorry for the delay. We are currently facing some backlog issues.

Could you confirm that you are using FTM5 and S32K144 please?

What happens is that the S32K144 only has FTM from 0 to 3 (Table 47-1. FTM instances and features of Reference Manual).

nxf86756_0-1670881502477.png

Have a nice day!

0 Kudos
Reply