s32k input frequency measurment

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

s32k input frequency measurment

跳至解决方案
593 次查看
sandeepc
Contributor IV

1st I tried I as shown in example by creating my own example I can able to read the frequency of individual channel

Refer the below code

My input frequency is 500 hz and I can able to read the 500 hz in this single channel but when I configured for multiple channel iam getting errors please below page

 

uint32_t frequency;

void clock_pins_init(void)

{

       /* Initialize clock module */

       CLOCK_SYS_Init(g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT, g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT);

       CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_AGREEMENT);

 

       /* Initialize pins */

       PINS_DRV_Init(NUM_OF_CONFIGURED_PINS0, g_pin_mux_InitConfigArr0);

 

       ic_pal();

}

void ic_pal(void)

{

       IC_Init(&ic_pal_1_instanceConfig, &ic_pal_1_InitConfig);

       frequency = FTM_DRV_GetFrequency(ic_pal_1_instanceConfig.instIdx);

 

 

}

int main(void)

{

       /* Write your code here */

       clock_pins_init();

       for(;;)

       {

 

             /* Get the latest value */

             inputCaptureMeas = IC_GetMeasurement(&ic_pal_1_instanceConfig, 0);

             /* Calculate the signal frequency using recorded data*/

             inputCaptureMeas = frequency / (inputCaptureMeas);

 

       }

}

 

/* END main */

/*!

 ** @}

 */

 

sandeepc_0-1685958683533.png

 

 

@rob

 

 

sandeepc_1-1685958683884.png

 

 

After getting single channel output I configured second channel I got below error

  • Measure period between two consecutive rising edges
  • Measure period between two consecutive falling edges

I tried in both option so iam getting now as below error

Error is odd channel is not supported by odd channels

sandeepc_2-1685958684195.png

 

After I got this I skipped only to read even channels with below configuration I am not able to read still second channel frequency

 

sandeepc_3-1685958684516.png

 

 

 

 

include "sdk_project_config.h"

volatile uint16_t inputCaptureMeas = 0,inputCaptureMeas1 = 0U,inputCaptureMeas2 = 0U;

uint32_t frequency;

void clock_pins_init(void)

{

       /* Initialize clock module */

       CLOCK_SYS_Init(g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT, g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT);

       CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_AGREEMENT);

 

       /* Initialize pins */

       PINS_DRV_Init(NUM_OF_CONFIGURED_PINS0, g_pin_mux_InitConfigArr0);

 

       ic_pal();

}

void ic_pal(void)

{

       IC_Init(&ic_pal_1_instanceConfig, &ic_pal_1_InitConfig);

       frequency = FTM_DRV_GetFrequency(ic_pal_1_instanceConfig.instIdx);

 

 

}

int main(void)

{

       /* Write your code here */

       clock_pins_init();

       for(;;)

       {

 

             /* Get the latest value */

             inputCaptureMeas = IC_GetMeasurement(&ic_pal_1_instanceConfig, 0);

             /* Calculate the signal frequency using recorded data*/

             inputCaptureMeas = frequency / (inputCaptureMeas);

             inputCaptureMeas1 = IC_GetMeasurement(&ic_pal_1_instanceConfig, 2);

             /* Calculate the signal frequency using recorded data*/

             inputCaptureMeas1 = frequency / (inputCaptureMeas1);

 

       }

}

 

/* END main */

/*!

 ** @}

 */

 

 

I am not getting any channel2 output

 

 

sandeepc_4-1685958684845.png

 

                                                   

 

Can I get few more tips how can I achieve reading of multiple channel frequency

 

@Robin_Shen 

0 项奖励
回复
1 解答
572 次查看
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi 

Sorry for the inconvenience we bring you!

About "The odd channels cannot be configured as a signal measurement mode.", this is the limitation of the IC_PAL and FTM_IC drivers. If FTM Input Capture Mode is configured by register(not use SDK APIs), the frequency can be measured with odd channel. But IC_PAL and FTM_IC will configure FTM in Dual Edge Capture Mode when they are configured as signal measurement mode.

If you use the SDK APIs and S32CT, and can switch to other pins, the easiest way is to choose even channel.

For reading the frequency of multiple channels, it can be configured in S32CT according to the original channel. 

 

    uint8_t channel0 = ic_pal_1_InitConfig.inputChConfig[0].hwChannelId;
    uint8_t channel2 = ic_pal_1_InitConfig.inputChConfig[1].hwChannelId;
    inputCaptureMeas0 = IC_GetMeasurement(&ic_pal_1_instanceConfig, channel0);
    inputCaptureMeas2 = IC_GetMeasurement(&ic_pal_1_instanceConfig, channel2);

 

 

In the case of Prescaler=8, Frequency of counter clock=6000000Hz. The Max measured frequency is 6MHz, and the Min measured frequency is 91.55Hz.

For more details on IC_PAL, please read its guide.

Documentation S32K1 SDK.jpg


Best Regards,
Robin
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

 

在原帖中查看解决方案

0 项奖励
回复
1 回复
573 次查看
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi 

Sorry for the inconvenience we bring you!

About "The odd channels cannot be configured as a signal measurement mode.", this is the limitation of the IC_PAL and FTM_IC drivers. If FTM Input Capture Mode is configured by register(not use SDK APIs), the frequency can be measured with odd channel. But IC_PAL and FTM_IC will configure FTM in Dual Edge Capture Mode when they are configured as signal measurement mode.

If you use the SDK APIs and S32CT, and can switch to other pins, the easiest way is to choose even channel.

For reading the frequency of multiple channels, it can be configured in S32CT according to the original channel. 

 

    uint8_t channel0 = ic_pal_1_InitConfig.inputChConfig[0].hwChannelId;
    uint8_t channel2 = ic_pal_1_InitConfig.inputChConfig[1].hwChannelId;
    inputCaptureMeas0 = IC_GetMeasurement(&ic_pal_1_instanceConfig, channel0);
    inputCaptureMeas2 = IC_GetMeasurement(&ic_pal_1_instanceConfig, channel2);

 

 

In the case of Prescaler=8, Frequency of counter clock=6000000Hz. The Max measured frequency is 6MHz, and the Min measured frequency is 91.55Hz.

For more details on IC_PAL, please read its guide.

Documentation S32K1 SDK.jpg


Best Regards,
Robin
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

 

0 项奖励
回复