How to control clock pulse

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

How to control clock pulse

912件の閲覧回数
kiyoshimatsuzak
Contributor III

Hi, all.

 

I use a FRDM-K64F.

I built "ftm_pwm" in KSDK 1.0.0 using Kinetis Design Studio, and I could get clock output from a FRDM-K64F.

As next step, I would like to control output pulse number to control motors.

For example,

When I need ten pulses:

__|"|_|"|_|"|_|"|_|"|_|"|_|"|_|"|_|"|_|"|______________

 

When I need three pulses:

__|"|_|"|_|"|_______________________________

 

I need sample codes and documents about this.

 

If someone have information, please let me know.

 

Regards,

 

Kiyoshi

ラベル(1)
0 件の賞賛
3 返答(返信)

679件の閲覧回数
apanecatl
Senior Contributor II

What I can think of to output a specific number of pulses would be to count the times the Channel Value register (FTMx_CnV) overflows, this counter register provides the pulse width, every time a pulse stops the register overflows and the count is reset to star counting up/down again effectively letting you know a new pulse has started, you just need to know how many times it overflowed to stop the count.

0 件の賞賛

679件の閲覧回数
kiyoshimatsuzak
Contributor III

Hi, Pedro

Thank you so much for your advice.

I have some questions.

Q1.

"every time a pulse stops the register overflows and the count is reset"

Can I get a value of FTMx_CnV using FTM_HAL_GetChnCountVal( ) in "ftm_pwm" demo of KDS?

Q2.

"the count is reset"

Do you mean that FTMx_CnV become zero when a pulse stopped every time?

Regards,

Kiyoshi

0 件の賞賛

679件の閲覧回数
apanecatl
Senior Contributor II

Well you need to check the reference manual in greater detail:

Q1: Can I get a value of FTMx_CnV using FTM_HAL_GetChnCountVal( ) in "ftm_pwm" demo of KDS?

A: You can get the channel vale at any time, the register has no read restrictions.

Q2: Do you mean that FTMx_CnV become zero when a pulse stopped every time?

A: The channel value resets (reaches 0 or the maximum count value) whenever the counter overflows after reaching its maximum count value, since the counter max value defines the pulse's duty cycle,  knowing when the value resets lets you know when a pulse has been sent.