Announcements

Help us improve the Power & Sensing Selection Guide. Share feedback

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
IvanoBono
Level 3
Level 3
25 sign-ins 10 sign-ins 10 replies posted

hi all, using a illd, I configured a fast compare channel like this:

 

void FastCompare_Init(void) {
IfxEvadc_Adc_FastCompareChannelConfig config;
IfxEvadc_Adc_initFastCompareChannelConfig(&config,&g_evadc);
config.fastCompareChannelId=IfxEvadc_GroupId_14;
config.channelEventMode=IfxEvadc_ChannelEventMode_aboveOrBelowCompareValue;
config.serviceRequestGenerationEvent=IfxEvadc_FastCompareServiceRequestGeneration_newResult;
config.referenceValue=256;
config.runMode=IfxEvadc_FastCompareRunControl_alwaysRun;
config.triggerInterval=0; //16/fADC 16/160mhz= 1mhz
IfxEvadc_Adc_FastCompareChannel fc;
IfxEvadc_Adc_initFastCompareChannel(&fc,&config);
g_evadc.evadc->FC[fc_channel].FCHYST.B.DELTAMINUS=0; 
g_evadc.evadc->FC[fc_channel].FCHYST.B.DELTAPLUS=128; 
	volatile Ifx_SRC_SRCR* src_regP=IfxEvadc_getSrcAddress(IfxEvadc_GroupId_14,0);
	IfxSrc_init(src_regP, Cpu_GetCoreServiceProvider(), ISR_PRIORITY_FASTCOMPARE); 
	IfxSrc_enable(src_regP);
}

IFX_INTERRUPT(ISR_ADC_result, 0, ISR_PRIORITY_FASTCOMPARE);
void ISR_ADC_result(void)
{
	counter++;
 }

 

and it works as expected.

but,

it'is possible route interrupt to a TIM counter to perform Count or Frequency calc without cpu intervention?

I have already configured the TIM counters to detect a frequency or a count of a signal coming from a pin, but I don't understand how I can select the result of the fast appear as the TIM input.

0 Likes
1 Solution
Nambi
Moderator
Moderator
Moderator
500 replies posted 50 likes received 5 likes given

Hi,

In the example, this specific sequence calls IfxGtm_PinMap_setTimTin(), which is more relevant to using a pin as an input.

You can try to use IfxGtm_Tim_Ch_setTimTin() ILLD API for your requirement.

Best Regards.

View solution in original post

0 Likes
6 Replies
Nambi
Moderator
Moderator
Moderator
500 replies posted 50 likes received 5 likes given

Hi,

It is possible to route the FC BFL flag to TIM input.

You can refer to the section "Port to GTM TIM Connections" in the device-specific user manual for the device-specific routing options.

Best Regards.

0 Likes

i'am using TC377. I have already read this section and noticed that in the file:
"IfxGtm_PinMap.c" there is the mapping of all the configurations but there are not those of the FC BFL.
so i did this TIM init function :

 

IfxGtm_Tim_In g_driverTIM;	// TIM driver structure

void Tim_Init(void) { //test
    IfxGtm_enable(&MODULE_GTM);                                  //Enable the GTM
    IfxGtm_Cmu_enableClocks(&MODULE_GTM, IFXGTM_CMU_CLKEN_CLK0); //Enable the CMU clock 0
    IfxGtm_Tim_In_Config configTIM;
    IfxGtm_Tim_In_initConfig(&configTIM, &MODULE_GTM);   //Initialize default parameters
    //pin map for: FC2BFL, EVADC boundary flag level of FC channel 2
    static const IfxGtm_Tim_TinMap IfxGtm_TIM0_2_FC2BFL_IN = {IfxGtm_Tim_0, IfxGtm_Tim_Ch_2, {0}, (IfxGtm_ChXSel)0}; 
    configTIM.filter.inputPin = &IfxGtm_TIM0_2_FC2BFL_IN;           //Select input port pin
    configTIM.filter.inputPinMode = IfxPort_InputMode_undefined;    //Select input port pin mode
    IfxGtm_Tim_In_init(&g_driverTIM, &configTIM);           //Initialize the TIM
}

 

and in main i call:

FastCompare_Init();

Tim_Init();

and in main loop i read period with:

 

IfxGtm_Tim_In_update(&g_driverTIM);
int period=IfxGtm_Tim_In_getPeriodSecond(&g_driverTIM);

 

but it does not work. I forgot something?

0 Likes
Nambi
Moderator
Moderator
Moderator
500 replies posted 50 likes received 5 likes given

Hi,

Can you check the "GTM_TIM_Capture_1" example from the Aurix Development Studio? 

1. You can test check this "GTM_TIM_Capture_1" existing TIM example at your end and ensure that it is successful.

2. Once you have a working example for TIM, you can adapt it for "fast compare ADC to TIM" mapping.

Best Regards.

0 Likes

i have a"GTM_TIM_Capture_1" example working, but how  adapt it for "fast compare ADC to TIM" mapping?

in init_TIM() function:

void init_TIM(void)
{
    IfxGtm_enable(&MODULE_GTM);                                         /* Enable the GTM                           */
    IfxGtm_Cmu_enableClocks(&MODULE_GTM, IFXGTM_CMU_CLKEN_CLK0);        /* Enable the CMU clock 0                   */

    IfxGtm_Tim_In_Config configTIM;

    IfxGtm_Tim_In_initConfig(&configTIM, &MODULE_GTM);                  /* Initialize default parameters            */
    configTIM.filter.inputPin = &PWM_IN;                                /* Select input port pin                    */
    configTIM.filter.inputPinMode = IfxPort_InputMode_pullDown;         /* Select input port pin mode               */
    IfxGtm_Tim_In_init(&g_driverTIM, &configTIM);                       /* Initialize the TIM                       */
}

 what should I set in
"config TIM.filter.inputPin config"

and

"TIM.filter.inputPinMode"
to select the "FC BFL flag"?

0 Likes
Nambi
Moderator
Moderator
Moderator
500 replies posted 50 likes received 5 likes given

Hi,

In the example, this specific sequence calls IfxGtm_PinMap_setTimTin(), which is more relevant to using a pin as an input.

You can try to use IfxGtm_Tim_Ch_setTimTin() ILLD API for your requirement.

Best Regards.

0 Likes
hardly_BSW
Level 1
Level 1
5 replies posted 10 sign-ins First like received

@IvanoBono Could you please help to post the link of the example?

0 Likes