Hello,
I have an issue with Generating accurate timer interrupt with FTM_5_CH_0_CH_1
as when starting the GPT timer for example with GPT_StartTimer(timer channel , time_needed)
where time needed is equal to 12 ms which corrosponds to 15000 tick for 1250000 hz
but i am getting the ISR each 6 ms instead of 12 ms
here is the configuration done on Tresos
GPT Configuration:
I have added new entry in GPTChannelConfiguration for FTM5
and GPT channel tick frequency is 1250000
GPT channel CLk src ref - > FTM_5 clock
GPT FTM Prescaler = 32
GPT FTM channel clk src=system_clock
MCU configuration :
MCU peripheral clock config for FTM5 is on SPLL
FTM5 clk in MCU clock reference point is 40 MHZ
for the SPLL:
SPLL freq is 160 Mhz
SPLL div 2 freq is 20 Mhz
SPLL div 1 freq is 40 Mhz
so what is wrong and leading to getting this issue ?
Based on your thread on Community, I have some clues:
GPT FTM channel clk src=system_clock -> FTM clock is gotten from System clock of MCU module. So even you configured SPLL div 1 to 40 Mhz, FTM doesn’t get this source clock
If you want to keep GPT FTM Prescaler = 32 , then check that your System clock equals 40Mhz
It’s Run System Clock Frequency (Hz) (dynamic range) attribute in MCU (/Mcu/McuModuleConfiguration/McuClockSettingConfig/McuRunClockConfig/McuSystemClockFrequency)
This attribute corresponds by Run System Clock Select. So you can modify these attributes to get value 40Mhz
For more information, you can check Reference Manual doc Chapter 27, Table 27-9. Peripheral module clocking to know about Clock source select for FTM:
In case you want to keep Source clock is SPLL, you can change GPT FTM channel clk src to External clock
Hi @YoussefGhorab , can you give us version of MCAL you're using and the project's config folder also, I will try to check it from my side