Back to ESAcademy Home Page


Microcontroller
Peripheral Timing
Calculator

Philips 87LPC768 - Pulse Width Modulator

Calculate Waveform Descriptions from SFR Values

 

Home

News

Training Classes

Products

Consulting

Technical Library

Contact Us

Recommended books:

The 8051 Microcontroller

Enter the clock frequency being used and the values assigned to the PWM SFRs.
If a channel is not being used then leave its associated SFRs blank.

Valid notation for SFR values:

Binary: 00010010B, 10010010b
Hexadecimal: 0x3D, 3DH, 3Dh

Clock Frequency (MHz): (fclk)
CNSW0 SFR Value: (cnsw0)
CNSW1 SFR Value: (cnsw1)
CPSW0 SFR Value: (cpsw0)
CPSW1 SFR Value: (cpsw1)
CPSW2 SFR Value: (cpsw2)
CPSW3 SFR Value: (cpsw3)
CPSW4 SFR Value: (cpsw4)  

Register Values
Counter Reload Value (CNSW)
cnsw = cnsw0 + (cnsw1<<8)
Channel 0 Compare Value (CPSW)
cpsw00 = cpsw0 + ((cpsw4 & 0x03)<<8)
Channel 1 Compare Value (CPSW)
cpsw01 = cpsw1 + (((cpsw4>>2) & 0x03)<<8)
Channel 2 Compare Value (CPSW)
cpsw02 = cpsw2 + (((cpsw4>>4) & 0x03)<<8)
Channel 3 Compare Value (CPSW)
cpsw03 = cpsw3 + (((cpsw4>>6) & 0x03)<<8)
 
Clock Period, PWM Period, Pulse Lengths and Duty Cycles
  6-clock Mode
(UCFG1.3 = 1)
12-clock Mode
(UCFG1.3 = 0)
PWM Counter Clock Period (us)
tpwmclk6 = 1/fclk

tpwmclk12 = 2/fclk
Period (us)
tp6 = tpwmclk6 x (cnsw + 1)

tp12 = tpwmclk12 x (cnsw + 1)
Channel 0 Pulse Length (us)
tpulse06 = (cnsw - cpsw06 + 1) x tpwmclk6

tpulse012 = (cnsw - cpsw012 + 1) x tpwmclk12
Channel 1 Pulse Length (us)
tpulse16 = (cnsw - cpsw16 + 1) x tpwmclk6

tpulse112 = (cnsw - cpsw112 + 1) x tpwmclk12
Channel 2 Pulse Length (us)
tpulse26 = (cnsw - cpsw26 + 1) x tpwmclk6

tpulse212 = (cnsw - cpsw212 + 1) x tpwmclk12
Channel 3 Pulse Length (us)
tpulse36 = (cnsw - cpsw36 + 1) x tpwmclk6

tpulse312 = (cnsw - cpsw312 + 1) x tpwmclk12
Channel 0 Duty Cycle (%)
dcycle06 = tpulse06/tp6 x 100

dcycle012 = tpulse012/tp12 x 100
Channel 1 Duty Cycle (%)
dcycle16 = tpulse16/tp6 x 100

dcycle112 = tpulse112/tp12 x 100
Channel 2 Duty Cycle (%)
dcycle26 = tpulse26/tp6 x 100

dcycle212 = tpulse212/tp12 x 100
Channel 3 Duty Cycle (%)
dcycle36 = tpulse36/tp6 x 100

dcycle312 = tpulse312/tp12 x 100
Upcoming Classes
   

© ESAcademy, 2000
Author: Andrew Ayre

All materials
provided 'as is'
see Disclaimer

www.esacademy.com
info@esacademy.com