UM10850
All information provided in this document is subject to legal disclaimers.
© NXP B.V. 2016. All rights reserved.
User manual
Rev. 2.4 — 13 September 2016
201 of 464
NXP Semiconductors
UM10850
Chapter 13: LPC5410x SCTimer/PWM (SCT0)
3. To start the SCT, write to the CTRL register:
–
Clear the counters.
–
Clear or set the STOP_L and/or STOP_H bits.
Remark:
The counter starts counting once the STOP bit is cleared as well. If the
STOP bit is set, the SCT waits instead for an event to occur that is configured to
start the counter.
–
For each counter, select unidirectional or bidirectional counting mode (field
BIDIR_L and/or BIDIR_H).
–
Select the prescale factor for the counter clock (CTRL register).
–
Clear the HALT_L and/or HALT_H bit. By default, the counters are halted and no
events can occur.
4. To stop the counters by software at any time, stop or halt the counter (write to
STOP_L and/or STOP_H bits or HALT_L and/or HALT_H bits in the CTRL register).
–
When the counters are stopped, both an event configured to clear the STOP bit or
software writing a zero to the STOP bit can start the counter again.
–
When the counter are halted, only a software write to clear the HALT bit can start
the counter again. No events can occur.
–
When the counters are halted, software can set any SCT output HIGH or LOW
directly by writing to the OUT register.
The current state can be read at any time by reading the STATE register.
To change the current state by software (that is independently of any event occurring), set
the HALT bit and write to the STATE register to change the state value. Writing to the
STATE register is only allowed when the counter is halted (the HALT_L and/or HALT_H
bits are set) and no events can occur.
13.7.12 Configure the SCT without using states
The SCT can be used as standard counter/timer with external capture inputs and match
outputs without using the state logic. To operate the SCT without states, configure the
SCT as follows:
•
Write zero to the STATE register (zero is the default).
•
Write zero to the STATELD and STATEV fields in the EVCTRL registers for each
event.
•
Write 0x1 to the EVn_STATE register of each event. Writing 0x1 enables the event.
In effect, the event is allowed to occur in a single state which never changes while the
counter is running.
13.7.13 SCT PWM Example
shows a simple application of the SCT using two sets of match events (EV0/1
and EV3/4) to set/clear SCT output 0. The timer is automatically reset whenever it
reaches the MAT0 match value.
In the initial state 0, match event EV0 sets output 0 to HIGH and match event EV1 clears
output 0. The SCT input 0 is monitored: If input0 is found LOW by the next time the timer
is reset(EV2), the state is changed to state 1, and EV3/4 are enabled, which create the