STMPE2401 is the first in the family of ST port-expander logic products. The principle of a
basic expander logic is to provide additional I/Os that can be used by the host processor to
implement additional features such as increasing the number of control signals and mixed
signal lines, or controlling more number of peripherals.
In addition to the above mentioned basic features, STMPE2401 comes with integrated
intelligence to implement advanced features like Keypad scanning, PWM control, and
Rotator dial control. These features enable the processor load to be reduced.
There is also a provision for using a single crystal clock to drive multiple STMPE2401
devices by cascading the devices and using the CLKOUT mode to drive the clock of the
cascaded devices.
STMPE2401 can be widely used in the fields of Mobile Communications, Portable media
players, Game console, Mobile Phones, Smart Phones, Consumer Electronics and
computer peripherals like state-of-the-art printers, Advanced embedded systems etc.
This application note explains the setup and programming of the integrated PWM controller
in STMPE2401 to do LED backlighting, brightness control, and LED blinking patterns.
–Advanced programmable ramping/blinking patterns for lighting effects
–Analog/PWM output
–Application: Mobile phone backlighting, LED brightness control
1.1 STMPE2401 default power-up configuration
STMPE2401 operates at a supply voltage of 1.8 V. The clock can be supplied through a 32
KHz crystal connected across XTALIN, XTALOUT pins or through an external oscillator
clock on XTALIN pin. The external oscillator can be low accuracy (16 KHz ~ 32 KHz) and
the clock frequency for normal operation should not exceed 32 KHz. The Reset pin should
be pulled high for the device to come out of reset and operate in the normal operating mode.
The device can be accessed through the I
can be connected to the same I
2
Philip I
C specification Ver 2.1. The slave address is selected by the state of two pins
(GPIO15 and GPIO23). The state of the pins is latched into STMPE2401 at power on and
this address setting is retained until the power is switched off.
2
C bus. STMPE2401 supports 7-bit addressing as per the
2
C lines)
2
C interface and up to four STMPE2401 devices
The address can be changed and latched-in again using the soft_reset bit in the SYSCON
register.
2
The I
C Read/Write is done byte by byte. The R/W bit is added as the LSB to the 7-bit slave
address to make up one byte to be sent through the I
slave address is configured and responding correctly, the internal registers can be accessed
through I
and the I
2
C read and write commands. Ta bl e 1 lists the slave addresses that can be used
2
C Read/Write protocol to access the device registers.
2
C interface from the Master. Once the
Table 1.Valid STMPE2401 slave address
ADDR1
(GPIO23)
0042h (1000010b)84h
0143h (1000011b)86h
1044h (1000100b)88h
1145h (1000101b)8Ah
ADDR0
(GPIO15)
7-bit slave
addressing
8-bit format to be
used (including R/W
bit in LSB)
4/22
AN2424PWM controller
S
S
M
S
Figure 1.I2C Read/Write protocol
One Byt e
Re ad
More than
One Byt e
Re ad
One Byt e
Write
ore than
One Byt e
Write
Dev
Addr
Start
Dev
Addr
Start
Dev
Addr
Start
Dev
Addr
Start
Master
Slave
At power-up all GPIOs function as inputs and by default the interrupt is configured as an
Active Low Level interrupt. The interrupt however remains low irrespective of the settings
until the Global Interrupt bit in the ICR register is enabled (set to '1').
2 PWM controller
Reg
Addr
RnW=0
Ack
Reg
Addr
RnW=0
Ack
Reg
Addr
RnW=0
Ack
Reg
Addr
RnW=0
Ack
Ack
Ack
Ack
Ack
Dev
Addr
reStart
Dev
Addr
reStart
Dat a t o
be
Written
Dat a t o
Write
RnW=1
RnW=1
top
Ack
Data to
Write + 1
Ack
Data
Rea d
Ack
Data
Rea d
Ack
Ack
NoAck
Ack
Data to
Write + 2
top
Dat a
Read + 1
Ack
top
Read + 2
Ack
Data
NoAck
Stop
STMPE2401 comes with an integrated PWM controller that can provide three independent
PWM outputs. These outputs can be used to generate light effects like rapid blinking or
dimming in LEDs. There are three PWM channels and they can be triggered independently.
Each PWM channel can be triggered by the other two channels. The unused PWM output
pins can be used as GPIO.
Each channel comes with a maximum 64 words x 16-bit command memory. The instructions
to be stored in the command memory can be downloaded through the I
2
C connections. Any
attempt to load beyond 64 words causes the internal address pointer to roll-over (0x1f ->
0x00) and the excess instructions overwrite the first address location of the channel and
onwards.
5/22
Operation modes and clockingAN2424
3 Operation modes and clocking
The PWM controller can be enabled only in the normal operational mode. In operational
mode, the PWM controller output is generated using the 32 KHz clock. The instruction
fetching and execution is also derived from the 32 KHz clock domain. The internal 5 MHz
clock is used only for the I
PWM is enabled, there is no interruption in the PWM output even though the internal 5 MHz
clock is cut-off in the sleep mode. However, the I
mode and therefore the PWM should be enabled before entering sleep mode.
2
C interface. Therefore, if the device enters sleep mode while the
2
C interface does not function during sleep
During Hibernate mode, the 32 KHz clock is also shut down and all modules are disabled.
The device resumes normal operation only after an I
2
C wake-up or Reset.
When the PWM function is not in use, power consumption can be reduced by gating off the
clock to the PWM Controller. This can be done by setting the 'Enable_PWM' bit in the
SYSCON register to zero.
Writing a ‘0’ to this bit gates off the clock to the PWM Controller module, thus
stopping its operation
Writing a ‘1’ to this bit puts the device in sleep mode. When in sleep mode,
all the units which need to work on clocks synchronous to 32 KHz get the
clocks derived from the 32 KHz domain.The internal RC Oscillator shuts
down.
Set this bit to disable the 32 KHz Clk, thus putting the device in hibernate
5Disable_32 KHz
7Soft_Reset
6/22
mode. Only a Reset or a wakeup on I2C resumes normal operation of the
device.
Writing a ‘1’ to this bit does a soft reset of the device. Once the reset is done,
this bit is cleared to ‘0’ by the Hardware.
AN2424PWM instruction set
4 PWM instruction set
The STMPE2401 PWM controller works as a simple MCU, with a program space of 64
instructions and a simple instruction set. The instructions are all 16-bits in length. The three
most significant bits are used to identify the command.
●RAMP
This instruction starts the PWM counters and the pwm_output depends on the counter
value.
Table 4.RAMP instruction
Bits1514131211109876543210
0PrescaleStep timeSignIncrement
Table 5.RAMP description
BitsNameDescription
6:0IncrementIncrement size. Takes value between 1-126. ‘0’ setting is not allowed.
7Sign
13:8Step Time
14Prescale
‘0’ – Step up counter
‘1’ – Step Down counter
‘0’ – Immediate action
1-63 – Step time per increment
‘0’ – Divide clock by 16
‘1’ – Divide clock by 512 clock
Each increment is broken down into the number of steps specified by the 'Step time'
parameter and the time taken for each step is based on the prescale clock. (refer : Example
2: in section 4.1)
●SMAX (Set Maximum)
This instruction loads the PWM counter with the maximum value of 0xff and the resulting
pwm_output is logic level low.
Table 6.SMAX instruction
Bits 1514131211109876543210
Note:1“x“ don‘t care
●SMIN (Set Minimum)
This instruction loads the PWM counter with the minimum value of 0x0 and the resulting
pwm_output is logic level high.
Table 7.SMIN instruction
Bits 1514131211109876543210
Note:1“x“ don‘t care
0x
1
0x
1
00000001111111
00000011111111
7/22
Loading...
+ 15 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.