Dynamically Changing the Period Value of Timers, Counters, and PWMs in PSoC 3/4/5LP - KBA88172

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

cross mob
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Note: I encountered a discussion which KBA88172 helped.

PWM period and duty cycle configuration

So I translated the KBA.

=====================

Original KBA: Dynamically Changing the Period Value of Timers,

Counters, and PWMs in PSoC 3/4/5LP - KBA88172

タイトル:PSoC 3/4/5LP において動作中の Timer, Counter, PWM の周期(period)を変更する。

質問:

PSoC 3/4/5LP において、動作中の Timer, Counter, PWM コンポーネントの周期を変更するのにはどうしたら良いですか?

回答:

動作中の fixed-function や universal digital block (UDB) の Timer, Counter 及び PWM コンポーネントの周期は下記の WritePeriod() API を使用して変更することが可能です。新しい周期の値はカウンタが 0 にリセットされたときにロードされます。

・ Timer_WritePeriod(period);

・ PWM_WritePeriod(period);

・ Counter_WritePeriod(period);

下記の WriteCounter() API を使用して変更された周期を直ちに有効にすることが出来ます。

・ Timer_WriteCounter(0);

・ PWM_WriteCounter(0);

・ Counter_WriteCounter(0);

注:

1. WritePeriod API を使用した Timer/Counter/PWM の周期変更は Start API が実行された後で有効です。Start API が実行されると周期は Component Configuration Window で設定された値にリセットされてしまいます。

2. 新たに周期レジスタに書き込まれる値が以前の値よりも小さい場合には、直後に WriteCounter(0) API を実行してください。

3. カウンタに N サイクルをカウントさせるためには、周期の値は N-1 を書き込む必要があります。

=====================

moto

2 Replies
JennaJo
Moderator
Moderator
Moderator
1000 replies posted 750 replies posted 500 replies posted

Hi, Tanaka-san

Thanks for providing your translation and sharing to Community  !

It will help other users,

I will request to work to publish this to Community and get back to you.

Thanks,

jenna 

Jenna Jo
JennaJo
Moderator
Moderator
Moderator
1000 replies posted 750 replies posted 500 replies posted

Hello, Tanaka-san

Sorry for the delay !

Your KBA has been released to Community!

You will receive the score for your work.

Thanks for your waiting and contribution to this activity!

Let me know, if you see issues.

Thanks,

Jenna 

Dynamically Changing the Period Value of Timers, Counters, and PWMs in PSoC 3/4/5LP - KBA88172

Jenna Jo