Output a kHz range clock through a GPIO?

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

Output a kHz range clock through a GPIO?

1,944 次查看
nxa09603
NXP Employee
NXP Employee

Hi

I'm trying to output a 4 kHz 50% duty cycle square waveform through a GPIO. What is the simplest way of doing that? 

It doesn't need to be exactly 4 kHz. I accept some tolerance around the target. 

I was considering to use FAST_IRCLK as time base, divide the clock by 1024 and output it. Is it possible?

 I'm using MCUXpresso with KL02 SDK.

Thank you

Andre VB

2 回复数

1,832 次查看
mjbcswitzerland
Specialist V

Hi

See also
https://www.utasker.com/docs/uTasker/uTaskerHWTimers.PDF
https://www.utasker.com/kinetis/FRDM-KL02Z.html

Available as open source on Git Hub "uTasker" including KL02 support and simulation - eg. generating 1kHz 20% output on PTB10:

pastedImage_1.png


Regards

Mark
[uTasker project developer for Kinetis and i.MX RT]

1,832 次查看
myke_predko
Senior Contributor III

Hey nxa09603‌,

The simplest way of doing it is to use one of the TPMs (Timer/PWM Modules) built into the KL02 to generate a PWM signal.  Just taking a quick look at the datasheet/RM, you will use one of the TM#_CH# pins as your output. 

I should note that the TPMs are different from the FTMs of other Kinetis parts but there should be an example in the SDK that you can see in MCUXpresso and copy over quickly.  

Good luck,

myke