System clock as FTM source on K64?

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

System clock as FTM source on K64?

跳至解决方案
1,877 次查看
leo_thirifays
Contributor I

Hello,

I'm developing on a K64 board under MCUXpresso and I'm trying to get the best resolution for the duty cycle of a PWM I'm generating with one of the FTM. That's why I'm trying to use the fastest clock source possible.

I read from the K64 reference manual that you can use the system clock at 100MHz as the source clock for the module (Chapter 40.1.2, page 976).

However, when using the Peripherals tool from MCUXpresso to configure the FTM, the fastest clock available is the BusClock which is at 50MHz (System Clock with a division factor of 2). I can't get any higher because this clock is limited at 60MHz.

2018-09-18 10_38_33-Combi-Meas - A0630-CB_MCUXpresso_project_source_A0630-CB.c - MCUXpresso IDE.png

FTM3 config

My problem is that by looking at the FTM3 registers in Debug Mode and the manual, it seems that I'm selecting the System Clock even though on the peripherals.h generated by the MCUXpresso tools, it is using the Bus Clock at 50MHz.

2018-09-18 10_38_04-Combi-Meas - A0630-CB_MCUXpresso_project_source_A0630-CB.c - MCUXpresso IDE.png

The register for FTM3 in debug mode after the peripherals are all initialized.

2018-09-18 10_37_45-K64 manual.pdf - Adobe Acrobat Reader DC.png

The K64 manual on Chapter 40.3.3, page 988

2018-09-18 10_42_01-Combi-Meas - A0630-CB_MCUXpresso_project_board_peripherals.h - MCUXpresso IDE.png

The code generated by the MCUXpresso tools, on peripherals.h

So there seems to be an incoherence between the manual and MCUXpresso. And the resolution of duty cycle the 24kHz PWM generated from the timer is around 1000 steps, so it seems like the smallest change on the duty cycle possible is around 25MHz, not even 50MHz!

I tried to manually change the #define FTM_3_CLOCK_SOURCE by replacing kCLOCK_BusClk with kCLOCK_CoreSysClk but it just messes with the PWM frequency, dividing it by a factor of 2 and not giving me a better resolution for the pulse width.

A better resolution for the duty cycle of the PWM would really help, so does somebody managed to use the fastest clock available on the MCU for the FTM (or the other peripherals in general)?

Thanks

标签 (1)
0 项奖励
回复
1 解答
1,578 次查看
mjbcswitzerland
Specialist V

Hi Léo

The Flex timer document is confusing because it talks of using the system clock as one of its clock sources, but if you check the chip configuration you will find that the flex timer's "system clock" is in fact the overall system's bus clock (true for all Kinetis parts).

This means that the bus clock is indeed the fastest clock that you can use for the Flex Timer.

Regards

Mark

Kinetis: http://www.utasker.com/kinetis.html
Kinetis K64:
- http://www.utasker.com/kinetis/FRDM-K64F.html
- http://www.utasker.com/kinetis/TWR-K64F120M.html
- http://www.utasker.com/kinetis/TEENSY_3.5.html
- http://www.utasker.com/kinetis/Hexiwear-K64F.html

For less questions and faster, cheaper developments: try uTasker for Kinetis

在原帖中查看解决方案

2 回复数
1,579 次查看
mjbcswitzerland
Specialist V

Hi Léo

The Flex timer document is confusing because it talks of using the system clock as one of its clock sources, but if you check the chip configuration you will find that the flex timer's "system clock" is in fact the overall system's bus clock (true for all Kinetis parts).

This means that the bus clock is indeed the fastest clock that you can use for the Flex Timer.

Regards

Mark

Kinetis: http://www.utasker.com/kinetis.html
Kinetis K64:
- http://www.utasker.com/kinetis/FRDM-K64F.html
- http://www.utasker.com/kinetis/TWR-K64F120M.html
- http://www.utasker.com/kinetis/TEENSY_3.5.html
- http://www.utasker.com/kinetis/Hexiwear-K64F.html

For less questions and faster, cheaper developments: try uTasker for Kinetis

1,578 次查看
leo_thirifays
Contributor I

Thank you for the clarification, Mark. That's what I thought.

Regards,

Léo

0 项奖励
回复