Letux 400 Hardware

PWM

You are looking at an old revision of the page PWM. This revision was created by Paul Boddie.

Table of Content

Pulse Width Modulation peripheral

PWM

The PWM (pulse width modulation) peripheral is used to control the brightness of the display backlight.

PWM Registers

Register Offset Purpose
CTR 0x00 Control
PER 0x04 Period
DUT 0x08 Duty

CTR

The control register (CTR) is arranged as follows:

Bits Purpose
7 Enable
6 Abrupt shutdown
5..0 Prescale

PER

The period register (PER) is arranged as follows:

Bits Purpose
9..0 Period

DUT

The duty register (DUT) is arranged as follows:

Bits Purpose
10 Full duty
9..0 Duty

Notes

The prescaler seems to be a simple quantity, not a 4**n progression as seen in the JZ4740 TCSR:PRESCALE field.

Thus, the PWM frequency can be calculated as follows, given observed values:

PWM frequency = clock frequency / prescaler / period count
              = 3686400Hz / 64 / 300
              = 192Hz

The above formula can be rewritten as follows:

PWM frequency = clock frequency / (prescaler * period count)
clock period * prescaler * period count = PWM period
prescaler * period count = PWM period / clock period
prescaler * period count = PWM period * clock frequency

With the prescaler and period count apparently acting together as a larger quantity, the prescaler needs populating when the period count would otherwise exceed the limit of its field.

Zero Field Values

The period and prescale fields may use zero to represent a value of one, with the stored values therefore being one lower than the desired values. In other words, a period of 300 would be represented by storing 299 in the period register.

Various magic values are found in old driver code, but no documentation exists to confirm whether this representation scheme is imposed. Other Ingenic SoCs do appear to use such schemes, however.

Resources

In modern kernels, the following files are pertinent:

  • drivers/pwm/pwm-jz4730.c

Created: 4 years 5 months ago
by Paul Boddie

Old Revisions