jackomo

Posted on 20 June 2006 by jakilevy

HPWM

from micro code studio help option:

HPWM PRO STD

HPWM Channel,Dutycycle,Frequency

HPWM run continuously in the background while the program is doing other things. Channel specifies which hardware PWM channel to use. Some devices have 1, 2 or 3 PWM channels. On devices with 2 channels, the Frequency must be the same on both channels. Dutycycle specifies the on/off (high/low) ratio of the signal. It ranges from 0 to 255, where 0 is off (low all the time) and 255 is on (high) all the time. A value of 127 gives a 50% duty cycle (square wave). Frequency is the desired frequency of the PWM signal. Not all frequencies are available at all oscillator settings. The lowest frequency at 4MHz is 245Hz. The highest frequency at any oscillator speed is 32767Hz.

The lowest usable HPWM Frequency at each oscillator setting is shown in the following table:

OSC 14-bit core and 18Cxxx 17Cxxx
4MHz 145Hz 3907Hz
8MHz 489Hz 7813Hz
10MHz 611Hz 9766Hz
12MHz 733Hz 11719Hz
16MHz 977Hz 15625Hz
20MHz 1221Hz 19531Hz
24MHz 1465Hz 23438Hz
33MHz 2015Hz 32227Hz
40MHz 2442Hz na

Some devices, such as the PIC18C452, have alternate pins that may be used for HPWM. The following DEFINEs allow using these pins:

DEFINE CCP1_REG PORTC ‘Hpwm 1 pin port
DEFINE CCP1_BIT 2 ‘Hpwm 1 pin bit
DEFINE CCP2_REG PORTC ‘Hpwm 2 pin port
DEFINE CCP2_BIT 1 ‘Hpwm 2 pin bit

The following DEFINEs specify which timer, 1 or 2, to use with PWM channel 2 and PWM channel 3 for the PIC17C7xx devices. The default is timer 1 if no DEFINE is specified.

DEFINE HPWM2_TIMER 1 ‘Hpwm 2 timer select
DEFINE HPWM3_TIMER 1 ‘Hpwm 3 timer select

Example

HPWM 1,127,1000 ‘ Send a 50% duty cycle PWM signal at 1kHz
HPWM 1,64,200   ‘ Send a 25% duty cycle PWM signal at 2kHz

See Also

PWM

Copyright © 2001 microEngineering Labs, Inc.
All rights reserved.

Socially Bookmarkit!
  • Digg
  • del.icio.us
  • Technorati
  • Reddit
Sphere: Related Content

Leave a Reply