S32K144 FTM OC function doubts

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

S32K144 FTM OC function doubts

3,579 Views
xiaoyuwang
Contributor II

I am using FTM OC function, but when I use SDK to configure my OC channel, I got some doubts.

1. Clock source frequency after prescaler is 1MHz.

1.png

2. Max counter value set to 150. Means I need to set the output pin curve period for 150us.

2.png

3. Channel compared value set to 100. Means I want to toggle output pin when at 100us.

3.png

RESULT: I got following curve.

4.jpg

Both high level and low level duration are 150us.

MY QUESTION: What's the meaning of compared value which set for channel? How to use it?

Labels (1)
Tags (1)
0 Kudos
Reply
9 Replies

3,303 Views
razva_tilimpea
NXP Employee
NXP Employee

Hi,

Compared value is the moment when the output action occurs. In our case the signal is toggled. So, your assumptions are right.

pastedImage_1.png

Compared value can be used to generate phase shifted signals, generate event after some period of time and so on.

I can provide you more details if you can detail your application.

Best regards,

Razvan

3,303 Views
xiaoyuwang
Contributor II

hello Tilimpea,

sorry for the error reply. I have solve problem yesterday. But I met a new fault today.

Step 1: I want to get a 150us pulse and I set FTM0 module clock 250KHz, 4us every tick.

Step 2: I called function "FTM_DRV_SetOutputlevel" in my task to control to start channel and set match mode to "FTM_SET_ON_MATCH".

Step 3: Set match value to 38 and set relative value.

1.png

   Means I will stop channel once channel interrupt is got. And waiting for next task schedulation.

Step 4: Run my task for 50ms  period.

ISSUE 1: The pulse period is 50ms, it is correct. But pulse width is changed from 50+ to 152us every task period.

0 Kudos
Reply

3,056 Views
julywu
Contributor II

i meet the question,how you slove this prolem。

0 Kudos
Reply

3,042 Views
julywu
Contributor II

i know why now.because i did not update the cnv value.if i set the cnv 100,set the MOD 150,the first match happen with the channel output flip,when CNT count to 100,spend 100 count time.the second match happen with the channel output flip,when CNT count to 100,spend 150 count time(50+100).

so the waveform will behave like 150 count time.

0 Kudos
Reply

3,303 Views
razva_tilimpea
NXP Employee
NXP Employee

Hi,

Based on the details provided by you I suppose that the pulse width is not always the same due to software overhead or because other taks/interrupts are handled.

Can you explain what signal are you trying to generate? In this way I can try to provide an better alternative to implement your software.

Best regards,

Razvan

0 Kudos
Reply

3,303 Views
xiaoyuwang
Contributor II

hi Tilimpea,

My application is use OC module to generate a pulse to drive ultrasonic sensor to measure the distance of a object and use IC module to get echo.  If you have better solution, could you provide.

In my system, I really use many interrupts, e.g. UART, CAN, LPIT, LPTMR. So I think my error is actually affected by other interrupts.  Do you have any suggestion for these interrupts priority?

Thank you~~

0 Kudos
Reply

3,303 Views
razva_tilimpea
NXP Employee
NXP Employee

Hi,

You can try to increase the priority of FTM, but this won't solve the case when other interrupt handler is executed when FTM interrupt is requested.

If is mandatory to generate the exact pulse width you have to use ftm_pwm because the pulse is generated by hardware, without software intervention. Do you have some limitation to not use ftm_pwm driver?

Razvan

0 Kudos
Reply

3,303 Views
xiaoyuwang
Contributor II

CONTINUE

ISSUE 2:  Function call for "FTMDRV_SetOutputState" cannot change channel output level.

QUESTION: If I want to get low level pulse, how to invert the curve phase?

Thank you so much for your answer.

0 Kudos
Reply

3,303 Views
xiaoyuwang
Contributor II

hello Tilimpea,

I have solve problem yesterday. But now I met another fault.

I call following function to set the action when match to "FTM_SET_ON_MATCH" mode in my 50ms task.

FTM_DRV_SetOutputlevel(FRT_SNSR1_MOD, FRT_SNSR1_CHN, (uint8_t)FTM_SET_ON_MATCH);

0 Kudos
Reply