Help on PWM signals on HC908QY4 chip

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

Help on PWM signals on HC908QY4 chip

6,615件の閲覧回数
Jerry
Contributor I
Hello.  I need to generate a PWM signal from the HC908QY4 chip, however, I've already used all the ADC pins except the PTA0 pin.  It says in the datasheet that for buffered PWM operation, to set the MS0B pin, however, I was wondering if this was necessary to generate the PWM signal since I'm already using the PTA1(TCH1) pin for other things.  Can PWM signals be generated from the TCLK pin as well and will the PWM timer signal mess up just a free-running timing counter that I may have going on as well because of the TOF register?
 
I'd appreciate any help I can get.
 
Jerry
ラベル(1)
0 件の賞賛
返信
5 返答(返信)

1,279件の閲覧回数
Jerry
Contributor I
Hi Ron.  I'd appreciate any code snippets out of your old apps that you might be able to show me.  Thank you for your replies everyone, I think I have a much better understanding of the PWM now.
 
Jerry :smileyhappy:
0 件の賞賛
返信

1,279件の閲覧回数
glork
Contributor I
Ok, I'll try to get the code within the next day or so. You do understand that this doesn't use the built-in PWM stuff, it uses ram registers and regular I/O pins, right??
Anyway, I'll need an email to send it to so why don't you email me at ron@cyberforceinc.com with your email address.
ron
0 件の賞賛
返信

1,279件の閲覧回数
bigmac
Specialist III

Hello Jerry,

I presume you are actually using the QY4A chip, since the QY4 does not have a TCLK pin.  So you would already have allowed for the extra ADC channels available on Port B, for the A-suffix device.  The TCLK pin is input only.

The data sheet states that TCH1 is available as a general purpose I/O pin when MS0B control bit is set., so would be OK to use for things other than a timer function.

Do you actually need to use buffered PWM?  If you can change the modulo register value to suit the PWM frequency, and suitably adjust other timing functions that use timer overflow, you might consider unbuffered PWM - operation is much simpler.

Regards,
Mac

 

0 件の賞賛
返信

1,279件の閲覧回数
rocco
Senior Contributor II
Hi, Jerry:


It says in the data sheet that for buffered PWM operation, to set the MS0B pin, however, I was wondering if this was necessary to generate the PWM signal since I'm already using the PTA1(TCH1) pin for other things.

You need to set the MS0B bit to enable BUFFERED PWM. When you do, the PTA1(TCH1) pin is not used, and is available to the ADC. The PWM will be outputted on the PTA0(TCH0) pin.


Can PWM signals be generated from the TCLK pin as well . . . ?

If you mean "Can PWM signals be output on the TCLK pin?", the answer is "No". If you mean "Can PWM signals be based on a clock that is input into the TCLK pin?", the answer is "Absolutely".


. . . and will the PWM timer signal mess up just a free-running timing counter that I may have going on as well because of the TOF register?

Normally, you would not modify the free-running counter, and you can process the TOF normally without disturbing the PWM. They can operate independently if programmed correctly.
0 件の賞賛
返信

1,279件の閲覧回数
glork
Contributor I
If your application can meet 2 requirements you can use a "software" PWM. The requirements are:
1. Your pwm signal doesn't have to be very high speed
2. You have a heart-beat interrupt set up and running (what I mean here is a periodic interrupt such as a "real-time" interrupt or similar).

I used this technique with good success in a QT4 application. You just use several memory locations as registers, i.e. an on-time reg, an off-time reg, reload reg, etc. The periodic interrupt decrements the on and off time regs and controls the state of your chosen output pin accordingly.

If you want more detail I can probably cut some code snippets out of my old app.
ron
0 件の賞賛
返信