HWPWM
 
This function is available on ARMmite, ARMmite Wireless, ARMexpress LITE and ARMmite PRO.

Library


#include <HWPWM.bas>

#include <HWPWM17.bas>   ' for the PROplus and SuperPRO LPC17xx based boards.

#include <HWPWM11.bas>   ' for the BASICchip, BASICboard and PROstart

H
 
 

 

 
Interface
 
' channels are 1-8
' cycletime and hightime are in microseconds
 
SUB HWPWM ( channel, cycletime, hightime )  
 
Cycletime should be the same for all channels, and will be set to the last value programmed.  HWPWM is used with the PWM hardware which consists of hardware registers which compare a counter that is counting from 0 to cycletime-1.   If you need to change the cycletime, you should write directly to the registers, as if you write a value that is less than the current count, the cycle will count until the counter rolls over to 0, (probably not what you want, as these comparators look for equality.
 
BASICchip, BASICboard and PROstart version

The BASICchip supports up to 4 channels of hardware driven PWM.  The IO direction of the pin will be set to output.  Once programmed these will continue to generate the specified PWM until re-programmed or reset.

Cycletime is in microseconds, is the time for a single PWM cycle. Hightimes are also in microseconds and represent the amount of time during the cycle that the corresponding outputs are high. It is assumed, but not enforced that cycletimes for all channels will be the same.

 channel1  IO(8)          
 channel2  IO(9)
 channel3  IO(10)
 channel4  IO(41)

 
If TIMER interrupts are used, then only 4 hardware PWM channels are available.
 
ARMmite and Wireless ARMmite version

The ARMmite supports up to 8 channels of hardware driven PWM.  The IO direction of the pin will be set to output.  Once programmed these will continue to generate the specified PWM until re-programmed or reset.

Cycletime is in microseconds, is the time for a single PWM cycle. Hightimes are also in microseconds and represent the amount of time during the cycle that the corresponding outputs are high. It is assumed, but not enforced that cycletimes for all channels will be the same.

 channel1  IO(0)          
 channel2  IO(1)
 channel3  IO(2)
 channel4  IO(3)
 channel5  IO(4)
 channel6  IO(9)
 channel7  IO(10)
 channel8

 IO(11)


ARMmite PRO version

The ARMmite PRO also supports up to 8 channels of hardware driven PWM.  The IO direction of the pin will be set to output.  Once programmed these will continue to generate the specified PWM until re-programmed or reset.

Cycletime is in microseconds, is the time for a single PWM cycle. Hightimes are also in microseconds and represent the amount of time during the cycle that the corresponding outputs are high. It is assumed, but not enforced that cycletimes for all channels will be the same.

 channel1  IO(0)          
 channel2  IO(1)
 channel3  IO(8)
 channel4  IO(5)
 channel5  IO(14)
 channel6  IO(10)
 channel7  IO(11)
 channel8

 IO(3)


ARMexpress LITE version

The ARMexpress LITE supports up to 6 channels of hardware driven PWM.  The IO direction of the pin will be set to output.  Once programmed these will continue to generate the specified PWM until re-programmed or reset.  2 of the channels are not available on the pins.

Cycletime is in microseconds, is the time for a single PWM cycle. Hightimes are also in microseconds and represent the amount of time during the cycle that the corresponding outputs are high.  It is assumed, but not enforced that cycletimes for all channels will be the same.

 channel1  IO( 5 )
 channel2  IO( 6 )
 channel3  IO( 3 )
 channel4  not available
 channel5  IO( 14 )
 channel6  not available
 channel7  IO( 13 )
 channel8

 IO( 15 )

SuperPRO version

The PROplus and SuperPRO support up to 6 channels of hardware driven PWM.  The IO direction of the pin will be set to output.  Once programmed these will continue to generate the specified PWM until re-programmed or reset.

Cycletime is in microseconds, is the time for a single PWM cycle. Hightimes are also in microseconds and represent the amount of time during the cycle that the corresponding outputs are high.  It is assumed, but not enforced that cycletimes for all channels will be the same.

 channel1  IO(64)
 channel2  IO(65)
 channel3  IO(66)
 channel4  IO(67)
 channel5  IO(68)
 channel6  IO(69)

The LPC17xx series processors also have an additional 6 channels designed to drive motors.  See details in the Motor PWM Control chapter of the NXP LPC17xx User Manual.  Also these pins can be re-assigned as selected by the PINSEL registers.

 
Example


#include <HWPWM.BAS>    'use HWPWM17 for SuperPRO / PROplus
 '...

'generate 1KHz with 750 and 100 uSec high signals on pins 1,2

HWPWM (2,1000,750)
HWPWM (3,1000,100)

'250 Hz with 1000, 500, 100 uSec high and LOW signals on pins 0,1,2,3

HWPWM (1,4000,1000)
HWPWM (2,4000,500)
HWPWM (3,4000,100)
HWPWM (4,4000,0)