Texas Instruments | DN115 -- Using PWM for Dimmer Function in LED Lighting | Application notes | Texas Instruments DN115 -- Using PWM for Dimmer Function in LED Lighting Application notes

Texas Instruments DN115 -- Using PWM for Dimmer Function in LED Lighting Application notes
Design Note DN115
Using PWM for Dimmer Function in LED Lighting
By Jerry Ng
Keywords
•
•
•
•
1
•
•
•
•
•
•
Dimmer
LED Lighting
PWM
Timer
CC1110Fx
CC1111Fx
CC2510Fx
CC2511Fx
CC2430
CC2431
Introduction
This design note shows how to use
CC251x PWM for dimmer functions in
LED lighting applications. As the
popularity of LED lighting increases, the
CC251x single chip solution not only
provides the wireless remote control
functions but also dimmer function by
using one of its built-in PWMs. By
configuring the timer peripheral to PWM
SWRU227
and set the corresponding registers for
frequency and pulse width, the desired
PWM signal can be generated. It can
highly reduce the complexity of the control
code and the effort on software.
Although this design note discusses the
CC251x in particular, the same principles
apply to CC111x and CC243x as well.
Page 1 of 8
Design Note DN115
Table of Contents
KEYWORDS.............................................................................................................................. 1
1
INTRODUCTION............................................................................................................. 1
2
ABBREVIATIONS........................................................................................................... 2
3
TIMER ............................................................................................................................. 3
3.1
TIMER 1 IN PWM MODE .............................................................................................. 3
4
IMPLEMENTATION ........................................................................................................ 5
5
REFERENCES................................................................................................................ 7
6
GENERAL INFORMATION ............................................................................................ 8
6.1
DOCUMENT HISTORY.................................................................................................. 8
2
Abbreviations
PWM
LED
SoC
Pulse Width Modulation
Light Emitting Diode
System On Chip
SWRU227
Page 2 of 8
Design Note DN115
3
Timer
CC251xFx, CC111xFx, CC243x are RF system-on-chip (SoC) design for low power wireless
applications. It incorporates RF transceiver and 8051 MCU with peripherals. The CC251x
includes, among others, ADC, I2S interface, USART and Timers.
Timer 1 of CC251x is an independent 16-bit timer which supports typical timer/counter
functions such as input capture, output compare and PWM functions. This design note will
discuss how to use timer 1 in PWM mode for dimmer function of LED lighting.
3.1
Timer 1 in PWM mode
Timer 1 provides three running modes including free-running, modulo and up/down. To
control the frequency of the PWM, modulo mode is selected. In modulo mode, the counter on
timer 1 starts from 0x0000 and increments at each active clock edge. When the counter
reaches the terminal count value set in T1CC0 register, the counter is loaded with 0x0000 on
the next timer tick and continues incrementing its value. Therefore, the frequency of the PWM
signal can be set by using T1CC0 register as shown in Figure 1.
Figure 1. Frequency in Modulo Mode
The pulse width of the PWM signal can be controlled by using Timer 1 in output compare
mode. The I/O pin associated with the channel is set/clear/toggled automatically according to
the mode selected. After the timer has been started, the contents of the counter are
compared with the contents of the 16-bit channel compare register T1CCnH:T1CCnL. If the
compare register equals the counter contents, the output pin is set, reset or toggled according
to the compare output mode setting. Thus, the pulse width of the PWM signal can be set by
T1CCnH:T1CCnL as shown in the Figure 2.
SWRU227
Page 3 of 8
Design Note DN115
Figure 2. Pulse Width in Modulo Mode
SWRU227
Page 4 of 8
Design Note DN115
4
Implementation
The CC251x code for initializing Timer 1 is shown below:
/* Timer 1 set Modulo Mode, pre-scaler = 128 (set in T1CTL) */
/* Freq. set by T1CC0H:T1CC0L = 0x1ff */
/* Counter Tick freq = 13MHz / 128 */
/* PWM freq = 13M / 128 / 511 = 198.75 Hz */
T1CC0L = 0xff;
T1CC0H = 0x01;
/* Timer 1 channel 1 set compare mode 4 */
T1CCTL1 |= 0x24;
/* Prescaler set to Tick Freq / 128 */
T1CTL |= 0x0c;
/* Timer 1 CFG set to Alt 2 location */
PERCFG |= 0x40;
/* P1_1 set peripheral func which associated with Timer 1 output */
P1SEL |= 0x2;
Timer 1 is set in modulo mode with frequency set in 16-bit register T1CC0H:T1CC0L.
Channel 1 is set as output compare mode 4 (Clear output on compare-up, set on 0). The I/O
port 1 pin 1 is associated to the Timer 1 for the PWM output. The PWM frequency is
controlled by the tick frequency and the prescaler. The frequency is set to around 200Hz.
The pulse width of the PWM signal is controlled by the contents in 16-bit register
T1CC1H:T1CC1L. For example, to set 1/8 duty, the value to be written to T1CC1H and
T1CC1L are 511 / 8 equals to 64 approximately. To set 7/8 duty, the value is 511 * 7 / 8
equals to 447 approximately. Similarly, the desired PWM frequency and duty cycle can be set
by modifying the 16-bit registers T1CC0H:T1CC0L and T1CC1H:T1CC1L. The wave forms of
1/8 duty and 7/8 duty are shown in Figure 3 and Figure 4 respectively.
Figure 3. 1/8 duty PWM Signal
SWRU227
Page 5 of 8
Design Note DN115
Figure 4. 7/8 duty PWM Signal
SWRU227
Page 6 of 8
Design Note DN115
5
[1]
References
CC2510Fx/CC2511Fx Low-Power SoC (System-on-Chip) with MCU, Memory, 2.4 GHz
RF Transceiver, and USB Controller (SWRS055)
SWRU227
Page 7 of 8
Design Note DN115
6
6.1
General Information
Document History
Revision
SWRU227
Date
2009.06.12
Description/Changes
Initial release.
SWRU227
Page 8 of 8
IMPORTANT NOTICE
Texas Instruments Incorporated and its subsidiaries (TI) reserve the right to make corrections, modifications, enhancements, improvements,
and other changes to its products and services at any time and to discontinue any product or service without notice. Customers should
obtain the latest relevant information before placing orders and should verify that such information is current and complete. All products are
sold subject to TI’s terms and conditions of sale supplied at the time of order acknowledgment.
TI warrants performance of its hardware products to the specifications applicable at the time of sale in accordance with TI’s standard
warranty. Testing and other quality control techniques are used to the extent TI deems necessary to support this warranty. Except where
mandated by government requirements, testing of all parameters of each product is not necessarily performed.
TI assumes no liability for applications assistance or customer product design. Customers are responsible for their products and
applications using TI components. To minimize the risks associated with customer products and applications, customers should provide
adequate design and operating safeguards.
TI does not warrant or represent that any license, either express or implied, is granted under any TI patent right, copyright, mask work right,
or other TI intellectual property right relating to any combination, machine, or process in which TI products or services are used. Information
published by TI regarding third-party products or services does not constitute a license from TI to use such products or services or a
warranty or endorsement thereof. Use of such information may require a license from a third party under the patents or other intellectual
property of the third party, or a license from TI under the patents or other intellectual property of TI.
Reproduction of TI information in TI data books or data sheets is permissible only if reproduction is without alteration and is accompanied
by all associated warranties, conditions, limitations, and notices. Reproduction of this information with alteration is an unfair and deceptive
business practice. TI is not responsible or liable for such altered documentation. Information of third parties may be subject to additional
restrictions.
Resale of TI products or services with statements different from or beyond the parameters stated by TI for that product or service voids all
express and any implied warranties for the associated TI product or service and is an unfair and deceptive business practice. TI is not
responsible or liable for any such statements.
TI products are not authorized for use in safety-critical applications (such as life support) where a failure of the TI product would reasonably
be expected to cause severe personal injury or death, unless officers of the parties have executed an agreement specifically governing
such use. Buyers represent that they have all necessary expertise in the safety and regulatory ramifications of their applications, and
acknowledge and agree that they are solely responsible for all legal, regulatory and safety-related requirements concerning their products
and any use of TI products in such safety-critical applications, notwithstanding any applications-related information or support that may be
provided by TI. Further, Buyers must fully indemnify TI and its representatives against any damages arising out of the use of TI products in
such safety-critical applications.
TI products are neither designed nor intended for use in military/aerospace applications or environments unless the TI products are
specifically designated by TI as military-grade or "enhanced plastic." Only products designated by TI as military-grade meet military
specifications. Buyers acknowledge and agree that any such use of TI products which TI has not designated as military-grade is solely at
the Buyer's risk, and that they are solely responsible for compliance with all legal and regulatory requirements in connection with such use.
TI products are neither designed nor intended for use in automotive applications or environments unless the specific TI products are
designated by TI as compliant with ISO/TS 16949 requirements. Buyers acknowledge and agree that, if they use any non-designated
products in automotive applications, TI will not be responsible for any failure to meet such requirements.
Following are URLs where you can obtain information on other Texas Instruments products and application solutions:
Products
Amplifiers
Data Converters
DLP® Products
DSP
Clocks and Timers
Interface
Logic
Power Mgmt
Microcontrollers
RFID
RF/IF and ZigBee® Solutions
amplifier.ti.com
dataconverter.ti.com
www.dlp.com
dsp.ti.com
www.ti.com/clocks
interface.ti.com
logic.ti.com
power.ti.com
microcontroller.ti.com
www.ti-rfid.com
www.ti.com/lprf
Applications
Audio
Automotive
Broadband
Digital Control
Medical
Military
Optical Networking
Security
Telephony
Video & Imaging
Wireless
www.ti.com/audio
www.ti.com/automotive
www.ti.com/broadband
www.ti.com/digitalcontrol
www.ti.com/medical
www.ti.com/military
www.ti.com/opticalnetwork
www.ti.com/security
www.ti.com/telephony
www.ti.com/video
www.ti.com/wireless
Mailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265
Copyright © 2009, Texas Instruments Incorporated
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertising