How to set FTM to enable GTB on S32G2 platform?

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

How to set FTM to enable GTB on S32G2 platform?

842 Views
jiaweilin
Contributor III

I tried to test the FTM functionality on GoldBox.

Attempt to generate the cycle flip signal through FTM_0, then capture the rising edge of the FTM_0 generated signal through FTM_1 and count.(The FTM_0 moduleused as the time base.)

Set channel 0 of FTM_0 as output mode, and PinActivate is TogglePin.
Set channel 1 of FTM1 as the input capture mode.\

However, after I completed the setup and started the program according to the steps in section 43.5.30.1 of the S32RM manual, FTM0 and FTM1 did not start to run, and CNT was always 0.

Attached is the program I wrote.

Could you tell me where my problem is.

Whether the initialization process is incorrect, or the GTB setup step is incorrect.

Tags (3)
0 Kudos
6 Replies

828 Views
Daniel-Aguirre
NXP TechSupport
NXP TechSupport

Hi,

How are you verifying that the project is working without GTB? Also, which RTD version are you using?

The Icu example requires an external connection to be able to start counting, do you have this external connection?

If you would like for your project to be reviewed, we recommend opening a ticket under the NXP online services.

Please, let us know.

0 Kudos

789 Views
jiaweilin
Contributor III

I have another question to ask.

Whether there can exist both Icu and Ocu channels in the same FTM. For example:

  1. FTM1_CH0 works in Icu mode for capturing the rising edge.
  2. FTM1_CH1 works in Ocu mode for controlling Pin output.

Thanks for your help.

Tags (3)
0 Kudos

798 Views
jiaweilin
Contributor III

A1:

The above GTB project is based on the S32DS Icu and Ocu example project modification. The modification includes the following two parts:

  1. Modify the FTM Icu and FTM Ocu configurations in S32DS Peripherals page(SC[CLKS] = FTM input clock).
  2. Add the GTBEEN and GTBEOUT configuration code to the main function (see below).

When I ran the program without part b, FTM_0 and FTM_1 worked, and CNT counted correctly.

jiaweilin_0-1684722268656.png

A2:

  • S32DS:Version - 3.4,Build id - 201217 (Update 3)
  • RTD:SW32G_RTD_4.4_3.0.2_HF01

A3:

Sorry, I don't understand.

Does external connection mean that FTM needs to use an external clock as the clock source (i.e. SC[CLKS] = External clock)?

 
Thanks for your reply.
 

 

Tags (3)
0 Kudos

777 Views
Daniel-Aguirre
NXP TechSupport
NXP TechSupport

Hi,

Thanks for your feedback.

Seeing the image you have shared, once you are setting GTBEOUT, you are doing it in a different manner to what we are custom to. You are doing an inverse AND with a GTBEOUT mask, is this mask the inverse of setting 1 to GTBEOUT?

Why are you not setting the flag with the OR operation? As follows:

Ftm_Ocu_Ip_gapcxBase[0]->CONF |= (FTM_CONF_GTBEOUT_MASK);

If you are using the provided masks by the RTD, you are setting to 0 the GTBEOUT bit, which does not start the GTB feature.

Also, as per your question "Whether there can exist both Icu and Ocu channels in the same FTM.", we are seeing the following when we configure both Icu and Ocu under the same module:

#error "FTM_1 instance cannot be used by ICU. Instance locked by another driver!"

For which, it seems that the drivers do not let this mixture under the same module. We do apologize.

Please, let us know.

0 Kudos

730 Views
jiaweilin
Contributor III

Thanks for your feedback.

I modified my program according to your method, and the two FTMS started normally.

I also changed the location of the FTM clock initialization operation. As follows:

  • Ftm_Icu_Ip_Init(), Ftm_Icu_Ip.c Line538:

jiaweilin_0-1685340732994.png

  • Ftm_Ocu_Ip_Init(), Ftm_Ocu_Ip.c Line640:

jiaweilin_1-1685340741911.png

  • main(), main.c :

jiaweilin_2-1685340751531.png

But new problems arise.

  • When the program started and first ran to line 164 of the main.c file, I observed that the numbers in the CNT registers of FTM_0 and FTM_1 were different, and the difference between the values is large.

Does this mean that the two FTMs are not started at the same time, that is, the GTB function is not set successfully?

Attached is the revised completed project.

Did I miss any operations?

Thanks for your help.

 

Tags (3)
0 Kudos

716 Views
Daniel-Aguirre
NXP TechSupport
NXP TechSupport

Hi,

For the image that you are sharing, you are enabling GTB (line 153) prior to finishing the configuration of the FTM modules. 

As said in the Reference Manual [Page 2243, S32G2 Reference Manual, Rev. 7, February 2023]:

"To initiate the GTB feature in the configuration described in the preceding figure, write 1 to CONF[GTBEOUT] in the FTM module used as the time base."

Since you are configuring the GTB and then modifying the source clock, the enablement of GTB is not as the Reference Manual describes.

Also, are you enabling both the Icu and Ocu modules for debugging? For what we see, the example for Ocu does not set the counter to stop under debugging.

Please, let us know.

0 Kudos