Data Guide
Data Guide
DSP Controllers
Reference Guide
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 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.
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.
Following are URLs where you can obtain information on other Texas Instruments products and
application solutions:
Products Applications
Amplifiers amplifier.ti.com Audio www.ti.com/audio
Data Converters dataconverter.ti.com Automotive www.ti.com/automotive
DSP dsp.ti.com Broadband www.ti.com/broadband
Interface interface.ti.com Digital Control www.ti.com/digitalcontrol
Logic logic.ti.com Military www.ti.com/military
Power Mgmt power.ti.com Optical Networking www.ti.com/opticalnetwork
Microcontrollers microcontroller.ti.com Security www.ti.com/security
Telephony www.ti.com/telephony
Video & Imaging www.ti.com/video
Wireless www.ti.com/wireless
Notational Conventions
This document uses the following conventions:
.asect is the directive. This directive has two parameters, indicated by sec-
tion name and address. When you use .asect, the first parameter must be
an actual section name, enclosed in double quotes; the second parameter
must be an address.
The LACC instruction has two parameters. The first parameter, 16-bit con-
stant, is required. The second parameter, shift, is optional. As this syntax
shows, if you use the optional second parameter, you must precede it with
a comma.
Square brackets are also used as part of the pathname specification for
VMS pathnames; in this case, the brackets are actually part of the path-
name (they are not optional).
Braces { } indicate a list. The symbol | (read as or) separates items with-
in the list. Here’s an example of a list:
{ * | *+ | *− }
Unless the list is enclosed in square brackets, you must choose one item
from the list.
This syntax shows that .byte must have at least one value parameter, but
you have the option of supplying additional value parameters, separated
by commas.
iv
Related Documentation From Texas Instruments
The following books describe the C24x and related support tools. To obtain a
copy of any of these TI documents, call the Texas Instruments Literature Re-
sponse Center at (800) 477-8924. When ordering, please identify the book by
its title and literature number. Many of these documents are located on the In-
ternet at http://www.ti.com.
vi
Trademarks
Trademarks
320 Hotline On-line is a trademark of Texas Instruments.
cDSP is a trademark of Texas Instruments.
Code Composer Studio is a trademark of Texas Instruments.
HP-UX is a trademark of Hewlett-Packard Company.
MS-DOS is a registered trademark of Microsoft Corporation.
OS/2 is a trademark of International Business Machines Corporation.
PC is a trademark of International Business Machines Corporation.
PC-DOS is a trademark of International Business Machines Corporation.
Solaris is a trademark of Sun Microsystems, Inc.
SunOS is a trademark of Sun Microsystems, Inc.
TMS320 is a trademark of Texas Instruments.
TMS320C24x is a trademark of Texas Instruments.
Windows is a registered trademark of Microsoft Corporation.
XDS is a trademark of Texas Instruments.
XDS510 is a trademark of Texas Instruments.
XDS510PP is a trademark of Texas Instruments.
XDS510WS is a trademark of Texas Instruments.
XDS511 is a trademark of Texas Instruments.
1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1
Summarizes the TMS320 family of products. Introduces the TMS320x240xA DSP controllers
and lists their key features.
1.1 TMS320 Family Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
1.2 TMS320C240xA Series of DSP Controllers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3
1.3 Peripheral Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-5
1.4 New Features in 240xA Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-6
1.5 240xA Highlights . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7
ix
Contents
x
Contents
Contents xi
Contents
xii
Contents
Contents xiii
Contents
xiv
Contents
Contents xv
Contents
F Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F-1
Explains terms, abbreviations, and acronyms used throughout this book.
xvi
Figures
1−1. 240xA Device Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9
2−1. 240xA Device Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
2−2. System Control and Status Register 1 (SCSR1) — Address 07018h . . . . . . . . . . . . . . . . . 2-3
2−3. System Control and Status Register 2 (SCSR2) — Address 07019h . . . . . . . . . . . . . . . . . 2-5
2−4. Device Identification Number Register (DINR) — Address 701Ch . . . . . . . . . . . . . . . . . . . 2-8
2−5. Peripheral Interrupt Expansion Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-14
2−6. Interrupt Requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-18
2−7. 240xA Interrupt Response and Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-23
2−8. Interrupt Flag Register (IFR) — Address 0006h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-27
2−9. Interrupt Mask Register (IMR) — Address 0004h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-28
2−10. Peripheral Interrupt Vector Register (PIVR) — Address 701Eh . . . . . . . . . . . . . . . . . . . . . 2-30
2−11. Peripheral Interrupt Request Register 0 (PIRQR0) — Address 7010h . . . . . . . . . . . . . . . 2-31
2−12. Peripheral Interrupt Request Register 1 (PIRQR1) — Address 7011h . . . . . . . . . . . . . . . 2-32
2−13. Peripheral Interrupt Request Register 2 (PIRQR2) — Address 7012h . . . . . . . . . . . . . . . 2-33
2−14. Peripheral Interrupt Acknowledge Register 0 (PIACKR0) — Address 7014h . . . . . . . . . 2-34
2−15. Peripheral Interrupt Acknowledge Register 1 (PIACKR1) — Address 7015h . . . . . . . . . 2-35
2−16. Peripheral Interrupt Acknowledge Register 2 (PIACKR2) — Address 7016h . . . . . . . . . 2-36
2−17. External Interrupt 1 Control Register (XINT1CR) — Address 7070h . . . . . . . . . . . . . . . . . 2-39
2−18. External Interrupt 2 Control Register (XINT2CR) — Address 7071h . . . . . . . . . . . . . . . . . 2-40
3−1. Program Memory Map for LF2407A . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6
3−2. 2407A Peripheral Memory Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9
3−3. Data Memory Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-10
3−4. I/O Space Address Map for 2407A . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-12
3−5. Program Address/Data — Visibility Functional Timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-14
3−6. Data Address/ Data — Visibility Functional Timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-15
3−7. 2407A Wait-State Generator Control Register (WSGR) —
I/O-Space Address FFFFh (2407A) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-18
4−1. Reference Resonator/Crystal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4
4−2. Power and Ground Connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-5
5−1. Shared Pin Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2
5−2. I/O Mux Control Register A (MCRA) — Address 7090h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4
5−3. I/O Mux Control Register B (MCRB) — Address 7092h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-5
5−4. I/O Mux Control Register C (MCRC) — Address 7094h . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-7
5−5. Port A Data and Direction Control Register (PADATDIR) . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-8
5−6. Port B Data and Direction Control Register (PBDATDIR) . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-9
5−7. Port C Data and Direction Control Register (PCDATDIR) . . . . . . . . . . . . . . . . . . . . . . . . . . 5-10
Contents xvii
Figures
xviii
Figures
6−38. Quadrature Encoded Pulses and Decoded Timer Clock and Direction . . . . . . . . . . . . . . . 6-82
6−39. EVA Interrupt Flag Register A (EVAIFRA) — Address 742Fh . . . . . . . . . . . . . . . . . . . . . . . 6-87
6−40. EVA Interrupt Flag Register B (EVAIFRB) — Address 7430h . . . . . . . . . . . . . . . . . . . . . . . 6-89
6−41. EVA Interrupt Flag Register C (EVAIFRC) — Address 7431h . . . . . . . . . . . . . . . . . . . . . . 6-90
6−42. EVA Interrupt Mask Register A (EVAIMRA) — Address 742Ch . . . . . . . . . . . . . . . . . . . . . 6-91
6−43. EVA Interrupt Mask Register B (EVAIMRB) — Address 742Dh . . . . . . . . . . . . . . . . . . . . . 6-92
6−44. EVA Interrupt Mask Register C (EVAIMRC) — Address 742Eh . . . . . . . . . . . . . . . . . . . . . 6-93
6−45. EVB Interrupt Flag Register A (EVBIFRA) — Address 752Fh . . . . . . . . . . . . . . . . . . . . . . 6-94
6−46. EVB Interrupt Flag Register B (EVBIFRB) — Address 7530h . . . . . . . . . . . . . . . . . . . . . . 6-96
6−47. EVB Interrupt Flag Register C (EVBIFRC) — Address 7531h . . . . . . . . . . . . . . . . . . . . . . 6-97
6−48. EVB Interrupt Mask Register A (EVBIMRA) — Address 752Ch . . . . . . . . . . . . . . . . . . . . . 6-98
6−49. EVB Interrupt Mask Register B (EVBIMRB) — Address 752Dh . . . . . . . . . . . . . . . . . . . . . 6-99
6−50. EVB Interrupt Mask Register C (EVBIMRC) — Address 752Eh . . . . . . . . . . . . . . . . . . . . 6-100
7−1. Block Diagram of Autosequenced ADC in Cascaded Mode . . . . . . . . . . . . . . . . . . . . . . . . . 7-5
7−2. Block Diagram of Autosequenced ADC With Dual Sequencers . . . . . . . . . . . . . . . . . . . . . . 7-6
7−3. Flow Chart for Uninterrupted Autosequenced Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-9
7−4. Example of Event Manager Triggers to Start the Sequencer . . . . . . . . . . . . . . . . . . . . . . . 7-11
7−5. Interrupt Operation During Sequenced Conversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-16
7−6. ADC Conversion Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-17
7−7. Clock Prescalers in 240xA ADC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-18
7−8. Calibration Register − Address 70B8h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-19
7−9. ADC Control Register 1 (ADCTRL1) — Address 70A0h . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-20
7−10. ADC Control Register 2 (ADCTRL2) — Address 70A1h . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-26
7−11. Maximum Conversion Channels Register (MAXCONV) — Address 70A2h . . . . . . . . . . . 7-31
7−12. Autosequence Status Register (AUTO_SEQ_SR) — Address 70A7h . . . . . . . . . . . . . . . 7-33
7−13. ADC Input Channel Select Sequencing Control Registers (CHSELSEQn) . . . . . . . . . . . 7-35
7−14. ADC Conversion Result Buffer Registers (RESULTn) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-37
8−1. SCI Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-4
8−2. Typical SCI Data Frame Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-8
8−3. Idle-Line Multiprocessor Communication Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-11
8−4. Double-Buffered WUT and TXSHF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-12
8−5. Address-Bit Multiprocessor Communication Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-14
8−6. SCI Asynchronous Communications Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-15
8−7. SCI RX Signals in Communication Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-16
8−8. SCI TX Signals in Communications Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-17
8−9. SCI Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-20
8−10. SCI Communication Control Register (SCICCR) — Address 7050h . . . . . . . . . . . . . . . . . 8-21
8−11. SCI Control Register 1 (SCICTL1) — Address 7051h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-23
8−12. Baud-Select MSbyte Register (SCIHBAUD) — Address 7052h . . . . . . . . . . . . . . . . . . . . . 8-26
8−13. Baud-Select LSbyte Register (SCILBAUD) — Address 7053h . . . . . . . . . . . . . . . . . . . . . . 8-26
8−14. SCI Control Register 2 (SCICTL2) — Address 7054h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-27
8−15. Receiver Status Register (SCIRXST) — Address 7055h . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-28
8−16. Register SCIRXST Bit Associations — Address 7055h . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-30
8−17. Emulation Data Buffer Register (SCIRXEMU) — Address 7056h . . . . . . . . . . . . . . . . . . . 8-31
Contents xix
Figures
xx
Figures
Contents xxi
Tables
1−1. Hardware Features of 240xA Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7
2−1. Description of Low-Power Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3
2−2. 240xA Interrupt Source Priority and Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9
2−3. Peripheral Interrupt Request Descriptions (PIRQR0) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-31
2−4. Peripheral Interrupt Request Descriptions (PIRQR1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-33
2−5. Peripheral Interrupt Request Descriptions (PIRQR2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-34
2−6. Peripheral Interrupt Acknowledge Descriptions (PIACKR0) . . . . . . . . . . . . . . . . . . . . . . . . 2-35
2−7. Peripheral Interrupt Acknowledge Descriptions (PIACKR1) . . . . . . . . . . . . . . . . . . . . . . . . 2-36
2−8. Peripheral Interrupt Acknowledge Descriptions (PIACKR2) . . . . . . . . . . . . . . . . . . . . . . . . 2-37
3−1. Data Page 0 Address Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-11
3−2. XMIF Signal Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-13
3−3. Setting the Number of Wait States With the 2407A WSGR Bits . . . . . . . . . . . . . . . . . . . . 3-19
4−1. Low-Power Modes Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-9
5−1. 240xA Digital I/O Port Control Registers Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3
5−2. I/O Mux Control Register A (MCRA) Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-5
5−3. I/O Mux Control Register B (MCRB) Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-6
5−4. I/O Mux Control Register C (MCRC) Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-7
5−5. PADATDIR I/O Pin Designation (Assuming Pins Have Been Selected as I/O;
i.e., Secondary Function) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-9
5−6. PBDATDIR I/O Pin Designation (Assuming Pins Have Been Selected as I/O;
i.e., Secondary Function) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-10
5−7. PCDATDIR I/O Pin Designation (Assuming Pins Have Been Selected as I/O;
i.e., Secondary Function) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-11
5−8. PDDATDIR I/O Pin Designation (Assuming Pins Have Been Selected as I/O;
i.e., Secondary Function) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-12
5−9. PEDATDIR I/O Pin Designation (Assuming Pins Have Been Selected as I/O;
i.e., Secondary Function) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-13
5−10. PFDATDIR I/O Pin Designation (Assuming Pins Have Been Selected as I/O;
i.e., Secondary Function) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-14
6−1. Event Manager A Pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-7
6−2. Event Manager B Pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-8
6−3. Addresses of EVA Timer Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-11
6−4. Addresses of EVB Timer Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-11
6−5. Addresses of EVA Compare Control Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-11
6−6. Addresses of EVB Compare Control Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-12
6−7. Addresses of EVA Capture Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-12
6−8. Addresses of EVB Capture Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-12
6−9. Addresses of EVA Interrupt Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-13
xxii
Tables
Contents xxiii
Tables
xxiv
Examples
7−1. Conversion in Dual-Sequencer Mode Using SEQ1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-8
7−2. Sequencer Start/Stop Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-10
7−3. MAXCONV Register Bit Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-32
7−4. Calculating the Conversion Time for a Multiple Conversion Sequence With
CPS = 0 and ACQ = 0: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-39
7−5. Calculating the Conversion Time for a Single Conversion Sequence With
CPS = 1 and ACQ = 1: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-39
9−1. Transmission of Bit from SPIRXBUF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-12
9−2. Maximum Baud-Rate Calculation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-13
Contents xxv
Notes
Re-enabling interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-21
Do Not Write to Test/Emulation Addresses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-10
Do Not Write to Test/Emulation Addresses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-10
Validating Resonator/Crystal Vendors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4
Failure to Clear the Interrupt Flag Bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-87
Dual-Sequencer Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-4
Using the RESET Bit in the ADCTRL1 Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-20
The Address-bit format is for transfers of 11 bytes or less . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-13
Unused Message Mailboxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-12
Power-on reset (POR) and WDFLAG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-10
Power-on reset (POR) and WDFLAG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-10
xxvi
Chapter 1
This reference guide describes the following 240xA devices: 2407A, 2406A,
2404A, 2403A, 2402A, and 2401A.
This chapter provides an overview of the current TMS320 family, describes the
background and benefits of the 240xA DSP controller products, and
introduces the 240xA devices. These low-cost DSPs are intended to enable
multiple applications for a nominal price.
Throughout this book, all devices are referred to as 240xA devices. This book
is applicable for both the 240x and 240xA families of devices and will be
applicable for future derivatives of the 240xA family. Any feature that is not
applicable for the 240x family is highlighted as appropriate. This book should
be used in conjunction with the TMS320F/C24x DSP Controllers Reference
Guide: CPU and Instruction Set (literature number SPRU160) and the
appropriate device data sheet. Device errata are updated as and when an
exception to functional specification of the silicon is discovered. Refer to the
latest errata for exceptions to functional specifications and possible
workarounds.
Topic Page
1.1 TMS320 Family Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
1.2 TMS320C240xA Series of DSP Controllers . . . . . . . . . . . . . . . . . . . . . . 1-3
1.3 Peripheral Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-5
1.4 New Features in 240xA Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-6
1.5 240xA Highlights . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7
1-1
TMS320 Family Overview
1-2
TMS320C240xA Series of DSP Controllers
More efficient and quieter operation due to diminished torque ripple, re-
sulting in less loss of power, lower vibration, and longer life
Control-Based Applications
The 240xA DSP controllers are designed to meet the needs of control-based
applications. By integrating the high performance of a DSP core and the
on-chip peripherals of a microcontroller into a single-chip solution, the 240xA
series yields a device that is an affordable alternative to traditional
microcontroller units (MCUs) and expensive multichip designs. At 40 million
instructions per second (MIPS), the 240xA DSP controllers offer significant
performance over traditional 16-bit microcontrollers and microprocessors.
(240x devices operate at 30 MIPS.)
Introduction 1-3
TMS320C240xA Series of DSP Controllers
The 16-bit, fixed-point DSP core of the 240xA device provides analog
designers a digital solution that does not sacrifice the precision and
performance of their systems. In fact, system performance can be enhanced
through the use of advanced control algorithms for techniques such as
adaptive control, Kalman filtering, and state control. The 240xA DSP
controllers offer reliability and programmability. Analog control systems, on the
other hand, are hardwired solutions and can experience performance
degradation due to aging, component tolerance, and drift.
1-4
Peripheral Overview
Event Manager: Timers and PWM generators for digital motor control
CAN Interface: Controller Area Network (CAN) 2.0b compatible, with six
mailboxes
Watchdog timer
Note:
For device pinouts, electrical characteristics, and timing specifications of
LF240x devices, see the following data sheet:
TMS320LF2407, TMS320LF2406, TMS320LF2402 DSP Controllers Data
Sheet (literature number SPRS094).
For LF/LC240xA devices, see the following data sheets:
TMS320LF2407A, TMS320LF2406A, TMS320LF2403A,
TMS320LF2402A, TMS320LC2406A, TMS320LC2404A,
TMS320LC2402A DSP Controllers Data Sheet (literature number
SPRS145); TMS320LF2401A, TMS320LC2401A DSP Controllers Data
Sheet (literature number SPRS161).
Introduction 1-5
New Features in 240xA Devices
Input qualifier circuitry for PDPINTx, CAPn, XINTn, and ADCSOC pins
1-6
1.5 240xA Highlights
Available device configurations and their features are shown in Table 1−1.
Introduction
Conversion Time (minimum) 375 ns 375 ns 375 ns 375 ns 500 ns 375 ns 375 ns 425 ns 500 ns
SPI Yes Yes Yes — — Yes Yes — —
Shading denotes features that are different/new compared to 240x devices.
† Some pins may not be applicable to Lx2401A.
1-7
240x Highlights
1-8
Table 1−1. Hardware Features of 240xA Devices (Continued)
Feature LF2407A LF2406A LF2403A LF2402A LF2401A LC2406A LC2404A LC2402A LC2401A
SCI Yes Yes Yes Yes Yes Yes Yes Yes Yes
240x Highlights
Introduction
Supply Voltage 3.3 V 3.3 V 3.3 V 3.3 V 3.3 V 3.3 V 3.3 V 3.3 V 3.3 V
Packaging 144-pin 100-pin 64-pin 64-pin 32-pin 100-pin 100-pin 64-pin 32-pin
PGE PZ PAG PG VF PZ PZ PG, PAG VF
Shading denotes features that are different/new compared to 240x devices.
† Some pins may not be applicable to Lx2401A.
240x Highlights
ÈÈÈÈÈÈÈ
32 Words XINT2/ADCSOC/IOPD0
ÈÈÈÈÈÈÈÈÈÈÈÈÈÈ
SCITXD/IOPA0
SCI SCIRXD/IOPA1
ÈÈÈÈÈÈÈÈÈÈÈÈÈÈ
VDD (3.3 V)
SPISIMO/IOPC2
VSS SARAM (2K Words)
SPISOMI/IOPC3
ÈÈÈÈÈÈÈÈÈÈÈÈÈÈ
SPI SPICLK/IOPC4
ÈÈÈÈÈÈÈÈÈÈÈÈÈÈ
SPISTE/IOPC5
TP1
CANTX/IOPC6
ÈÈÈÈÈÈÈÈÈÈÈÈÈÈ
TP2 Flash/ROM CAN CANRX/IOPC7
VCCP(5V) (32K Words:
ÈÈÈÈÈÈÈ
4K/12K/12K/4K)
WD
ÈÈÈÈÈÈÈ
Port A(0−7) IOPA[0:7]
A0−A15 Port B(0−7) IOPB[0:7]
ÈÈÈÈÈÈÈ
D0−D15 Port C(0−7) IOPC[0:7]
Digital I/O
ÈÈÈÈÈÈÈ
PS, DS, IS (shared with other pins) Port D(0) IOPD[0]
R/W Port E(0−7) IOPE[0:7]
ÈÈÈÈÈÈÈ
RD Port F(0−6) IOPF[0:6]
TRST
ÈÈÈÈÈÈÈ
READY
STRB External memory interface TDO
ÈÈÈÈÈÈÈ
WE TDI
ENA 144 JTAG port TMS
ÈÈÈÈÈÈÈ
TCK
ÈÈÈÈÈÈÈÈÈÈÈÈÈÈ
VIS OE EMU0
W/R / IOPC0 EMU1
ÈÈÈÈÈÈÈ
PDPINTA PDPINTB
ÈÈÈÈÈÈÈ
CAP1/QEP1/IOPA3 CAP4/QEP3/IOPE7
CAP2/QEP2/IOPA4 CAP5/QEP4/IOPF0
ÈÈÈÈÈÈÈ
CAP3/IOPA5 CAP6/IOPF1
PWM1/IOPA6 PWM7/IOPE1
ÈÈÈÈÈÈÈ
PWM2/IOPA7
Event manager A Event manager B
PWM8/IOPE2
ÈÈÈÈÈÈÈ
PWM3/IOPB0 3 × Capture input 3 × Capture input PWM9/IOPE3
PWM4/IOPB1 6 × Compare/PWM 6 × Compare/PWM PWM10/IOPE4
ÈÈÈÈÈÈÈ
PWM5/IOPB2 output output PWM11/IOPE5
2 × GP timers/PWM 2 × GP timers/PWM
ÈÈÈÈÈÈÈ
PWM6/IOPB3 PWM12/IOPE6
T1PWM/T1CMP/IOPB4 T3PWM/T3CMP/IOPF2
ÈÈÈÈÈÈÈ
T2PWM/T2CMP/IOPB5 T4PWM/T4CMP/IOPF3
ÈÈÈÈÈÈÈ
TDIRA/IOPB6 TDIRB/IOPF4
TCLKINA/IOPB7 TCLKINB/IOPF5
ÈÈÈ
ÈÈÈ
Indicates optional modules. The memory size and peripheral selection of these modules change for different
240xA devices. See Table 1−1 for device-specific details. For a device overview figure of the 2401A device,
see TMS320LF2401A, TMS320LC2401A DSP Controllers Data Sheet (literature number SPRS161).
1-9
This page intentionally left blank.
1-10
Chapter 2
Topic Page
2-1
Architecture Summary
Mem I/F
Event
ADC Interrupts I/O
Managers SPI SCI CAN WD
control reset, etc. registers
(EVA and EVB)
ADC
2-2
Configuration Registers
Figure 2−2. System Control and Status Register 1 (SCSR1) — Address 07018h
15 14 13 12 11 10 9 8
Reserved CLKSRC LPM1 LPM0 CLK PS2 CLK PS1 CLK PS0 Reserved
Bit 15 Reserved
These bits indicate which low-power mode is entered when the CPU executes
the IDLE instruction. See Table 2−1 for a description of the low-power modes.
01 IDLE2. (LPM1)
1x HALT (LPM2)
Bits 11−9 PLL Clock prescale select. These bits select the PLL multiplication factor for
the input clock.
Bit 8 Reserved
2-4
Configuration Registers
Note:
In order to modify/read the register contents of any peripheral, the clock to
that peripheral must be enabled by writing a 1 to the appropriate bit.
Bit 1 Reserved
Figure 2−3. System Control and Status Register 2 (SCSR2) — Address 07019h
15−8
Reserved
RW-0
7 6 5 4 3 2 1 0
WD
Reserved I/P QUAL XMIF HI-Z BOOT EN MP/MC DON PON
OVERRIDE
This bit determines the width of the glitches (in number of internal clock cycles)
that will be blocked. Note that the internal clock is not the same as CLKOUT,
although its frequency is the same as CLKOUT.
0 The input-qualifier circuitry blocks glitches up to 5 clock cycles long
1 The input-qualifier circuitry blocks glitches up to 11 clock cycles
long
Note:
This bit is applicable only for the 240xA devices, not for the 240x devices
since they lack an input-qualifier circuitry.
After RESET, this bit gives you the ability to protect the WD function from being
disabled through software (by setting the WDDIS bit = 1 in the WDCR). This
bit is a clear-only bit and defaults to a 1 after reset, Note: this bit is cleared by
writing a 1 to it.
0 Protects the WD from being disabled by software. This bit cannot
be set to 1 by software. It is a clear-only bit, cleared by writing a 1.
Clearing this bit would enable the WD if it were currently disabled.
1 This is the default reset value and allows the user to disable the
WD through the WDDIS bit in the WDCR. Once cleared however,
this bit can no longer be set to 1 by software, thereby protecting
the integrity of the WD timer.
This bit controls the state of the external memory interface (XMIF) signals.
0 XMIF signals in normal driven mode; i.e., not Hi-Z (high impedance)
1 All XMIF signal are forced to Hi-Z state
Note:
This bit is a reserved bit on all devices other than LF2407/2407A, and must
be written only as a zero.
This bit reflects the state of the BOOT_EN / XF pin at the time of reset. After
reset and device has “Booted up”, this bit can be changed in software to
re-enable Flash memory visibility, or return to active Boot ROM.
0 Enable Boot ROM — Address space 0000 — 00FF is now occu-
pied by the on-chip Boot ROM Block. Flash memory is totally dis-
abled in this mode. Note: There is no on-chip boot ROM in ROM
devices (i.e., LC240xA)
1 Disable Boot ROM — Program address space 0000 — 7FFF is
mapped to on-chip Flash Memory in the case of LF2407A and
LF2406A. In the case of LF2402A, addresses 0000 − 1FFF are
mapped
2-6
Configuration Registers
This bit reflects the state of the MP/MC pin at time of reset. After reset, this bit
can be changed in software to allow dynamic mapping of memory on and off
chip.
0 Set to Microcontroller mode — Program Address range 0000 —
7FFF is mapped internally (i.e., Flash)
1 Set to Microprocessor mode — Program Address range 0000 —
7FFF is mapped externally (i.e., Customer provides external
memory device.)
Note: MP/MC pin is available only in LF2407A and LF2407.
Bits 15−4 DIN15−DIN4. These bits contain the hard-wired device-specific device identi-
fication number (DIN).
Bits 3−0 DIN3−DIN0. These bits contain the hard-wired device revision-specific value.
Device Rev # DIN #
LF2407 (rev 1.0 − 1.5) 0510h
LF2407 1.6 0511h
LF240xA, 1.0 0520h
LF240xA 1.1 0521h
LC2406A, LC2404A All revs 0700h
LC2402A All revs 0610h
LF2401A All revs 0810h
LC2401A All revs 0910h
2-8
Interrupt Priority and Vectors
CPU Peripheral
Overall Interrupt Interrupt Interrupt Source
Priority Name Vector Vector Maskable? Peripheral Description
1 Reset RSN N/A N RS Pin, Reset from pin, watch-
0000h Watchdog dog time out
2 Reserved − N/A N CPU Emulator trap
0026h
3 NMI NMI N/A N Nonmaskable Nonmaskable interrupt
0024h interrupt
(a) INT1 (level 1)
CPU Peripheral
Overall Interrupt Interrupt Interrupt Source
Priority Name Vector Vector Maskable? Peripheral Description
4 PDPINTA INT1 0020h Y EVA Power drive protection
0002h interrupt pin
5 PDPINTB INT1 0019h Y EVB Power drive protection
0002h interrupt pin
6 ADCINT INT1 0004h Y ADC ADC interrupt in high-
0002h priority mode
7 XINT1 INT1 0001h Y External External interrupt pin in
0002h interrupt logic high-priority mode
8 XINT2 INT1 0011h Y External External interrupt pin in
0002h interrupt logic high-priority mode
9 SPIINT INT1 0005h Y SPI SPI interrupt in high-
0002h priority mode
10 RXINT INT1 0006h Y SCI SCI receiver interrupt
0002h in high-priority mode
11 TXINT INT1 0007h Y SCI SCI transmitter inter-
0002h rupt in high-priority
mode
12 CANMBINT INT1 0040h Y CAN CAN mailbox interrupt
0002h (high-priority mode)
13 CANERINT INT1 0041h Y CAN CAN error interrupt
0002h (high-priority mode)
2-10
Interrupt Priority and Vectors
2-12
Peripheral Interrupt Expansion (PIE) Controller
Because the C240xA CPU does not have sufficient capacity to handle all
peripheral interrupt requests at the core level, a centralized interrupt controller
(PIE) is required to arbitrate the interrupt requests from various sources such
as peripherals and other external pins (see Figure 2−5).
PDPINTA
PDPINTB
ADCINT PIE
XINT1
XINT2 Level 1
SPIINT IRQ GEN
RXINT INT1
TXINT
CANMBINT
CANERINT
PIRQR0
CMP1INT
CMP2INT
CMP3INT
T1PINT
T1CINT
T1UFINT INT2
T1OFINT Level 2
CMP4INT IRQ GEN
CMP5INT
CMP6INT
T3PINT
T3CINT CPU
T3UFINT
T3OFINT
T2PINT
T2CINT
T2UFINT INT3
T2OFINT Level 3
T4PINT IRQ GEN
T4CINT
T4UFINT
T4OFINT
CAP1INT
CAP2INT INT4
CAP3INT Level 4
PIRQR1
SPIINT
RXINT
Level 5 INT5
TXINT IRQ GEN
CANMBINT
CANERINT
INT6
ADCINT Level 6
XINT1 IRQ GEN
XINT2 IACK
PIRQR#
PIACKR#
PIVR#
Data Addr
bus bus
2-14
Peripheral Interrupt Expansion (PIE) Controller
At the lower level of the hierarchy, the peripheral interrupt requests (PIRQ)
from several peripherals to the interrupt controller are ORed together to
generate an interrupt request (INTn) to the CPU. This is the core level interrupt
request. There is an interrupt flag bit and an interrupt enable bit located in the
peripheral configuration registers for each event that can cause a PIRQ. There
is also one PIRQ for each event. If an interrupt causing event occurs in a
peripheral and the corresponding interrupt enable bit is set, the interrupt
request from the peripheral to the interrupt controller will be asserted. This
interrupt request simply reflects the status of the peripheral’s interrupt flag,
gated with the interrupt enable bit. When the interrupt flag is cleared, the
interrupt request is cleared.
At the upper level of the hierarchy, the ORed PIRQs generate interrupt (INTn)
requests to the CPU. The request to the C240xA CPU is a low-going pulse of
two CPU clock cycles. The PIE controller generates an INTn pulse when any
of the PIRQ’s controlling the INTn become active. If any of the PIRQ’s capable
of asserting the CPU interrupt request are still active in the cycle following an
interrupt acknowledge for the INTn, another INTn pulse is generated. An
interrupt acknowledge clears the highest priority pending PIRQ. Note that the
interrupts are automatically cleared only at the core level and not at the
peripheral level. The interrupt controller (not the peripherals) defines the
following:
This is shown in Table 2−2, 240xA Interrupt Source Priority and Vectors, on
page 2-9.
2-16
Interrupt Vectors
In effect there are two vector tables: The CPU’s vector table which is used to
get to the first, general interrupt service routine (GISR) in response to a CPU
interrupt request; and the peripheral vector table which is used to get to the
event specific interrupt service routine (SISR) corresponding to the event
which caused the PIRQ. The code in the GISR should read the PIVR, and after
saving any necessary context, use this value to generate a vector to the SISR.
IMR
INTM
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 Interrupt
acknowledge
INT6 INT5 INT4 INT3 INT2 INT1
IFR
Interrupt controller
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
PIRQ0 register
Flag Mask
2-18
Interrupt Vectors
There are two levels of interrupt service routine hierarchy: the general interrupt
service routine (GISR), and the specific interrupt service routine (SISR). There
is one GISR for each maskable prioritized request (INT1−INT6) to the CPU
which performs all necessary context saves before it fetches the peripheral
interrupt vector from the PIVR. This vector is used to generate a branch to the
SISR. There is one SISR for every interrupt request (IRQn) from a peripheral
to the interrupt controller, and this SISR performs the required actions in
response to the peripheral interrupt request.
The GISR must read the peripheral interrupt vector from the PIVR before
interrupts are re-enabled. (All interrupts are automatically disabled when an
interrupt is taken.) If the PIVR is not read before interrupts are re-enabled and
another interrupt is asserted, a new peripheral interrupt vector will be loaded
into the PIVR, causing permanent loss of the original peripheral interrupt
vector.
Nonmaskable interrupts such as reset and NMI are not part of PIE. The PIE
controller does not support expansion of nonmaskable interrupts.
The 240xA devices do not have an NMI pin like the 240 or 241/242/243
devices. NMI will be asserted when access to any illegal address is made.
When NMI is asserted, the code will branch to 0024h in program memory,
which is the NMI vector. There is no control register corresponding to the NMI
feature.
The following caution should be observed while using the SARAM on 240xA
devices that lack an external memory interface (XMIF): The last 2 words in
SARAM cannot be used to store a RET or Branch instruction. This is because
when a RET or Branch instruction reaches the execute phase of the pipeline,
the next two instruction words have already been fetched. Since addresses
8800h and above are illegal in 240xA devices that lack XMIF, this asserts an
NMI. As an example, the following code snippet will work:
87FB xxxxx
87FC xxxxx
87FD RET
87FE xxxxx
87FF xxxxx
However, if the RET instruction is pushed down to 87FE or 87FF, an NMI will
be asserted.
This will work fine. However, if the B occupies 87FD or above, then NMI will
be asserted. TBLR and TBLW instructions can operate on data at locations
87FE or 87FF without any issue.
2-20
Interrupt Operation Sequence
The interrupt request to the CPU sets the corresponding flag in the CPU’s
interrupt flag register (IFR). If the CPU interrupt has been enabled by setting
the corresponding bit in the CPU’s interrupt mask register (IMR), the CPU
stops what it is doing, masks all other maskable interrupts by setting the INTM
bit, saves some context, and starts executing the general interrupt service
routine (GISR) for that interrupt priority level (INTn). The CPU generates an
interrupt acknowledge automatically which is accompanied by a value on the
program address bus (PAB) corresponding to the interrupt priority level being
responded to. For example, if INT3 is asserted, its vector 0006h is loaded in
the PAB. This is the interrupt vector corresponding to INTn (refer to Table 2−2
240xA Interrupt Source Priority and Vectors, on page 2-9).
The PIE controller decodes the PAB value and generates a peripheral interrupt
acknowledge to clear the PIRQ bit associated with the CPU interrupt being
acknowledged. The PIE controller then loads the peripheral interrupt vector
register (PIVR) with the appropriate peripheral interrupt vector (or the phantom
interrupt vector) from the table stored in the PIE controller.
When the GISR has completed any necessary context saves, it reads the
PIVR and uses that interrupt vector to branch to the specific interrupt service
routine (SISR) for the interrupt event which occurred in the peripheral.
2-22
Figure 2−7. 240xA Interrupt Response and Flow
Peripheral
CPU branches
interrupt GISR Flow
Peripheral
Peripheral interrupt
interrupt to
occurs
GISR
occurs
occurs
2-23
Interrupt Latency
2) Core Latency is the time it takes for the CPU to recognize the enabled in-
terrupt request, clear it’s pipeline, and begin fetching the first instruction
from the CPU’s interrupt vector table. There is a minimum core latency of
four CPU cycles. If a higher priority maskable interrupt is requested during
this minimum latency period, it is masked until the ISR for the interrupt be-
ing serviced re-enables the interrupt. The latency can be longer than the
minimum if the interrupt request occurs during an uninterruptible opera-
tion; for example, a repeat loop, a multicycle instruction, or during a wait-
stated access. If a higher-priority interrupt occurs during this additional la-
tency period, it gets serviced before the original lower-priority interrupt, as-
suming both are enabled.
3) ISR Latency is the time it takes to get to the specific interrupt service
routine (ISR) code for the event that caused the acknowledged interrupt.
ISR latency can vary depending on how much context saving is required.
2-24
Sample ISR Code
main code
.
B GISR2 ; This instruction resides at 0004h of PM
.
.
;========================================================================
; ISRs
;========================================================================
GISR2: LDP #PIVR >> 7h ; Load the data page containing PIVR
LACL PIVR ; Load PIVR value in the accumulator
XOR #0027h ; Timer 1 period interrupt ?
BCND SISR27,eq ; Branch to T1PINT if Accumulator = 0
; Else reload PIVR in the accumulator and continue
; checking for other peripheral interrupts
EXIT_ISR
CLRC INTM ; Before exiting the SISR, clear the interrupt
RET ; mode bit
Notes:
1) To clear an IFR bit, you must write a one to it, not a zero.
2) When a maskable interrupt is acknowledged, only the IFR bit is cleared
automatically. The flag bit in the corresponding peripheral control regis-
ter is not cleared. If an application requires that the control register flag
be cleared, the bit must be cleared by software.
3) When an interrupt is requested by an INTR instruction and the corre-
sponding IFR bit is set, the CPU does not clear the bit automatically. If
an application requires that the IFR bit be cleared, the bit must be cleared
by software.
4) IMR and IFR registers pertain to core-level interrupts. All peripherals
have their own interrupt mask and flag bits in their respective control/
configuration registers. Note that several peripheral interrupts are
grouped under one core-level interrupt.
2-26
CPU Interrupt Registers
Reserved INT6 flag INT5 flag INT4 flag INT3 flag INT2 flag INT1 flag
Note: 0 = Always read as zeros, R = Read access, W1C = Write 1 to this bit to clear it, -0 = value after reset
Bit 2 INT3. Interrupt 3 flag. This bit is the flag for interrupts connected to interrupt
level INT3.
0 No INT3 interrupt is pending
1 At least one INT3 interrupt is pending. Write a 1 to this bit to clear
it to 0 and clear the interrupt request
Bit 1 INT2. Interrupt 2 flag. This bit is the flag for interrupts connected to interrupt
level INT2.
0 No INT2 interrupt is pending
1 At least one INT2 interrupt is pending. Write a 1 to this bit to clear
it to 0 and clear the interrupt request
Bit 0 INT1. Interrupt 1 flag. This bit is the flag for interrupts connected to interrupt
level INT1.
0 No INT1 interrupt is pending
1 At least one INT1 interrupt is pending. Write a 1 to this bit to clear
it to 0 and clear the interrupt request
You can read the IMR to identify masked or unmasked interrupt levels, and you
can write to the IMR to mask or unmask interrupt levels. To unmask an interrupt
level, set its corresponding IMR bit to one. To mask an interrupt level, set its
corresponding IMR bit to zero. When an interrupt is masked, it is not
acknowledged, regardless of the value of the INTM bit. When an interrupt is
unmasked, it is acknowledged if the corresponding IFR bit is one and the INTM
bit is zero.
The IMR is shown in Figure 2−9, and descriptions of the bits follow the figure.
Reserved INT6 mask INT5 mask INT4 mask INT3 mask INT2 mask INT1 mask
0 RW RW RW RW RW RW
Note: 0 = Always read as zeros, R = Read access, W = Write access, bit values are not affected by a device reset
Bit 5 INT6. Interrupt 6 mask. This bit masks or unmasks interrupt level INT6.
0 Level INT6 is masked
1 Level INT6 is unmasked
Bit 4 INT5. Interrupt 5 mask. This bit masks or unmasks interrupt level INT5.
0 Level INT5 is masked
1 Level INT5 is unmasked
Bit 3 INT4. Interrupt 4 mask. This bit masks or unmasks interrupt level INT4.
0 Level INT4 is masked
1 Level INT4 is unmasked
Bit 2 INT3. Interrupt 3 mask. This bit masks or unmasks interrupt level INT3.
0 Level INT3 is masked
1 Level INT3 is unmasked
2-28
CPU Interrupt Registers
Bit 1 INT2. Interrupt 2 mask. This bit masks or unmasks interrupt level INT2.
0 Level INT2 is masked
1 Level INT2 is unmasked
Bit 0 INT1. Interrupt 1 mask. This bit masks or unmasks interrupt level INT1.
0 Level INT1 is masked
1 Level INT1 is unmasked
Note:
The IMR bits are not affected by a device reset.
Note:
PIRQR0/1/2 and PIACKR0/1/2 are control registers internal to the PIE
module used for generating interrupts (INT1 − INT6) to the CPU. While
programming, these registers can be ignored since they monitor the internal
operation of the PIE. These registers are used for test purposes and are not
intended for user applications.
During the peripheral interrupt acknowledge cycle, the PIVR is loaded with the
interrupt vector of the highest-priority pending interrupt associated with the
CPU interrupt (INTn) being acknowledged (or the phantom interrupt vector).
The PIVR is shown in Figure 2−10.
V7 V6 V5 V4 V3 V2 V1 V0
Bits 15−0 V15−V0. Interrupt vector. This register contains the peripheral interrupt vector
of the most recently acknowledged peripheral interrupt.
2-30
Peripheral Interrupt Registers
2-32
Peripheral Interrupt Registers
15 14 13 12 11 10 9 8
Bit 15 Reserved.
2-34
Peripheral Interrupt Registers
7 6 5 4 3 2 1 0
Bit 15 Reserved.
2-36
Peripheral Interrupt Registers
2.11 Reset
The 240xA devices have two sources of reset:
The reset pin is an I/O pin. If there is an internal reset event (watchdog timer),
the reset pin is put into output mode and driven low to indicate to external
circuits that the 240xA device is resetting itself.
The external reset pin and watchdog timer reset are ORed together to drive
the reset input to the CPU.
2-38
External Interrupt Control Registers
Note: R = Read access, W = Write access, C = Clear by writing a 1, -0 = value after reset
This bit indicates whether the selected transition has been detected on the
XINT1 pin and is set whether or not the interrupt is enabled. This bit is cleared
by the appropriate interrupt acknowledge, by software writing a 1 (writing a 0
has no effect), or by a device reset.
0 No transition detected
1 Transition detected
This read/write bit determines whether interrupts are generated on the rising
edge or the falling edge of a signal on the pin.
0 Interrupt generated on a falling edge (high-to-low transition)
1 Interrupt generated on a rising edge (low-to-high transition)
This read/write bit determines which interrupt priority is requested. The CPU
interrupt priority levels corresponding to low and high priority are coded into
the peripheral interrupt expansion controller. These priority levels are shown
in Table 2−2, 240xA Interrupt Source Priority and Vectors, in Chapter 2 on
page 2-9.
0 High priority
1 Low priority
Note: R = Read access, W = Write access, C = Clear by writing a 1, -0 = value after reset
This bit indicates whether the selected transition has been detected on the
XINT2 pin, and is set whether or not the interrupt is enabled. This bit is cleared
by the appropriate interrupt acknowledge, by software writing a 1 (writing a 0
has no effect), or by a device reset.
0 No transition detected
1 Transition detected
This read/write bit determines whether interrupts are generated on the rising
edge or the falling edge of a signal on the pin.
0 Interrupt generated on a falling edge (high-to-low transition)
1 Interrupt generated on a rising edge (low-to-high transition)
This read/write bit determines which interrupt priority is requested. The CPU
interrupt priority levels corresponding to low and high priority are coded into
the peripheral interrupt expansion controller. These priority levels are shown
in Table 2−2, 240xA Interrupt Source Priority and Vectors, in Chapter 2 on
page 2-9.
0 High priority
1 Low priority
2-40
External Interrupt Control Registers
This chapter describes the RAM, ROM, and Flash availability on the 240xA.
The 2407A device has a 16-bit address bus that can access the following three
individually selectable spaces (192K words total):
64K-word program space
64K-word data space
64K-word I/O space
This chapter shows memory maps for program, data, and I/O spaces. It also
describes available 240xA memory configuration options.
Topic Page
3-1
On-Chip RAM
In the pipeline operation, the CPU reads data on the third cycle and writes data
on the fourth cycle. However, DARAM allows the CPU to write and read in one
cycle; the CPU writes to DARAM on the master phase of the cycle and reads
from DARAM on the slave phase. For example, suppose two instructions, A
and B, store the accumulator value to DARAM and load the accumlator with
a new value from DARAM. Instruction A stores the accumulator value during
the master phase of the CPU cycle, and instruction B loads the new value to
the accumulator during the slave phase. Because part of the dual-access
operation is a write, it only applies to RAM.
3-2
FactoryFactory
MaskedMasked
On-ChipOn-Chip ROM
ROM / Flash
3.3 Flash
The on-chip flash in flash devices is mapped in program memory space. This
flash memory is always enabled in devices that lack an external memory
interface. For the 2407A, which has an external memory interface, the MP/MC
pin determines whether the on-chip program memory (flash) or the off-chip
program memory (customer design specific) is accessed.
240xA devices come with JTAG interface to aid programming and emula-
tion
The following sections explain the Flash programming registers and their bit
functions. Flash programming utilities will be provided by Texas Instruments
(TI). Refer to the TI’s web page (www.ti.com, under 24x Flash tools) for
revisions of these utilities.
Memory 3-3
Flash
The Flash control registers are used to program the Flash array. These
registers are a part of the Flash wrapper and are mapped at the same start
address as the Flash array itself. These registers are not visible (disabled)
during Flash array mode (i.e., Flash read). During the Flash control register
mode, the Flash program control registers are enabled and the Flash array is
disabled (i.e., not accessible to CPU).
An OUT instruction, using the register address as an I/O port, places the
flash module in register-access mode. The data operand used is insignifi-
cant. For example:
OUT dummy, 0FF0Fh; Selects register-access mode
An IN instruction, using the register address as an I/O port, places the flash
module in array-access mode. The data operand used is insignificant. For
example:
IN dummy, 0FF0Fh; Selects array-access mode
3-4
Flash / Overview of Memory and I/O Spaces
In the case of serial port flash programming utilities, the available number of
frequencies is limited further by the serial port synchronization protocol
implemented within the Boot ROM. See Appendix C, TMS320F240x Boot
ROM Loader: Protocols and Interfacing.
The 240xA address map is organized into three individually selectable spaces:
These spaces provide a total address space of 192K words. The 240xA
devices include on-chip memory to aid in system performance and integration.
Higher performance than external memory (because the wait states re-
quired for slower external memories are avoided)
Memory 3-5
Program Memory
ÇÇÇÇÇÇÇÇ
Interrupt level 6 000Ch−000Dh
FDFFh
ÇÇÇÇÇÇÇÇ
FE00h Reserved 000Eh−000Fh
Reserved
ÇÇÇÇÇÇÇÇ
(CNF = 1) Software interrupts 0010h−0021h
ÇÇÇÇÇÇÇÇ
FEFF
FF00
(External if CNF = 0)
On-chip
TRAP
NMI
0022h−0023h
0024h−0025h
DARAM (B0) Reserved 0026h−0027h
(CNF = 1)
(External if CNF = 0) Software interrupts 0028h−003Fh
FFFF
32K on-chip flash (MP/MC = 0)
External (MP/MC = 1)
CNF bit. The CNF bit (bit 12) of status register ST1 determines whether
DARAM B0 is in on-chip program space:
CNF = 0. The 256 words are mapped as external memory.
CNF = 1. The 256 words of DARAM B0 are configured for program
use. At reset, B0 is mapped to data space (CNF = 0).
3-6
Program Memory
MP/MC pin. The level on the MP/MC pin determines whether program
instructions are read from on-chip flash/ROM or external memory:
MP/MC = 0. The device is configured in microcontroller mode. The on-
chip ROM/flash EEPROM is accessible. The device fetches the reset
vector from on-chip memory. Accesses to program memory
addresses 0000h−7FFFh will be made to on-chip memory in the case
of 2407A. Refer to the respective memory maps for other devices.
MP/MC = 1. The device is configured in microprocessor mode. The
device fetches the reset vector from external memory. Accesses to
program memory addresses 0000h−7FFFh will be made to off-chip
memory of the 2407A. Refer to the respective memory maps for other
devices.
Regardless of the value of MP/MC, the 240xA fetches its reset vector at
location 0000h in program memory. Note that there is no MP/MC pin avail-
able on devices that lack an external memory interface.
Memory 3-7
Data Memory
Data memory space addresses up to 64K of 16-bit words. 32K words are
internal memory (0000h to 7FFFh). Internal data memory includes
memory-mapped registers, DARAM, and peripheral memory-mapped
registers. The remaining 32K words of memory (8000h to FFFFh) form part of
the external data memory. Note that addresses 8000h−FFFFh are not
accessible in 2406A, 2404A, and 2402A.
Figure 3−2 shows the data memory map for the 2407A. Each device has three
on-chip DARAM blocks: B0, B1, and B2. B0 is configurable as data memory
or program memory. It is the same memory block accessible either as data
memory or program memory, depending on the CNF bit. Blocks B1 and B2 are
available for data memory only. External data memory is available only on the
2407A.
An access to the following address spaces in the data memory is illegal and
generates an NMI. In addition to these addresses, an access to any of the
reserved addresses within the peripheral register maps is also illegal.
3-8
Data Memory
ÈÈÈÈÈÈÈÈÈ
0060 Reserved 0005
On-chip DARAM B2
ÈÈÈÈÈÈÈÈÈ
007F Interrupt flag register
0080 0006
Illegal Emulation registers 0007
ÈÈÈÈÈÈÈÈÈ
00FF and reserved 005F
ÈÈÈÈÈÈÈÈÈ
0100
Reserved Illegal 7000−700F
01FF System configuration and
0200 7010−701F
ÈÈÈÈÈÈÈÈÈ
control registers
On-chip DARAM B0
ÈÈÈÈÈÈÈÈÈ
Watchdog timer registers 7020−702F
02FF
0300 Illegal 7030−703F
On-chip DARAM B1
03FF
ÈÈÈÈÈÈÈÈÈ ÈÈÈÈÈÈÈÈÈ
0400 SPI 7040−704F
Reserved
SCI 7050−705F
ÈÈÈÈÈÈÈÈÈ ÈÈÈÈÈÈÈÈÈ
04FF
0500 Illegal Illegal 7060−706F
ÈÈÈÈÈÈÈÈÈ
07FF
0800 External-interrupt registers 7070−707F
ÈÈÈÈÈÈÈÈÈ ÈÈÈÈÈÈÈÈÈ
SARAM (2K)
0FFF Illegal 7080−708F
ÈÈÈÈÈÈÈÈÈ
1000
Illegal Digital I/O control registers 7090−709F
ÈÈÈÈÈÈÈÈÈ
6FFF
7000 ADC control registers 70A0−70BF
ÈÈÈÈÈÈÈÈÈ
Peripheral frame 1 (PF1)
73FF Illegal 70C0−70FF
7400
ÈÈÈÈÈÈÈÈÈ ÈÈÈÈÈÈÈÈÈ
Peripheral frame 2 (PF2)
743F CAN control registers 7100−710E
ÈÈÈÈÈÈÈÈÈ ÈÈÈÈÈÈÈÈÈ
7440 Illegal Illegal 710F−71FF
ÈÈÈÈÈÈÈÈÈ ÈÈÈÈÈÈÈÈÈ
74FF
7500 CAN mailbox 7200−722F
Peripheral frame 3 (PF3)
ÈÈÈÈÈÈÈÈÈ ÈÈÈÈÈÈÈÈÈ
753F Illegal 7230−73FF
7540 Illegal
77EF Event manager − EVA
77F0
Code security passwords General-purpose timer registers 7400−7408
77F3
ÈÈÈÈÈÈÈÈÈ
77F4 Compare, PWM, and
7411−7419
Reserved deadband registers
ÈÈÈÈÈÈÈÈÈ
77FF
Capture and QEP registers 7420−7429
7800
ÈÈÈÈÈÈÈÈÈ
Illegal Interrupt mask, vector, and
7FFF 742C−7431
8000 flag registers
External†
Illegal 7432−743F
ÈÈÈÈ
FFFF
Event manager − EVB
ÈÈÈÈ “Illegal” indicates that access to these General-purpose timer registers 7500−7508
ÈÈÈÈ
Illegal addresses causes a nonmaskable
Compare, PWM, and
interrupt (NMI). 7511−7519
deadband registers
“Reserved” indicates addresses that are Capture and QEP registers 7520−7529
Reserved reserved for test.
Interrupt mask, vector, and
752C−7531
flag registers
† Available in LF2407A only
Reserved 7532−753F
Memory 3-9
Data Memory
The two registers that can be accessed with zero wait states are:
The test/emulation reserved area is used by the test and emulation sys-
tems for special information transfers.
3-10
Data Memory
The scratch-pad RAM block (B2) includes 32 words of DARAM that pro-
vide for variable storage without fragmenting the larger RAM blocks,
whether internal or external. This RAM block supports dual-access opera-
tions and can be addressed via any data-memory addressing mode.
0005h − Reserved
0023h−0027h − Reserved
CNF bit. The CNF bit (bit 12) of status register ST1 determines whether
the on-chip DARAM B0 is mapped to data space or program space.
CNF = 1. B0 is used for program space.
CNF = 0. B0 is used for data space.
At reset, B0 is mapped into data space (CNF = 0).
Note:
Global Data Memory is not available in the 240xA. Hence, the global memory
allocation register (GREG) is a reserved location and should not be ac-
cessed.
Memory 3-11
I/O Space
External
ÇÇÇÇÇÇÇ
ÇÇÇÇÇÇÇ
FEFF
FF00
Flash control
FF0F
mode register†
ÇÇÇÇÇÇÇ
ÇÇÇÇÇÇÇ
FF10
Reserved
FFFE
Wait-state generator
FFFF control register‡
3-12
XMIF Qualifier Signal Description
The signals that define the XMIF are given in Table 3−2.
Figure 3−5 and Figure 3−6 show Visibility mode timing diagrams.
Memory 3-13
XMIF Qualifier Signal Description
STRB
VIS OE
3-14
XMIF Qualifier Signal Description
STRB
VIS OE
R/W
Memory 3-15
Program
Program and
and Data
Data Spaces
Spaces / I/O Space
Two cycles are required on all external writes, including a half-cycle before WE
goes low and a half-cycle after WE goes high. This prevents data contention
on the external buses.
While accesses are made to the on-chip I/O mapped registers, signals IS and
STRB are made inactive, that is, driven to the high state. The external address
and data bus is only active when accesses are made to external I/O memory
locations.
Two cycles are required on all external writes, including a half-cycle before WE
goes low and a half-cycle after WE goes high. This prevents data contention
on the external busses.
3-16
Wait-State Generation
To avoid bus conflicts, writes from the 2407A always take at least two
CLKOUT cycles. The 2407A offers two options for generating wait states:
The READY signal. With the READY signal, you can externally generate
any number of wait states.
The on-chip wait-state generator. With this generator, you can generate
zero to seven wait states.
The READY pin can be used to generate any number of wait states. However,
when the 2407A operates at full speed, it cannot respond fast enough to
provide a READY-based wait state for the first cycle. For extended wait states
using external READY logic, the on-chip wait-state generator must be
programmed to generate at least one wait state.
Memory 3-17
Wait-State Generation
Bits 15−11 Reserved. Bits 15−11 are reserved and always read as 0s.
Bits 10−9 Bus visibility modes. Bits 10−9 allow selection of various bus visibility modes
while running from internal program and/or data memory. These modes pro-
vide a method of tracing internal bus activity.
Bit 10 Bit 9 Visibility mode
0 0 Bus visibility OFF (reduces power and noise)
0 1 Bus visibility OFF (reduces power and noise)
1 0 Data-address bus output to external address bus
Data-data bus output to external data bus
1 1 Program-address bus o/p to external address bus
Program-data bus output to external data bus
Note: On the 2407A device, the bus visibility is turned off until the device is
unsecured.
Bits 8−6 ISWS — I/O-space wait-state bits. Bits 8−6 determine the number of wait
states (0−7) that are applied to reads from and writes to off-chip I/O space. At
reset, the three ISWS bits become 111, setting seven wait states for reads from
and writes to off-chip I/O space.
Bits 5−3 DSWS — Data-space wait-state bits. Bits 5−3 determine the number of wait
states (0−7) that are applied to reads from and writes to off-chip data space.
At reset, the three DSWS bits become 111, setting seven wait states for reads
from and writes to off-chip data space.
Bits 2−0 PSWS — Program-space wait-state bits. Bits 2−0 determine the number of
wait states (0−7) that are applied to reads from and writes to off-chip program
space. At reset, the three PSWS bits become 111, setting seven wait states
for reads from and writes to off-chip program space.
Table 3−3 shows how to set the number of wait states you want for each type
of off-chip memory.
3-18
Wait-State Generation
Table 3−3. Setting the Number of Wait States With the 2407A WSGR Bits
ISWS Bits DSWS PSWS
8 7 6 I/O WS 5 4 3 Data WS 2 1 0 Prog WS
0 0 0 0 0 0 0 0 0 0 0 0
0 0 1 1 0 0 1 1 0 0 1 1
0 1 0 2 0 1 0 2 0 1 0 2
0 1 1 3 0 1 1 3 0 1 1 3
1 0 0 4 1 0 0 4 1 0 0 4
1 0 1 5 1 0 1 5 1 0 1 5
1 1 0 6 1 1 0 6 1 1 0 6
1 1 1 7 1 1 1 7 1 1 1 7
Memory 3-19
3-20
Chapter 4
The 240xA devices use the phase-locked loop (PLL) circuit embedded in the
240xA CPU core to synthesize the on-chip clocks from a lower frequency
external clock.
Topic Page
4-1
Pins
Pins / Phase-Locked Loop (PLL)
4.1 Pins
There are three device pins associated with clocks:
XTAL1/CLKIN − This is the clock input from the external crystal to the on-
chip oscillator. If an external oscillator is used, its output must be con-
nected to this pin.
XTAL2 − This is the clock output from the on-chip oscillator to drive the
external crystal.
4.2.1 Overview
This module contains a phased-locked loop (PLL), crystal oscillator, clock
monitor circuit, clock enable circuit, and prescaler.
The PLL’s main disadvantage over a simple oscillator is that they can be
sensitive to noise if proper board decoupling/layout practices are not adhered
to, and thus, require more system-level design effort to insure low jitter, robust
operation.
4-2
Phase-Locked Loop (PLL)
Main features:
Lock: The condition in which the PLL’s output is synchronized to the phase
and frequency of it’s reference input.
4.2.2 Operation
The sections that follow describe the operation and operating modes of the
PLL.
The oscillator requires two external pins: XTAL1/CLKIN and XTAL2 which are
connected to the resonator/crystal and load capacitors (Figure 4−1). The
oscillator is a single-stage inverter held in bias by an integrated bias resistor.
This resistor is disabled only during leakage test measurements and HALT
mode.
Cb
Clock Module
The PLL can also be driven by an external oscillator whose output is connected
to XTAL1/CLKIN pin. XTAL2 is left open in this case.
4-4
Phase-Locked Loop (PLL)
The 240xA PLL needs external R-C components for the loop filter (see device
data sheet for more details). Keep the loop filter (R1, C2, and C2) components
close to their pins (PLLF and PLLF2). This is the primary entry point for noise
which can result in increased jitter.
All PCB traces pertaining to the PLL circuit must be kept as short as possible.
In addition, the loop area formed by the loop filter components, PCB traces,
and DSP chip should be as small as possible. A bypass capacitor (0.1 µF to
0.01 µF, ceramic) should be connected between the PLLVCCA and VSS pins.
The diagram of Figure 4−2 illustrates how to minimize jitter and EMI by
properly filtering VDD, and by using private traces up to the pins as much as
possible.
While Cbypass is required for proper circuit operation, the “T” filter is optional
and is needed only if minimal CPU CLOCK jitter is required in the application.
This is a function of the amount of system noise on the circuit board. Because
this noise is difficult to quantify, optimal results are obtained experimentally.
PLLF
Loop-filter
components
(Make no other connections to
PLLF, PLLF2 pins)
PLLF2
Clock module
Optional filter circuit
fc = 10 MHz
VDD
L1 L2 PLLVCCA
Cf Cbypass
VSS
You should adhere to the following guidelines when connecting the PLL pins:
1) Connect the VCCA pin to the low-pass T filter with short leads. This 10-MHz
cutoff filter is not essential but may improve jitter significantly and reduce
EMI.
2) Keep the traces short to ensure that Cbypass (0.01 to 0.1 µF ceramic) is
closely coupled to the VCCA and VSS pins.
3) Minimize the loop area formed by these traces, the chip, and the bypass
capacitor. Large loop areas increase EMI. Avoid nearby noisy traces
which may couple noise back into the clock module pins.
4-6
Watchdog Timer Clock
WDCLK = CLKOUT
512
4-8
Low-Power Modes
CPU System
Low-Power LPMx Bits Clock Clock WDCLK PLL OSC
Mode SCSR[12:13] Domain Domain Status Status Status Exit Condition
CPU running
XX On On On On On —
normally
Peripheral
IDLE1 − (LPM0) 00 Off On On On On interrupts, XINT1/2,
Reset, PDPINTA/B
Wakeup interrupts,
IDLE2 − (LPM1) 01 Off Off On On On XINT1/2, Reset,
PDPINTA/B
HALT − (LPM2)
{PLL/OSC 1X Off Off Off Off Off Reset, PDPINTA/B
power down}
4.4.2.1 Reset
A reset (from any source) causes the device to exit any of the IDLE modes.
If the device is halted, the reset initially starts the oscillator; however, initiation
of the CPU reset sequence may be delayed while the oscillator powers up
before clocks are generated.
The external interrupts, XINTx, can cause the device to exit any of the
low-power modes, except HALT. If the device is in IDLE2 mode, the
synchronous logic connected to the external interrupt pins is bypassed with
combinatorial logic that recognizes the interrupt on the pin, starts the clocks,
and then allows the clocked logic to generate an interrupt request to the PIE
controller.
Some peripherals have the capability to start the device clocks and then
generate an interrupt in response to certain external events, such as activity
on a communication line. As an example, the CAN wake-up interrupt can
assert the CAN error interrupt request even when there are no clocks running.
As outlined in Table 4−1, peripheral interrupts are used to wake up the device
from different low-power modes. The “wake-up” action (and the subsequent
behavior of the device) is dependent upon the following:
Whether the peripheral interrupt in question has been enabled at the pe-
ripheral level
NOTES:
1) Clock to EVA must be enabled in order for PDPINTA to pull the device out of reset.
2) When the PDPINTA pin is used to wake up the device from LPM2, it must be held low for
4096 CLKIN cycles + (6 or 12) CLKOUT cycles. For a device with a 10-MHz CLKIN and 40-MHz
4-10
Low-Power Modes
CLKOUT, this translates into about 410 µs. The 4096 cycles are required to initiate a clock output
to the CPU. The remaining 12 cycles trigger a valid PDPINTA interrupt.
3) PDPINTA has both a synchronous path and an asynchronous path. The asynchronous path is used
to wake up from HALT; i.e., the clocks are turned on asynchronously by PDPINTA. Once clocks
start, it generates an interrupt. However, PDPINTA must be held low long enough for the first clock’s
edge to catch it.
The Flash module can be powered down before entering the LPM2 mode. This
operation is done while executing code from on-chip RAM, such as SARAM
or B0. This mode achieves the lowest possible current consumption. Following
is the sequence of instructions that powers down the Flash module:
***************************************************************************
; Flash−module power−down routine
;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
LDP #0h ; Set DP=0
SPLK #0008h,60h ; 0008 puts the flash in powerdown mode
OUT 60h,0FF0Fh ; Puts the FLASH in control reg access mode
LACL #0h ; 0000h is the address of the Pump Control Register
TBLW 60h ; This write powers down the flash.
***************************************************************************
The LPM2 mode can be exited by using either the RS or PDPINTx signals.
While RS automatically powers up the Flash module, the following sequence
of instructions should be executed if PDPINTx is used (to exit LPM2) to power
up the Flash module:
***************************************************************************
; Flash−module power−up routine
;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
LDP #0h ; Set DP=0
SPLK #0000h,60h ; 0000 pulls the flash out of powerdown mode
OUT 60h,0FF0Fh ; Puts the FLASH in control reg access mode
LACL #0h ; 0000h is the address of the Pump Control Register
TBLW 60h ; This write powers up the FLASH.
IN 60h,0FF0Fh ; Puts the FLASH in Array access mode
***************************************************************************
After the Flash is powered up, a read of a known location in Flash may be done
to ensure that the Flash is ready for application use. For example, 0000h in
Program memory usually has a “branch” instruction whose opcode is 7980h.
Therefore, address 0000h could be read and checked for 7980h to validate
Flash power-up.
4-12
Chapter 5
The digital I/O ports module provides a flexible method for controlling both
dedicated I/O and shared pin functions. All I/O and shared pin functions are
controlled using nine 16-bit registers. These registers are divided into two
types:
I/O MUX Control registers (MCRx) − Used to control the multiplexor selec-
tion that chooses between the primary function of a pin or the general-
purpose I/O function.
The GPIO pins are controlled through “data-memory mapped registers.” Note
that there is no relationship between the GPIO pins and the I/O space of the
device.
Topic Page
5-1
Digital I/O Ports Register Implementation on 240xA Devices
Note that when multiplexed I/O pins are configured for peripheral functions or
as GPIO outputs, the pin status can be monitored by reading the I/O data
register.
In Out
Pullup
or
Pulldown
(Internal)
5-2
Digital I/O Ports Register Implementation on 240xA Devices
In the 240xA devices, when the bit value in an MCRx register (OCRx regis-
ter in 24x) is one, the primary function is always chosen. Likewise, when
the bit value is zero, the GPIO function is always chosen. There are no ex-
ceptions, as in the case of 24x, where XF, BIO, and CLKOUT pins have
a different configuration.
Also, some pins (such as XF and CLKOUT) are paired with different GPIO
pins compared to the 24x (i.e., the “primary function/GPIO pin” mapping/
pairing is not exactly identical to the 24x.
Due to the addition of two GPIO ports, E and F, a new MUX Control register
(MCRC) has been added.
5-4
I/O Mux Control Registers
Note: Due to the absence of XINT1/IOPA2 and TDIRA/IOPB6 pins, bits 2 and 14 of MCRA must
be treated as reserved for 2402A devices.
Notes: 1) Due to the absence of the W/R/IOPC0, BIO/IOPC1, and SPISTE/IOPC5 pins, bits 0,
1, and 5 of MCRB must be treated as reserved in the 2402A.
2) Due to the absence of SPI and CAN modules (in 2402A), bits 2, 3, 4, 6, and 7 of
MCRB should always be written with 0. The corresponding pins work as GPIO pins
only.
3) Due to the absence of the CAN module and W/R function in 2404A, bits 0, 6, and
7 of MCRB should always be written with 0. The corresponding pins work as GPIO
pins only.
4) Due to the absence of the W/R function in 2406A, bit 0 of MCRB should always be
written with 0. The corresponding pin works as a GPIO pin only.
5-6
I/O Mux Control Registers
If AnDIR = 0, then:
0 Corresponding I/O pin is read as a low
1 Corresponding I/O pin is read as a high
If AnDIR = 1, then:
0 Set corresponding I/O pin low
1 Set corresponding I/O pin high
5-8
Data and Direction Control Registers
Table 5−5. PADATDIR I/O Pin Designation (Assuming Pins Have Been Selected as I/O;
i.e., Secondary Function)
If BnDIR = 0, then:
0 Corresponding I/O pin is read as a low
1 Corresponding I/O pin is read as a high
If BnDIR = 1, then:
0 Set corresponding I/O pin low
1 Set corresponding I/O pin high
Table 5−6. PBDATDIR I/O Pin Designation (Assuming Pins Have Been Selected as I/O;
i.e., Secondary Function)
If CnDIR = 0, then:
0 Corresponding I/O pin is read as a low
1 Corresponding I/O pin is read as a high
If CnDIR = 1, then:
0 Set corresponding I/O pin low
1 Set corresponding I/O pin high
5-10
Data and Direction Control Registers
Table 5−7. PCDATDIR I/O Pin Designation (Assuming Pins Have Been Selected as I/O;
i.e., Secondary Function)
15−9 8
Reserved D0DIR
RW-0
7−1 0
Reserved IOPD0
RW-†
† The reset value of this bit depends upon the state of the respective pins.
Note: R = Read access, W = Write access, -0 = value after reset
Bit 8 D0DIR
0 Configure corresponding pin as an input
1 Configure corresponding pin as an output
Bit 0 IOPD0
If D0DIR = 0, then:
0 Corresponding I/O pin is read as a low
1 Corresponding I/O pin is read as a high
If D0DIR = 1, then:
0 Set corresponding I/O pin low
1 Set corresponding I/O pin high
Table 5−8. PDDATDIR I/O Pin Designation (Assuming Pins Have Been Selected as I/O;
i.e., Secondary Function)
If EnDIR = 0, then:
0 Corresponding I/O pin is read as a low
1 Corresponding I/O pin is read as a high
5-12
Data and Direction Control Registers
If EnDIR = 1, then:
0 Set corresponding I/O pin low
1 Set corresponding I/O pin high
Table 5−9. PEDATDIR I/O Pin Designation (Assuming Pins Have Been Selected as I/O;
i.e., Secondary Function)
Bit 15 Reserved
Bit 7 Reserved
If FnDIR = 0, then:
0 Corresponding I/O pin is read as a low
1 Corresponding I/O pin is read as a high
If FnDIR = 1, then:
0 Set corresponding I/O pin low
1 Set corresponding I/O pin high
Table 5−10. PFDATDIR I/O Pin Designation (Assuming Pins Have Been Selected as I/O;
i.e., Secondary Function)
5-14
Chapter 6
This chapter describes the 240xA Event Manager (EV) module. Most of the
EV pins are shared with general-purpose digital I/O signals. This pin sharing
and how it is controlled is described in Chapter 5, Digital Input/Output (I/O).
The EV module provides a broad range of functions and features that are
particularly useful in motion control and motor control applications. There are
differences in terms of the functionality between the EV module of 240xA
devices and the EV module of 240 devices. (However, the EV modules in the
24x and 240xA families of DSPs are exactly identical in terms of functionality.)
Note that all devices of the 240xA family (with the exception of the 2402A) have
two EV modules as opposed to one EV module in the 241/242/243 devices.
Topic Page
6-1
Event Manager (EV) Functional Blocks
Each EV module in the 240xA device contains the following functional blocks:
Figure 6−1 shows a block diagram of the EVA module and Figure 6−2 shows
a block diagram of the EVB module.
6-2
Event Manager (EV) Functional Blocks
TDIRA
16 TCLKINA
GP timer 1
Prescaler
CLKOUT
16
T1CON[4,5] T1CON[8,9,10]
TCLKINA
16 Prescaler
GP timer 2 CLKOUT
T2CON[4,5] T2CON[8,9,10]
16
TDIRA
16
DIR Clock
QEP CAPCONA[14,13]
MUX
circuit
2
2 CAP1/QEP1
2 CAP2/QEP2
16
Capture units
CAP3
16
TDIRB
16 TCLKINB
GP timer 3
Prescaler
CLKOUT
16
T3CON[4,5] T3CON[8,9,10]
Prescaler TCLKINB
16
GP timer 4 CLKOUT
T4CON[4,5] T4CON[8,9,10]
16
TDIRB
16
DIR Clock
QEP CAPCONB[14,13]
MUX
circuit
2
2 CAP4/QEP3
2 CAP5/QEP4
16
Capture units
CAP6
16
6-4
Event Manager (EV) Functional Blocks
The GP Timers do not stay at the period register value, FFFFh or 0000h
when operating in directional-up/down count mode (including QEP mode).
They now reverse direction when one of these end points is reached.
The capture units of a particular EV can now use any timer associated with
that EV as a time base.
The capture interrupt flag gets set when a capture event occurs only if
there are one or more capture events stored in the FIFO already.
The Capture FIFO status bits are now RW. Bits 5−0 of CAPFIFO are now
unnecessary and are reserved.
Both locations in the capture FIFO can be read individually, not just the top
location.
The QEP logic can only clock GP timer 2 for EVA and GP timer 4 for EVB.
The compare mode of the (full) compare units has been removed. They
now only operate in PWM mode.
The dead band counters have been reduced from 8 bits to 4 bits. The dead
band prescaler has been increased from 3 bits to 5 bits, adding two more
prescale values: x/16 and x/32. Software change: There are now three
DBTPSx bits. DBTPS0 moves to bit 2 of DBTCON, DBTPS1 moves to
bit 3, and bit 4 becomes DBTPS2.
Any register bits associated with the removed functions are now reserved
(not implemented).
Most interrupt control logic has been removed from each peripheral. Each
peripheral now simply has one interrupt request signal and associated en-
able for each interrupt flag. The peripheral interrupt vector table (contain-
ing the peripheral interrupt vectors) is now located in the peripheral inter-
rupt expansion (PIE) controller.
Software writing a 1 to the interrupt flag, which has been identified by the
interrupt vector ID, is required to clear the flag. Reading the interrupt vec-
tor ID no longer automatically clears the associated flag.
6.1.2 EV Pins
Each EV module has eight device pins available for compare/PWM outputs:
EVA EVB
T1CMP/T1PWM T3CMP/T3PWM
T2CMP/T2PWM T4CMP/T4PWM
EVA EVB
PWM1 PWM7
PWM2 PWM8
PWM3 PWM9
PWM4 PWM10
PWM5 PWM11
PWM6 PWM12
The EVA module uses three device pins, CAP1/QEP1, CAP2/QEP2, and
CAP3, as capture or quadrature encoder pulse inputs.
The EVB module uses three device pins, CAP4/QEP3, CAP5/QEP4, and
CAP6, as capture or quadrature encoder pulse inputs.
The device pin TDIRA/B is used to specify the counting direction when a GP
timer is in directional up-/down-counting mode.
The device pins are summarized in Table 6−1, Event Manager A Pins, and
Table 6−2, Event Manager B Pins.
6-6
Event Manager (EV) Functional Blocks
The PDPINTx is a safety feature that is provided for the safe operation of
systems such as power converters and motor drives. PDPINTx can be used
to inform the monitoring program of motor drive abnormalities such as over-
voltage, over-current, and excessive temperature rise. If the PDPINTx
interrupt is unmasked, all PWM output pins will be put in the high-impedance
state immediately after the PDPINTx pin is driven low. An interrupt will also be
generated.
The interrupt flag associated with PDPINTx is also set when such an event
occurs; however, it must wait until the transition on PDPINTx has been
qualified and synchronized with the internal clock. The qualification and
synchronization cause a delay of two clock cycles. The setting of the flag does
not depend on whether or not the PDPINTx interrupt is masked: it happens
when a qualified transition occurs on the PDPINTx pin. This interrupt is
enabled following reset. If the PDPINTx interrupt is disabled, the action of
driving the PWM outputs to the high-impedance state (upon a valid PDPINTx
interrupt) is also disabled.
6-8
Event Manager (EV) Functional Blocks
In 240xA devices, the status of the PDPINTx pin is reflected in bit 8 of the
COMCONx register.
The PDPINTx pin must be held low for 6 (or 12) CLKOUT cycles before
it is recognized by the core.
6.1.4 EV Registers
The Event Manager registers occupy two 64-word (16-bit) frames of address
space. The Event Manager module decodes the lower six-bits of the address;
while the upper 10 bits of the address are decoded by the peripheral address
decode logic, which provides a module select to the Event Manager when the
peripheral address bus carries an address within the range designated for the
EV on that device.
On 240xA devices (as with the C240 device), EVA registers are located in the
range 7400h to 7431h. EVB registers are located in the range of 7500h to
7531h.
The undefined registers and undefined bits of the EV registers all return zero
when read by user software. Writes have no effect. See Section 6.2, Event
Manager(EV) Register Addresses, on page 6-11.
6.1.5 EV Interrupts
The Event Manager interrupts are arranged into three groups. Each group is
assigned one CPU interrupt (INT2, 3 or 4). Since each group has multiple
interrupt sources, the CPU interrupt requests are processed by the peripheral
interrupt expansion (PIE) module. The 240xA interrupt requests have the
following stages of response:
PIE request. If both interrupt flag bits and interrupt mask bits are set, then
the peripheral issues a peripheral interrupt request to the PIE module. The
PIE module can receive more than one interrupt from the peripheral. The
PIE logic records all the interrupt requests and generates the respective
CPU interrupt (INT1, 2, 3, or 4) based on the preassigned priority of the
received interrupts. See Table 2−2, 240xA Interrupt Source Priority and
Vectors, on page 2-9 for priority and vector values.
PIE response. The PIE logic uses the acknowledge signal from the core
to clear the PIRQ bit that issued the CPU interrupt. Along with this, the PIE
updates its PIVR register with the interrupt vector, unique to the peripheral
interrupt, that was just acknowledged. After this, the PIE hardware works
in parallel to the current interrupt software to generate a CPU interrupt and
other pending interrupts, if any.
Level 1 (GISR). In the first level the software should do any context
save and read the PIVR register from PIE module to decide which in-
terrupt group caused the interrupt.Since the PIVR value is unique, it
can be used to branch to the interrupt service routine specific to this
interrupt condition.
Level 2 (SISR). This level is optional and could reside as a part of lev-
el 1. However, at this stage the interrupt software has explicit respon-
sibility to avoid improper interrupt response. After executing the inter-
rupt specific code, the routine should clear the interrupt flag in the
EVxIFRA EVxIFRB, or EVxIFRC that caused the serviced interrupt.
Code will return after enabling the CPU’s global interrupt bit INTM
(clear INTM bit).
6-10
Event Manager (EV) Register Addresses
6-12
Event Manager (EV) Register Addresses
Providing a time base for the operation of the quadrature encoder pulse
(QEP) circuit (GP timer 2/4 only) and the capture units
Providing a time base for the operation of the compare units and
associated PWM circuits to generate PWM outputs
Note:
Timer 2 can select the period register of timer 1 as its period register. In
Figure 6−3, the mux is applicable only when the figure represents timer 2.
Timer 4 can select the period register of timer 3 as its period register. In
Figure 6−3, the mux is applicable only when the figure represents timer 4.
6-14
General-Purpose (GP) Timers
TxPR
TyPR period register
period register
(shadowed)
(shadowed)
GPTCONA/B
GP timer
control
MUX TnCON[0] register
TxCMPR
Symm/asym
compare Compare Output
waveform TxPWM
register logic logic
generator
(shadowed)
Interrupt flags
TxCNT GP
timer counter
ADC start of
conversion
Internal Control
CPU logic TCLKINA/B
clock TDIRA/B
TxCON
GPTx control
register
GP Timer Inputs
6-16
General-Purpose (GP) Timers
When a timer is used with the QEP circuit, the QEP circuit generates both the
timer’s clock and the counting direction.
GP Timer Outputs
The outputs of the timers are:
Underflow, overflow, compare match, and period match signals to its own
compare logic and to the compare units
Which of the eight input clock prescale factors (ranging from 1 to 1/128)
is used
Which period register is used by timer 2, its own, or timer 1’s period register
(EVA)
Which period register is used by timer 4, its own, or timer 3’s period register
(EVB)
The compare operation and outputs can be enabled in any of the timer modes,
including QEP mode.
On underflow or period match; that is, when the counter value is 0 or when
the counter value equals the value of the period register
The double buffering feature of the period and compare registers allows the
application code to update the period and compare registers at any time during
6-18
General-Purpose (GP) Timers
a period in order to change the timer period and the width of the PWM pulse
for the period that follows. On-the-fly change of the timer period value, in the
case of PWM generation, means on-the-fly change of PWM carrier frequency.
Note:
The period register of a GP timer should be initialized before its counter is
initialized to a non-zero value. Otherwise, the value of the period register will
remain unchanged until the next underflow.
Note that a compare register is transparent (the newly loaded value goes
directly into the active register) when the associated compare operation is
disabled. This applies to all Event Manager compare registers.
The input pin TDIRA/B determines the direction of counting when a GP timer
is in directional up-/down-counting mode. When TDIRA/B is high, upward
counting is specified; when TDIRA/B is low, downward counting is specified.
Timer Clock
The source of the GP timer clock can be the internal device clock or the
external clock input, TCLKINA/B. The frequency of the external clock must be
less than or equal to one-fourth of that of the device clock. GP timer 2 (EVA)
and GP timer 4 (EVB) can be used with the QEP circuits, in directional
up-/down-counting mode. In this case, the QEP circuits provide both the clock
and direction inputs to the timer.
A wide range of prescale factors are provided for the clock input to each GP
timer.
GP Timer Synchronization
GP timer 2 can be synchronized with GP timer 1 (for EVA) and GP timer 4 can
be synchronized with GP timer 3 (for EVB) by proper configuration of T2CON
and T4CON, respectively, in the following ways:
EVA:
Set the T2SWT1 bit in T2CON to start GP timer 2 counting with the TEN-
ABLE bit in T1CON (thus, both timer counters start simultaneously)
EVA:
Initialize the timer counters in GP timers 1 and 2 with different values be-
fore starting synchronized operation
EVA:
Specify that GP timer 2 uses the period register of GP timer 1 as its period
register (ignoring its own period register) by setting SELT1PR in T2CON
EVB:
Set the T4SWT3 bit in T4CON to start GP timer 4 counting with the TEN-
ABLE bit in T3CON (thus, both timer counters start simultaneously)
EVB:
Initialize the timer counters in GP timers 3 and 4 with different values be-
fore starting synchronized operation
EVB:
Specify that GP timer 4 uses the period register of GP timer 3 as its period
register (ignoring its own period register) by setting SELT3PR in T4CON
6-20
General-Purpose (GP) Timers
This allows the desired synchronization between GP timer events. Since each
GP timer starts the counting operation from its current value in the counter
register, one GP timer can be programmed to start with a known delay after
the other GP timer.
The bits in GPTCONA/B can specify that an ADC start signal be generated on
a GP timer event such as underflow, compare match, or period match. This
feature provides synchronization between the GP timer event and the ADC
start without any CPU intervention.
The GP timer control register bits also define the operation of the GP timers
during emulation suspend. These bits can be set to allow the operation of GP
timers to continue when an emulation interrupt occurs making in-circuit
emulation possible. They can also be set to specify that the operation of GP
timers stops immediately, or after completion of the current counting period,
when emulation interrupt occurs.
Emulation suspend occurs when the device clock is stopped by the emulator,
for example, when the emulator encounters a break point.
GP Timer Interrupts
There are sixteen interrupt flags in the EVAIFRA, EVAIFRB, EVBIFRA, and
EVBIFRB registers for the GP timers. Each of the four GP timers can generate
four interrupts upon the following events:
Overflow: TxOFINT (x = 1, 2, 3, or 4)
Underflow: TxUFINT (x = 1, 2, 3, or 4)
An overflow event occurs when the value of the timer counter reaches FFFFh.
An underflow event occurs when the timer counter reaches 0000h. Similarly,
a period event happens when the value of the timer counter is the same as that
of the period register. The overflow, underflow, and period interrupt flags of the
timer are set one clock cycle after the occurrence of each individual event.
Note that the definition of overflow and underflow is different from their
conventional definitions.
Stop/Hold mode
The bit pattern in the corresponding timer control register TxCON determines
the counting mode of a GP timer. The timer enabling bit, TxCON[6], enables
or disables the counting operation of a timer. When the timer is disabled, the
counting operation of the timer stops and the prescaler of the timer is reset
to x/1. When the timer is enabled, the timer starts counting according to the
counting mode specified by other bits of TxCON.
Stop/Hold Mode
In this mode the GP timer stops and holds at its current state. The timer
counter, the compare output, and the prescale counter all remain unchanged
in this mode.
The period interrupt flag of the timer is set one clock cycle after the match
between the timer counter and period register. A peripheral interrupt request
is generated if the flag is not masked. An ADC start is sent to the ADC module
at the same time the flag is set, if the period interrupt of this timer has been
selected by the appropriate bits in GPTCONA/B to start the ADC.
6-22
General-Purpose (GP) Timers
One clock cycle after the GP timer becomes 0, the underflow interrupt flag of
the timer is set. A peripheral interrupt request is generated by the flag if it is
unmasked. An ADC start is sent to the ADC module at the same time if the
underflow interrupt flag of this timer has been selected by appropriate bits in
GPTCONA/B to start ADC.
The overflow interrupt flag is set one clock cycle after the value in TxCNT
matches FFFFh. A peripheral interrupt request is generated by the flag if it is
unmasked.
The duration of the timer period is (TxPR) + 1 cycles of the scaled clock input
except for the first period. The duration of the first period is the same if the timer
counter is zero when counting starts.
The initial value of the GP timer can be any value between 0h and FFFFh
inclusive. When the initial value is greater than the value in the period register,
the timer counts up to FFFFh, resets to zero, and continues the operation as
if the initial value was zero. When the initial value in the timer counter is the
same as that of the period register, the timer sets the period interrupt flag,
resets to zero, sets the underflow interrupt flag, and then continues the
operation again as if the initial value was zero. If the initial value of the timer
is between zero and the contents of the period register, the timer counts up to
the period value and continue to finish the period as if the initial counter value
was the same as that of the period register.
The counting direction indication bit in GPTCONA/B is one for the timer in this
mode. Either the external or internal device clock can be selected as the input
clock to the timer. TDIRA/B input is ignored by the GP timer in this counting
mode.
The continuous up-counting mode of the GP timer is particularly useful for the
generation of edge-triggered or asynchronous PWM waveforms and sampling
periods in many motor and motion control systems.
3 3
Timer value 2 2 2
1 1 1
0 0 0 0
TxCON[6]
Timer clock
6-24
General-Purpose (GP) Timers
The direction of counting is indicated for the timer in this mode by the
corresponding direction indication bit in GPTCONA/B: 1 means counting up;
0 means counting down. Either the external clock from the TCLKINA/B pin or
the internal device clock can be used as the input clock for the timer in this
mode.
TDIRA/B
TxCON[6]
Timer
CLK
The directional up-/down-counting mode of GP timer 2/4 can be used with the
quadrature encoder pulse (QEP) circuits in the EV module. The QEP circuits
provide both the counting clock and direction for GP timer 2/4 in this case. This
mode of operation can also be used to time the occurrence of external events
in motion/motor control and power electronics applications.
The period of the timer in this mode is 2*(TxPR) cycles of the scaled clock
input, except for the first period. The duration of the first counting period is the
same if the timer counter is zero when counting starts.
The initial value of the GP timer counter can be any value between 0h and
FFFFh inclusive. When the initial value is greater than that of the period
register, the timer counts up to FFFFh, resets to zero, and continues the
operation as if the initial value was zero. When the initial value in the timer
counter is the same as that of the period register, the timer counts down to zero
and continues again as if the initial value was zero. If the initial value of the
timer is between zero and the contents of the period register, the timer counts
up to the period value and continues to finish the period as if the initial counter
value was the same as that of the period register.
The period, underflow, and overflow interrupt flags, interrupts, and associated
actions are generated on respective events in the same manner as they are
generated in continuous up-counting mode.
The counting direction indication bit for this timer in GPTCONA/B is one when
the timer counts upward and zero when the timer counts downward. Either the
external clock from the TCLKINA/B pin or the internal device clock can be
selected as the input clock. TDIRA/B input is ignored by the timer in this mode.
2 2 2 2
Timer value 1 1 1 1 1 1
0 0 0 0
TxCON[6]
Timer clock
6-26
General-Purpose (GP) Timers
The compare interrupt flag of the timer is set one clock cycle after the
match
A transition occurs on the associated PWM output according to the bit con-
figuration in GPTCONA/B, one device clock cycle after the match
PWM Transition
The transition on the PWM output is controlled by an asymmetric and
symmetric waveform generator and the associated output logic, and depends
on the following:
resets to zero at the end of a period on period match, if the new compare
value for the following period is not zero
The output is one for the whole period, if the compare value is zero at the
beginning of a period. The output does not reset to zero if the new compare
value for the following period is zero. This is important because it allows the
generation of PWM pulses of 0% to 100% duty cycle without glitches. The
output is zero for the whole period if the compare value is greater than the
value in the period register. The output is one for one cycle of the scaled clock
input if the compare value is the same as that of the period register.
Compare
match
Timer value
New comp
value greater
than period
TxPWM/TxCMP Active
active low
Inactive
TxPWM/TxCMP
active high Active
Compare matches
6-28
General-Purpose (GP) Timers
The output is set to one at the beginning of a period and remains one until the
second compare match if the compare value is zero at the beginning of a
period. After the first transition, the output remains one until the end of the
period if the compare value is zero for the second half of the period. When this
happens, the output does not reset to zero if the new compare value for the
following period is still zero. This is done again to assure the generation of
PWM pulses of 0% to 100% duty cycle without any glitches. The first transition
does not happen if the compare value is greater than or equal to that of the
period register for the first half of the period. However, the output still toggles
when a compare match happens in the second half of the period. This error
in output transition, often as a result of calculation error in the application
routine, is corrected at the end of the period because the output resets to zero,
unless the new compare value for the following period is zero. In this case, the
output remains one, which again puts the output of the waveform generator
in the correct state.
Note:
The output logic determines what the active state is for all output pins.
TxPWM/TxCMP
active high
Compare matches
Output Logic
The output logic further conditions the output of the waveform generator to
form the ultimate PWM output that controls different kinds of power devices.
The PWM output can be specified active high, active low, forced low, and
forced high by proper configuration of the appropriate GPTCONA/B bits.
The polarity of the PWM output is the same as that of the output of the
associated asymmetric/symmetric waveform generator when the PWM output
is specified active high.
The polarity of the PWM output is the opposite of that of the output of the
associated asymmetric/symmetric waveform generator when the PWM output
is specified active low.
The PWM output is set to one (or zero) immediately after the corresponding
bits in GPTCONA/B are set, and the bit pattern specifies that the state of PWM
output is forced high (or low).
Setting active means setting high for active high and setting low for active low.
Setting inactive means the opposite.
6-30
General-Purpose (GP) Timers
All GP timer PWM outputs are put in the high-impedance state when any of
the following events occurs:
For the continuous up-counting mode, the value in the compare register
represents the elapsed time between the beginning of a period and the
occurrence of the first compare match (length of the inactive phase). This
elapsed time is equal to the period of the scaled input clock multiplied by the
value of TxCMPR. Therefore, the length of the active phase (the output pulse
width) is given by (TxPR) − (TxCMPR) + 1 cycle of the scaled input clock.
For the continuous up-/down-counting mode, the compare register can have
a different value while counting down from the value while counting up. The
length of the active phase (output pulse width) for up-/down-counting modes
is given by (TxPR) − (TxCMPR)up + (TxPR) − (TxCMPR)dn cycles of the scaled
input clock, where (TxCMPR)up is the compare value on the way up and
(TxCMPR)dn is the compare value on the way down.
When the value in TxCMPR is zero, the GP timer compare output is active for
the whole period if the timer is in the up-counting mode. For the
up-/down-counting mode, the compare output is active at the beginning of the
period if (TxCMPR)up is zero. The output remains active until the end of the
period if (TxCMPR)dn is also zero.
The length of the active phase (the output pulse width) is zero when the value
of TxCMPR is greater than that of TxPR for up-counting modes. For the
up-/down-counting mode, the first transition is lost when (TxCMPR)up is
greater than or equal to (TxPR). Similarly, the second transition is lost when
(TxCMPR)dn is greater than or equal to (TxPR). The GP timer compare output
is inactive for the entire period if both (TxCMPR)up and TxCMPR)dn are greater
than or equal to (TxPR) for the up-/down-counting mode.
Note:
Each Timer Control Register (TxCON) is independently configurable.
6-32
General-Purpose (GP) Timers
T2SWT1/ SELT1PR/
TENABLE TCLKS1 TCLKS0 TCLD1 TCLD0 TECMPR
T4SWT3† SELT3PR†
Bit 7 T2SWT1. In the case of EVA, this bit is T2SWT1. (GP timer 2 start with GP tim-
er 1.) Start GP timer 2 with GP timer 1’s timer enable bit. This bit is reserved in
T1CON.
T4SWT3. In the case of EVB, this bit is T4SWT3. (GP timer 4 start with GP
timer 3.) Start GP timer 4 with GP timer 3’s timer enable bit. This bit is reserved
in T3CON.
0 Use own TENABLE bit
1 Use TENABLE bit of T1CON (in case of EVA) or T3CON (in case
of EVB) to enable and disable operation ignoring own TENABLE
bit
Bit 6 TENABLE. Timer enable.
0 Disable timer operation (the timer is put in hold and the prescaler
counter is reset)
1 Enable timer operations
Bits 5−4 TCLKS1, TCLKS0. Clock Source Select.
5 4 Source
0 0 Internal
0 1 External
1 0 Reserved
1 1 QEP Circuit† (in case of Timer 2/Timer 4)
Reserved (in case of Timer 1/Timer 3)
† This option is valid only if SELT1PR = 0
6-34
General-Purpose (GP) Timers
Bit 6 TCOMPOE. Compare output enable. If PDPINTx is active this bit is set to zero.
0 Disable all GP timer compare outputs (all compare outputs are put
in the high-impedance state)
1 Enable all GP timer compare outputs
6-36
General-Purpose (GP) Timers
Bit 6 TCOMPOE. Compare output enable. If PDPINTx is active this bit is set to zero.
0 Disable all GP timer compare outputs (all compare outputs are put
in the high-impedance state)
1 Enable all GP timer compare outputs
PWM Operation
To generate a PWM output with a GP timer, a continuous up- or
up-/down-counting mode can be selected. Edge-triggered or asymmetric
PWM waveforms are generated when a continuous-up count mode is
selected. Centered or symmetric PWM waveforms are generated when a
continuous-up/-down mode is selected. To set up the GP timer for the PWM
operation, do the following:
Set up TxCON to specify the counting mode and clock source, and start
the operation
The period value is obtained by dividing the desired PWM period by the period
of the GP timer input clock, and subtracting one from the resulting number
when the continuous up-counting mode is selected to generate asymmetric
PWM waveforms. When the continuous up-/down-counting mode is selected
to generate symmetric PWM waveforms, this value is obtained by dividing the
desired PWM period by two times the period of the GP timer input clock.
The GP timer can be initialized the same way as in the previous example.
During run time, the GP timer compare register is constantly updated with
newly determined compare values corresponding to the newly determined
duty cycles.
All GP timer register bits, except for the counting direction indication bits
in GPTCONA/B, are reset to 0; thus, the operation of all GP timers is dis-
abled. The counting direction indication bits are all set to 1
All timer interrupt mask bits are reset to 0, except for PDPINTx; thus, all
GP timer interrupts are masked except for PDPINTx
6-38
Compare Units
Three 16-bit compare registers (CMPR1, CMPR2, and CMPR3 for EVA;
and CMPR4, CMPR5, and CMPR6 for EVB), all with an associated shad-
ow register, (RW)
One 16-bit compare control register (COMCONA for EVA, and COM-
CONB for EVB), (RW)
One 16-bit action control register (ACTRA for EVA, and ACTRB for EVB),
with an associated shadow register, (RW)
TzCNT
GPTz
counter
ACTR
Compare full compare
logic action control register
(shadowed)
CMPRx
full compare Output
register (shad- PWM circuits logic
owed) PWMy,y+1
The time base for the compare units and the associated PWM circuits is
provided by GP timer 1 (for EVA) or GP timer 3 (for EVB), which can be in any
of its counting modes when the compare operation is enabled. Transitions
occur on the compare outputs.
Compare Inputs/Outputs
The inputs to a compare unit include:
GP timer 1/3 (T1CNT/T3CNT) and its underflow and period match signals
RESET
The condition on which the compare registers are updated with the values
in their shadow registers
Operation
The following paragraph describes the operation of the EVA compare unit. The
operation of the EVB compare unit is identical. For EVB, GP timer 3 and
ACTRB are used.
The value of the GP timer 1 counter is continuously compared with that of the
compare register. When a match is made, a transition appears on the two
outputs of the compare unit according to the bits in the action control register
(ACTRA). The bits in ACTRA can individually specify each output to be toggled
active high or toggled active-low (if not forced high or low) on a compare match.
The compare interrupt flag associated with a compare unit is set when a
compare match is made between GP timer 1 and the compare register of this
6-40
Compare Units
PDPINTA
CENABLE CLD1 CLD0 SVENABLE ACTRLD1 ACTRLD0 FCOMPOE
STATUS
Reserved
R-0
Note: R = Read access, W = Write access, -0 = value after reset
6-42
Compare Units
Bit 9 FCOMPOE. Compare output enable. Active PDPINTA clears this bit to zero.
0 PWM output pins are in high-impedance state; that is, they are
disabled
1 PWM output pins are not in high-impedance state; that is, they are
enabled
Bit 8 PDPINTA STATUS. This bit reflects the current status of the PDPINTA pin. An
application could poll this bit to determine whether the fault that activated this
pin has disappeared. (This bit is applicable to 240xA devices only — it is re-
served on 240x devices and returns a zero when read.)
15 14 13 12 11 10 9 8
PDPINTB
CENABLE CLD1 CLD0 SVENABLE ACTRLD1 ACTRLD0 FCOMPOE
STATUS
Reserved
R-0
Note: R = Read access, W = Write access, -0 = value after reset
Bit 9 FCOMPOE. Compare output enable. Active PDPINTB clears this bit to zero.
0 PWM output pins are in high-impedance state; that is, they are dis-
abled
1 PWM output pins are not in high-impedance state; that is, they are
enabled
Bit 8 PDPINTB STATUS. This bit reflects the current status of the PDPINTB pin. An
application could poll this bit to determine whether the fault that activated this
pin has disappeared. (This bit is applicable to 240xA devices only — it is re-
served on 240x devices and returns a zero when read.)
The compare action control registers (ACTRA and ACTRB) control the action
that takes place on each of the six compare output pins (PWMx, where x = 1−6
for ACTRA, and x = 7−12 for ACTRB) on a compare event, if the compare
operation is enabled by COMCONx[15]. ACTRA and ACTRB are double-
buffered. The condition on which ACTRA and ACTRB is reloaded is defined
by bits in COMCONx. ACTRA and ACTRB also contain the SVRDIR, D2, D1,
and D0 bits needed for space vector PWM operation. The bit configuration of
ACTRA is described in Figure 6−18 and that of ACTRB is described in
Figure 6−19.
6-44
Compare Units
Bit 15 SVRDIR. Space vector PWM rotation direction. Used only in space vector
PWM output generation.
0 Positive (CCW)
1 Negative (CW)
Bits 14−12 D2−D0. Basic space vector bits. Used only in space vector PWM output gener-
ation.
Bit 15 SVRDIR. Space vector PWM rotation direction. Used only in space vector
PWM output generation.
0 Positive (CCW)
1 Negative (CW)
Bits 14−12 D2−D0. Basic space vector bits. Used only in space vector PWM output
generation.
Bits 11−10 CMP12ACT1−0. Action on compare output pin 12, CMP12.
00 Forced low
01 Active low
10 Active high
11 Forced high
Bits 9−8 CMP11ACT1−0. Action on compare output pin 11, CMP11.
00 Forced low
01 Active low
10 Active high
11 Forced high
Bits 7−6 CMP10ACT1−0. Action on compare output pin 10, CMP10.
00 Forced low
01 Active low
10 Active high
11 Forced high
6-46
Compare Units
Output Logic
The EVB PWM circuits functional block diagram is identical to that of the EVA’s
with the corresponding change of configuration registers.
Sym/asym
waveform COMCONA[9]
generator
SVPWM
state ACTRA
DBTCONA
machine full compare
dead-band
COMCONA[12] timer control action control
register register
ACTRA[12−15]
6-48
PWM Circuits Associated With Compare Units
The PWM circuits are designed to minimize CPU overhead and user
intervention when generating pulse width modulated waveforms used in motor
control and motion control applications. PWM generation with compare units
and associated PWM circuits are controlled by the following control registers:
T1CON, COMCONA, ACTRA, and DBTCONA (in case of EVA); and T3CON,
COMCONB, ACTRB, and DBTCONB (in case of EVB).
Programmable dead-band for the PWM output pairs associated with the
compare units
Control logic
6-50
PWM Circuits Associated With Compare Units
Bit 5 EDBT1. Dead-band timer 1 enable (for pins PWM1 and PWM2 of Compare
Unit 1).
0 Disable
1 Enable
Bits 4−2 DBTPS2 to DBTPS0. Dead-band timer prescaler.
000 x/1
001 x/2
010 x/4
011 x/8
100 x/16
101 x/32
110 x/32
111 x/32
x = Device (CPU) clock frequency
Bits 1−0 Reserved. Reads return zero; writes have no effect.
Bit 5 EDBT1. Dead-band timer 1 enable (for pins PWM7 and PWM8 of Compare
Unit 4).
0 Disable
1 Enable
The inputs to the dead-band unit are PH1, PH2, and PH3 from the
asymmetric/symmetric waveform generators of compare units 1, 2, and 3,
respectively.
The outputs of the dead-band unit are DTPH1, DTPH1_, DTPH2, DTPH2_,
DTPH3, and DTPH3_, corresponding to PH1, PH2, and PH3, respectively.
For each input signal PHx, two output signals, DTPHx and DTPHx_, are
generated. When dead-band is not enabled for the compare unit and its
associated outputs, the two signals are exactly the same. When the
dead-band unit is enabled for the compare unit, the transition edges of the two
signals are separated by a time interval called dead-band. This time interval
is determined by the DBTCONx bits. If you assume that the value in
DBTCONx[11−8] is m, and that the value in DBTCONx[4−2] corresponds to
prescaler x/p, then the dead-band value is (p*m) device clock cycles.
Table 6−13, on page 6-53, shows the dead-band generated by typical bit
combinations in DBTCONx. The values are based on a 25 ns device clock.
Figure 6−23, on page 6-54, shows the block diagram of the dead-band logic
for one compare unit.
6-52
PWM Circuits Associated With Compare Units
DBTPS2−DBTPS0 (p)
(DBTCONx[4−2])
DBT3−DBT0 (m) 110 and
(DBTCONx[11−8]) 1x1 (P=32) 100 (P=16) 011 (P=8) 010 (P=4) 001 (P=2) 000 (P=1)
0 0 0 0 0 0 0
A 8 4 2 1 0.5 0.25
DBTCONx
dead-band
Prescale
control
register
CLK
PHx
from waveform Edge
EN Counter
generators/SV detect
state machine
Compare
logic
DBTCONx
dead-band
control
register
DTPHx
DTPHx_
PHx
DTPHx
Dead band
DTPHx_
Note: Signals such as PHx, DTPHx, and DTPHx are internal to the device, and as such, external monitoring/control of these
signals is not possible.
6-54
PWM Circuits Associated With Compare Units
The output logic circuit determines the polarity and/or the action that must be
taken on a compare match for outputs PWMx, for x = 1−12. The outputs
associated with each compare unit can be specified active low, active high,
forced low, or forced high. The polarity and/or the action of the PWM outputs
can be programmed by proper configuration of bits in the ACTR register. The
PWM output pins can all be put in the high-impedance state by any of the
following:
Active PDPINTx (when enabled) and system reset override the bits in
COMCONx and ACTRx
Figure 6−24, on page 6-56, shows a block diagram of the output logic circuit
(OLC). The inputs of Output Logic for the compare units are:
The outputs of the Output Logic for the compare units are:
10
DTPHx
or MUX
DTPHx_
01 PWMy
“1” 11
“0” 00
COMCON[9]
6-56
PWM Waveform Generation With Compare Units and PWM Circuits
6.6 PWM Waveform Generation With Compare Units and PWM Circuits
A pulse width modulated (PWM) signal is a sequence of pulses with changing
pulse widths. The pulses are spread over a number of fixed-length periods so
that there is one pulse in each period. The fixed period is called the PWM
(carrier) period and its inverse is called the PWM (carrier) frequency. The
widths of the PWM pulses are determined, or modulated, from pulse to pulse
according to another sequence of desired values, the modulating signal.
In a motor control system, PWM signals are used to control the on and off time
of switching power devices that deliver the desired current and energy to the
motor windings (see Figure 6−27 on page 6-62). The shape and frequency of
the phase currents and the amount of energy delivered to the motor windings
control the required speed and torque of the motor. In this case, the command
voltage or current to be applied to the motor is the modulating signal. The
frequency of the modulating signal is typically much lower than the PWM
carrier frequency.
Dead Band
In many motion/motor and power electronics applications, two power devices,
an upper and a lower, are placed in series on one power converter leg. The
turn-on periods of the two devices must not overlap with each other in order
to avoid a shoot-through fault. Thus, a pair of non-overlapping PWM outputs
is often required to properly turn on and off the two devices. A dead time
(dead-band) is often inserted between the turning-off of one transistor and the
turning-on of the other transistor. This delay allows complete turning-off of one
transistor before the turning-on of the other transistor. The required time delay
is specified by the turning-on and turning-off characteristics of the power
transistors and the load characteristics in a specific application.
Each of the three compare units, together with GP timer 1 (in the case of EVA)
or GP timer 3 (in the case of EVB), the dead-band unit, and the output logic
in the event manager module, can be used to generate a pair of PWM outputs
with programmable dead-band and output polarity on two dedicated device
pins. There are six such dedicated PWM output pins associated with the three
compare units in each EV module. These six dedicated output pins can be
used to conveniently control 3-phase AC induction or brushless DC motors.
The flexibility of output behavior control by the compare action control register
(ACTRx) also makes it easy to control switched reluctance and synchronous
reluctance motors in a wide range of applications. The PWM circuits can also
be used to conveniently control other types of motors such as DC brush and
stepper motors in single or multi-axis control applications. Each GP timer
compare unit, if desired, can also generate a PWM output based on its own
timer.
All three kinds of PWM waveform generations with compare units and
associated circuits require configuration of the same Event Manager registers.
The setup process for PWM generation includes the following steps:
Initialize CMPRx
Setup and load T1CON (for EVA) or T3CON (for EVB) to start the opera-
tion
6-58
PWM Waveform Generation With Compare Units and PWM Circuits
Figure 6−25. Asymmetric PWM Waveform Generation With Compare Unit and PWM Circuits
(x = 1, 3, or 5)
Timer Timer
(PWM) (PWM)
period 1 period 1 Compare value
greater than
period
Timer value
PWMx
(active high)
Dead band
PWMx+1
(active low)
Compare matches
After GP timer 1 (or GP timer 3) is started, the compare registers are rewritten
every PWM period with newly determined compare values to adjust the width
(the duty cycle) of PWM outputs that control the switch-on and -off duration of
the power devices. Since the compare registers are shadowed, a new value
can be written to them at any time during a period. For the same reason, new
values can be written to the action and period registers at any time during a
period to change the PWM period or to force changes in the PWM output
definition.
Figure 6−26. Symmetric PWM Waveform Generation With Compare Units and PWM
Circuits (x = 1, 3, or 5)
Timer (PWM)
period 1
Timer value
PWMx (activelow)
Dead time
PWMx+1 (active high)
Compare matches
6-60
PWM Waveform Generation With Compare Units and PWM Circuits
There are usually two compare matches in a PWM period in symmetric PWM
waveform generation, one during the upward counting before period match,
and another during downward counting after period match. A new compare
value becomes effective after the period match (reload on period) because
itmakes it possible to advance or delay the second edge of a PWM pulse. An
application of this feature is when a PWM waveform modification
compensates for current errors caused by the dead-band in AC motor control.
Because the compare registers are shadowed, a new value can be written to
them at any time during a period. For the same reason, new values can be
written to the action and period registers at any time during a period to change
the PWM period or to force changes in the PWM output definition.
The compare registers in 240xA Event Managers are all buffered and support
three compare value reload/update (value in buffer becoming active) modes.
These modes have earlier been documented as compare value reload
conditions. The reload condition that supports double update PWM mode is
reloaded on underflow (beginning of PWM period) OR period (middle of PWM
period). Double update PWM mode can be achieved by using this condition
for compare value reload.
Va Vb Vc
GND
6-62
Space Vector PWM
1 1 1 0 0 0 0 0 0
Note: 0 = off, 1 = on
Mapping the phase voltages corresponding to the eight combinations onto the
d-q plane by performing a d-q transformation (which is equivalent to an
orthogonal projection of the 3-vectors (a b c) onto the two dimensional plane
perpendicular to the vector (1,1,1), the d-q plane), results in six nonzero
vectors and two zero vectors. The nonzero vectors form the axes of a
hexagonal. The angle between two adjacent vectors is 60 degrees. The two
zero vectors are at the origin. These eight vectors are called the basic space
vectors and are denoted by U0, U60, U120, U180, U240, U300, O000, and O111.
The same transformation can be applied to the demanded voltage vector Uout
to be applied to a motor. Figure 6−28 shows the projected vectors and the
projected desired motor voltage vector Uout.
The d axis and q axis of a d-q plane correspond here to the horizontal and
vertical geometrical axes of the stator of an AC machine.
The objective of the space vector PWM method is to approximate the motor
voltage vector Uout by a combination of these eight switching patterns of the
six power transistors.
T2 Uout
The binary representations of two adjacent basic vectors are different in only
one bit; that is, only one of the upper transistors switches when the switching
pattern switches from Ux to Ux+60 or from Ux+60 to Ux. Also, the zero vectors
O000 and O111 apply no voltage to the motor.
6-64
Space Vector PWM
Software
To generate space vector PWM outputs, the user software must:
Configure ACTRx to define the polarity of the compare output pins
The space vector PWM waveforms generated are symmetric with respect to
the middle of each PWM period; and for this reason, it is called the symmetric
space vector PWM generation method. Figure 6−29 shows examples of the
symmetric space vector PWM waveforms.
Only two compare registers are used in space vector PWM output generation.
The third compare register, however, is still constantly compared with GP
timer 1. When a compare match happens, the corresponding compare
interrupt flag remains set and a peripheral interrupt request is generated, if the
flag is unmasked. Therefore, the compare register that is not used in space
vector PWM output generation can still be used to time events happening in
a specific application. Also, because of the extra delay introduced by the state
machine, the compare output transitions are delayed by one clock cycle in
space vector PWM mode.
6-66
Space Vector PWM
Full compare
match 2
Timer value
Full compare
match 1
DTPH1
DTPH2
DTPH3
U0 U60 U60 U0
(001) (011) (111) (111) (011) (001)
Full compare
match 2
Timer value
Full compare
match 1
DTPH1
DTPH2
DTPH3
Each EVA capture unit can choose GP timer 2 or 1 as its time base; however,
CAP1 and CAP2 cannot choose a different timer between themselves as their
timebase. Each EVB capture unit can choose GP timer 4 or 3 as its time base;
however, CAP4 and CAP5 cannot choose a different timer between
themselves as their timebase.
6-68
Capture Units
T2CNT T1CNT
GP timer 2 GP timer 1
counter counter
2 CAPCONA[12−14]
CAPCONA[9,10] MUX
16
EN 3
CAP1,2,3
Edge
detect Capture unit 3
16 RS cap. event
Edge CAPCONA[8]
2-level 6 select
FIFO RS
stacks CAPCONA[2−7]
ADC start
8 CAPCONA[15]
Cap FIFO
status
clear
CAPFIFOA[13−15]
T4CNT T3CNT
GP timer 4 GP timer 3
counter counter
2 CAPCONB[12−14]
CAPCONB[9,10] MUX
16
EN 3
CAP4,5,6
Edge
detect Capture unit 6
16 RS cap. event
Edge CAPCONB[8]
2-level 6 select
FIFO RS
stacks CAPCONB[2−7]
ADC start
8 CAPCONB[15]
Cap FIFO
status
clear
CAPFIFOB[13−15]
One 16-bit capture control register (CAPCONA for EVA, CAPCONB for
EVB), (RW)
One 16-bit capture FIFO status register (CAPFIFOA for EVA, CAPFIFOB
for EVB)
6-70
Capture Units
Three 16-bit 2-level-deep FIFO stacks, one for each capture unit
Six Schmitt-triggered capture input pins, CAP1 through CAP6, one input
pin for each capture unit. (All inputs are synchronized with the device/CPU
clock: in order for a transition to be captured, the input must hold at its
current level to meet the two rising edges of the device clock. In 240xA
devices, the input must be held for a duration mandated by the input
qualifier circuitry. Input pins CAP1 and CAP2 (CAP4 and CAP5 in EVB)
can also be used as QEP inputs to QEP circuit).
For EVA, Capture Unit 3 has a separate time base selection bit from Capture
Units 1 and 2. This allows the two GP timers to be used at the same time, one
for Capture Units 1 and 2, and the other for Capture Unit 3. For EVB, Capture
Unit 6 has a separate time base selection bit.
Capture operation does not affect the operation of any GP timer or the
compare/PWM operations associated with any GP timer.
6-72
Capture Units
6-74
Capture Units
CAPFIFOA contains the status bits for each of the three FIFO stacks of the
capture units. The bit description of CAPFIFOA is given in Figure 6−34. If a
write occurs to the CAPnFIFOA status bits at the same time as they are being
updated (because of a capture event), the write data takes precedence.
Reserved
R-0
6-76
Capture Units
CAPFIFOB contains the status bits for each of the three FIFO stacks of the
capture units. The bit description of CAPFIFOB is given in Figure 6−35. If a
write occurs to the CAPnFIFOB status bits at the same time as they are being
updated (because of a capture event), the write data takes precedence.
Reserved
R-0
If desired, the bottom register of the FIFO stack can be read. Reading the
bottom register of the FIFO stack causes the FIFO status bits to change to 01
(has one entry) if they were previously 10 or 11. If the FIFO status bits were
previously 01 when the bottom FIFO register is read, they will change to 00
(empty).
First Capture
The counter value of the selected GP timer (captured by a capture unit when
a specified transition happens on its input pin) is written into the top register
of the FIFO stack, if the stack is empty. At the same time, the corresponding
status bits are set to 01. The status bits are reset to 00 if a read access is made
to the FIFO stack before another capture is made.
Second Capture
If another capture occurs before the previously captured counter value is read,
the newly captured counter value goes to the bottom register. In the meantime,
the corresponding status bits are set to 10. When the FIFO stack is read before
another capture happens, the older counter value in the top register is read
out, the newer counter value in the bottom register is pushed up into the top
register, and the corresponding status bits are set to 01.
6-78
Capture Units
Third Capture
If a capture happens when there are already two counter values captured in
the FIFO stack, the oldest counter value in the top register of the stack is
pushed out and lost, the counter value in the bottom register of the stack is
pushed up into the top register, the newly captured counter value is written into
the bottom register, and the status bits are set to 11 to indicate that one or more
older captured counter values have been lost.
The appropriate capture interrupt flag is also set by the third capture. A
peripheral interrupt request is generated if the interrupt is not masked.
Each Event Manager module has a quadrature encoder pulse (QEP) circuit.
The QEP circuit decodes and counts the quadrature encoded input pulses on
pins CAP1/QEP1 and CAP2/QEP2 (in case of EVA) or CAP4/QEP3 and
CAP5/QEP4 (in case of EVB). The QEP circuit can be used to interface with
an optical encoder to get position and speed information from a rotating
machine.
The two QEP input pins are shared between capture units 1 and 2 (or 3 and 4,
for EVB), and the QEP circuit.
The time base for the QEP circuit is provided by GP timer 2 (GP timer 4, in case
of EVB). The GP timer must be put in directional-up/down count mode with the
QEP circuit as the clock source. Figure 6−36 shows the block diagram of the
QEP circuit for EVA and Figure 6−37 shows the block diagram of the QEP
circuit for EVB.
Figure 6−36. Quadrature Encoder Pulse (QEP) Circuit Block Diagram for EVA
2 T2CON[8,9,10]
T2CON[4,5]
2
CLK
TDIRA QEP
GPT2 dir M
DIR 2
U decoder
X
logic
Capture 2 CAP1/QEP1
unit 1,2 CAP2/QEP2
CAPCONA[13,14]
6-80
Quadrature Encoder Pulse (QEP) Circuit
Figure 6−37. Quadrature Encoder Pulse (QEP) Circuit Block Diagram for EVB
GPT4 clock M CLKIN
GP timer 4 U Prescaler CLKOUT
X
2 T4CON[8,9,10]
T4CON[4,5]
2
CLK
TDIRB QEP
GPT4 dir M
DIR 2
U decoder
X
logic
Capture 2 CAP4/QEP3
unit 4,5 CAP5/QEP4
CAPCONB[13,14]
6.9.3 Decoding
Quadrature encoded pulses are two sequences of pulses with a variable
frequency and a fixed phase shift of a quarter of a period (90 degrees). When
generated by an optical encoder on a motor shaft, the direction of rotation of
the motor can be determined by detecting which of the two sequences is the
leading sequence. The angular position and speed can be determined by the
pulse count and pulse frequency.
QEP Circuit
The direction detection logic of the QEP circuit in the EV module determines
which one of the sequences is the leading sequence. It then generates a
direction signal as the direction input to GP timer 2 (or 4). The timer counts up
if CAP1/QEP1 (CAP4/QEP3 for EVB) input is the leading sequence, and
counts down if CAP2/QEP2 (CAP5/QEP4 for EVB) is the leading sequence.
Both edges of the pulses of the two quadrature encoded inputs are counted
by the QEP circuit. Therefore, the frequency of the clock generated by the QEP
logic to GP timer 2 (or 4) is four times that of each input sequence. This
quadrature clock is connected to the clock input of GP timer 2 (or 4).
Figure 6−38 shows an example of quadrature encoded pulses and the derived
clock and counting direction.
Figure 6−38. Quadrature Encoded Pulses and Decoded Timer Clock and Direction
QEP1
QEP2
Quadrature CLK
DIR
Period, underflow, overflow, and compare interrupt flags for a GP timer with
a QEP circuit clock are generated on respective matches. A peripheral
interrupt request can be generated by an interrupt flag, if the interrupt is
unmasked.
1) Load GP timer 2’s counter, period, and compare registers with desired
values.
6-82
Quadrature Encoder Pulse (QEP) Circuit
1) Load GP timer 4s counter, period, and compare registers with desired val-
ues, if necessary.
Table 6−15. Interrupt Flag Register and Corresponding Interrupt Mask Register
EVAIFRC EVAIMRC
EVBIFRA EVBIMRA
EVBIFRC EVBIMRC
6-84
Event Manager (EV) Interrupts
Priority Vector
Group Interrupt within group (ID) Description/Source INT
PDPINTA 1 (highest) 0020h Power Drive Protection Interrupt A 1
A CMP1INT 2 0021h Compare Unit 1 compare interrupt
CMP2INT 3 0022h Compare Unit 2 compare interrupt
CMP3INT 4 0023h Compare Unit 3 compare interrupt
T1PINT 5 0027h GP timer 1 period interrupt 2
T1CINT 6 0028h GP timer 1 compare interrupt
T1UFINT 7 0029h GP timer 1 underflow interrupt
T1OFINT 8 (lowest) 002Ah GP timer 1 overflow interrupt
B T2PINT 1 (highest) 002Bh GP timer 2 period interrupt
T2CINT 2 002Ch GP timer 2 compare interrupt
3
T2UFINT 3 002Dh GP timer 2 underflow interrupt
T2OFINT 4 002Eh GP timer 2 overflow interrupt
C CAP1INT 1 (highest) 0033h Capture Unit 1 interrupt
CAP2INT 2 0034h Capture Unit 2 interrupt 4
CAP3INT 3 0035h Capture Unit 3 interrupt
Priority Vector
Group Interrupt within group (ID) Description/Source INT
PDPINTB 1 (highest) 0019h Power Drive Protection Interrupt B 1
A CMP4INT 2 0024h Compare Unit 4 compare interrupt
CMP5INT 3 0025h Compare Unit 5 compare interrupt
CMP6INT 4 0026h Compare Unit 6 compare interrupt
T3PINT 5 002Fh GP timer 3 period interrupt 2
T3CINT 6 0030h GP timer 3 compare interrupt
T3UFINT 7 0031h GP timer 3 underflow interrupt
T3OFINT 8 (lowest) 0032h GP timer 3 overflow interrupt
B T4PINT 1 (highest) 0039h GP timer 4 period interrupt
T4CINT 2 003Ah GP timer 4 compare interrupt
3
T4UFINT 3 003Bh GP timer 4 underflow interrupt
T4OFINT 4 003Ch GP timer 4 overflow interrupt
C CAP4INT 1 (highest) 0036h Capture Unit 4 interrupt
CAP5INT 2 0037h Capture Unit 5 interrupt 4
CAP6INT 3 0038h Capture Unit 6 interrupt
Period When the counter register contents match that of the period
register
Interrupt Generation
6-86
Event Manager (EV) Interrupts
Interrupt Vector
The peripheral interrupt vector corresponding to the interrupt flag that has the
highest priority among the flags that are set and enabled is loaded into the
PIVR when an interrupt request is acknowledged (this is all done in the
peripheral interrupt controller, external to the event manager peripheral).
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
15−11 10 9 8
Reserved
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
T1OFINT
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
FLAG
T1UFINT
FLAG
T1CINT
FLAG
ÍÍÍÍ 7 6−4
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
3 2 1 0
ÍÍÍÍ
T1PINT
ÍÍÍÍFLAG
Reserved ÍÍÍÍÍÍÍÍÍ
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
FLAG ÍÍÍÍÍÍÍÍÍÍ
CMP3INT
ÍÍÍÍÍ
CMP2INT
FLAG
CMP1INT
FLAG
PDPINTA
FLAG
Write: 0 No effect
1 Resets flag
6-88
Event Manager (EV) Interrupts
Reserved ÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
T2OFINT
FLAG
ÍÍÍÍÍ
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
T2UFINT
FLAG
T2CINT
FLAG
T2PINT
FLAG
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
15−3 2 1 0
Reserved
R-0
ÍÍÍÍÍÍÍÍÍÍ
CAP3INT
ÍÍÍÍ
CAP2INT
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
FLAG
RW1C-0
FLAG
RW1C-0
CAP1INT
FLAG
RW1C-0
6-90
Event Manager (EV) Interrupts
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
15−11 10 9 8
Reserved
R-0
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
T1OFINT
ENABLE
RW-0
T1UFINT
ENABLE
RW-0
T1CINT
ENABLE
RW-0
ÍÍÍÍ 7 6−4
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
3 2 1 0
ÍÍÍÍ
T1PINT
ÍÍÍÍ
ENABLE
Reserved ÍÍÍÍÍÍÍÍÍ
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
ÍÍÍÍÍÍÍÍÍÍ
CMP3INT
ENABLE ÍÍÍÍÍ CMP2INT
ENABLE
CMP1INT
ENABLE
PDPINTA
ENABLE
Note: R = Read access, W = write access, value following dash (−) = value after reset
Reserved ÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
T2OFINT
ÍÍÍÍ
T2UFINT
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
ENABLE ENABLE
T2CINT
ENABLE
T2PINT
ENABLE
6-92
Event Manager (EV) Interrupts
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
15−3 2 1 0
Reserved
ÍÍÍÍÍÍÍÍÍ
CAP3INT
ÍÍÍÍÍ
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
ENABLE
CAP2INT
ENABLE
CAP1INT
ENABLE
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
15−11 10 9 8
Reserved
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
T3OFINT
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
FLAG
T3UFINT
FLAG
T3CINT
FLAG
ÍÍÍÍÍ 7 6−4
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
3 2 1 0
ÍÍÍÍÍ
T3PINT
ÍÍÍÍÍ
FLAG
Reserved ÍÍÍÍÍÍÍÍÍ
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
FLAG ÍÍÍÍÍÍÍÍÍ
CMP6INT
ÍÍÍÍ
CMP5INT
FLAG
CMP4INT
FLAG
PDPINTB
FLAG
6-94
Event Manager (EV) Interrupts
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
15−4 3 2 1 0
Reserved
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
T4OFINT
ÍÍÍÍ
T4UFINT
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
FLAG FLAG
T4CINT
FLAG
T4PINT
FLAG
6-96
Event Manager (EV) Interrupts
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
15−3 2 1 0
Reserved
ÍÍÍÍÍÍÍÍÍ
CAP6INT
ÍÍÍÍÍ
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
FLAG
CAP5INT
FLAG
CAP4INT
FLAG
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
15−11 10 9 8
Reserved
R-0
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
T3OFINT
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
ENABLE
RW-0
T3UFINT
ENABLE
RW-0
T3CINT
ENABLE
RW-0
ÍÍÍÍÍ 7 6−4
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
3 2 1 0
ÍÍÍÍÍ
T3PINT
ÍÍÍÍÍ
ENABLE
Reserved ÍÍÍÍÍÍÍÍÍ
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
ENABLEÍÍÍÍÍÍÍÍÍ
CMP6INT
ÍÍÍÍ
CMP5INT
ENABLE
CMP4INT
ENABLE
PDPINTB
ENABLE
6-98
Event Manager (EV) Interrupts
Reserved ÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
T4OFINT
ÍÍÍÍÍ
T4UFINT
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
ENABLE ENABLE
T4CINT
ENABLE
T4PINT
ENABLE
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
15−3 2 1 0
Reserved
ÍÍÍÍÍÍÍÍÍÍ
CAP6INT
ÍÍÍÍ
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
ENABLE
CAP5INT
ENABLE
CAP4INT
ENABLE
6-100
Chapter 7
Topic Page
7-1
Features
7.1 Features
10-bit ADC core with built-in Sample and Hold (S/H)
Two independent 8-state sequencers (SEQ1 and SEQ2) that can be oper-
ated individually in dual-sequencer mode or cascaded into one large
16-state sequencer (SEQ) in cascaded mode
EVA and EVB can independently trigger SEQ1 and SEQ2, respectively.
(This is applicable for dual-sequencer mode only.)
Calibration mode
The 240x/240xA ADC is not compatible with the 24x ADC. Therefore,
code written for the 24x ADC cannot be ported to a 240x/240xA device.
7-2
Features
† The calibration feature available in 240x devices has some restrictions in usage. See the following device errata for details:
TMS320LF2402 DSP Controller Silicon Errata (literature number SPRZ157), TMS320LF2406 DSP Controller Silicon Errata (lit-
erature number SPRZ159), and TMS320LF2407 DSP Controller Silicon Errata (literature number SPRZ158). Note that the cal-
ibration and self-test features are not supported on the 240xA devices. Hence, bits 0, 1, 2, and 3 of the ADCTRL1 register must
be treated as “reserved” in 240xA devices and must be written with zeroes. Furthermore, the functionality of bit 14 of ADCTRL2
is restricted to RST_SEQ1 only.
7-4
ADC Overview
ADCIN0 RESULT0
ADCIN1 RESULT1
ADCIN2
10-bit 10 RESULT2
S/H + A/D
converter
10
ADCIN15 MUX Result RESULT15
SOC EOC
select select
MAX CONV1
State
Ch Sel (state 0) pointer
Ch Sel (state 1)
4 Ch Sel (state 2) 4
Ch Sel (state 3)
Autosequencer
Ch Sel (state 15) Note: Possible values are:
state machine
Channel select = 0 to 15
MAXCONV = 0 to 15
Software
EVA Start-of-sequence trigger
EVB
External pin (ADCSOC)
RESULT0
RESULT1
10
Analog MUX
ADCIN0 10
ADCIN1 Result RESULT7
ADCIN2 select
10-bit 10
S/H + A/D MUX
converter Result MUX
MUX
ADCIN15 RESULT8
select SOC EOC
RESULT9
10
4
Sequencer
arbiter
10
Result RESULT15
4 4 select
Start-of-sequence Start-of-sequence
Software trigger trigger
Software
EVA
EVB
External pin (ADCSOC)
Note:
There is only one A/D converter in the DSP. This converter is shared by the
two sequencers in Dual-Sequencer mode.
7-6
ADC Overview
The sequencer operation for both 8-state and 16-state modes is almost
identical; the few differences are highlighted in Table 7−2.
Maximum number of 8 8 16
autoconversions
(i.e., sequence length)
Autostop at end-of- Yes Yes Yes
sequence (EOS)
Arbitration priority High Low Not applicable
ADC conversion result 0 to 7 8 to 15 0 to 15
register locations
The analog input channel selected for each sequenced conversion is defined
by CONVnn bit fields in the ADC input channel select sequencing control
registers (CHSELSEQn). (See section 7.5.5., ADC Input Channel Select
Sequencing Control Registers, on page 7-35.) CONVnn is a 4-bit field that
specifies any one of the 16 channels for conversion. Since a maximum of
16 conversions in a sequence is possible when using the sequencers in
cascaded mode, 16 such 4-bit fields (CONV00 – CONV15) are available and
are spread across four 16-bit registers (CHSELSEQ1 – CHSELSEQ4). The
CONVnn bits can have any value from 0 to 15. The analog channels can be
chosen in any desired order and the same channel may be selected multiple
times.
7-8
ADC Overview
If CONT RUN is set, the conversion sequence starts all over again auto-
matically (i.e., SEQ CNTR n gets reloaded with the original value in MAX
CONV1 and SEQ1 state is set to CONV00). In this case, you must ensure
that the result registers are read before the next conversion sequence be-
gins. The arbitration logic designed into the ADC ensures that the result
registers are not corrupted should a contention arise (ADC module trying
to write into the result registers while you try to read from them at the same
time).
All
conversions
No complete?
(AUTO_SEQ_SR = 0 ?)
Yes
If CONT RUN is not set, the sequencer stays in the last state (CONV06,
in this example) and SEQ CNTR n continues to hold a value of zero.
Since the interrupt flag is set every time SEQ CNTR n reaches zero, you can
(if needed) manually reset the sequencer (using the RST SEQn bit in the
ADCTRL2 register) in the interrupt service routine (ISR), so that SEQ CNTR
n gets reloaded with the original value in MAX CONV1 at the next SOC and
SEQ1 state is set to CONV00. This feature is useful in the Start/Stop operation
of the sequencer. Example 7−1 also applies to SEQ2 and the cascaded
16-state sequencer (SEQ) with differences outlined in Table 7−2.
Note: Triggers 1 and 2 may be an SOC signal from EVA, external pin, or
software. The same trigger source may occur twice to satisfy the dual-trigger
requirement of this example.
7-10
ADC Overview
EV1
PWM
Here MAX CONV1 is set to 2 and the ADC Input Channel Select Sequencing
Control Registers (CHSELSEQn) are set to:
Once reset and initialized, SEQ1 waits for a trigger. With the first trigger, three
conversions with channel-select values of: CONV00 (I1), CONV01 (I2), and
CONV02 (I3) are performed. SEQ1 then waits at current state for another
trigger. Twenty-five microseconds later when the second trigger arrives,
another three conversions occur, with channel-select values of CONV03 (V1),
CONV04 (V2), and CONV05 (V3).
The value of MAX CONV1 is automatically loaded into SEQ CNTR n for both
trigger cases. If a different number of conversions are required at the second
trigger point, you must (at some appropriate time before the second trigger)
change the value of MAX CONV1 through software, otherwise, the current
(originally loaded) value will be reused. This can be done by an ISR that
changes the value of MAX CONV1 at the appropriate time. The interrupt
operation modes are described in section 7.2.5, Interrupt Operation During
Sequenced Conversions, on page 7-13.
At the end of the second autoconversion session, the ADC result registers will
have the following values:
At this point, SEQ1 keeps “waiting” at the current state for another trigger. Now,
the user can reset SEQ1 (by software) to state CONV00 and repeat the same
trigger1,2 sessions.
7-12
ADC Overview
Each sequencer has a set of trigger inputs that can be enabled/disabled. The
valid input triggers for SEQ1, SEQ2, and cascaded SEQ is as follows:
Note that:
When SEQ1/2 are used in cascaded mode, triggers going to SEQ2 are ig-
nored, while SEQ1 triggers are active. Cascaded mode can be viewed as
SEQ1 with 16 states instead of eight.
The sequencer can generate interrupts under two operating modes. These
modes are determined by the Interrupt-Mode-Enable Control bits in
ADCTRL2.
A variation of Example 7−2 can be used to show how interrupt mode 1 and
mode 2 are useful under different operating conditions.
Case 1: Number of samples in the first and second sequences are not equal
2) At ISR “a”, MAX CONVn is changed to 2 (by software) for converting V1,
V2, and V3
4) Steps 2 and 3 are repeated. Note that the interrupt flag is set every time
SEQ CNTR n reaches zero and both interrupts are recognized.
Case 2: Number of samples in the first and second sequences are equal
1) Sequencer is initialized with MAX CONVn = 2 for converting I1, I2, and I3
(or V1, V2, and V3).
3) Step 2 is repeated. Note that the interrupt flag is set every time SEQ CNTR
n reaches zero. This would happen after the ADC has finished converting
I1, I2, and I3 and also after converting V1, V2, and V3. But, only the EOS
generated after the conversion of V1, V2, and V3 triggers the interrupt.
7-14
ADC Overview
Case 3: Number of samples in the first and second sequences are equal
(with dummy read)
3) Step 2 is repeated. Note that the third I-sample (x) is a dummy sample, and
is not really required. However, to minimize ISR overhead and CPU inter-
vention, advantage is taken of the “every other” Interrupt request feature
of Mode 2.
25 µs
EV1 Timer 1
counter
EV1
PWM
Sampling
I1,I2 V1,V2,V3 I1,I2 V1,V2,V3 request
Case 1
SEQ
“a” “b” “c” “d” interrupt
Sampling
request
I1,I2,I3 V1,V2,V3 I1,I2,I3 V1,V2,V3
Case 2
SEQ
“b” “d” interrupt
Sampling
I1,I2,x V1,V2,V3 I1,I2,x V1,V2,V3 request
Case 3
SEQ
“b” “d” interrupt
7-16
ADC Clock Prescaler
••••••
PS will be the same as the CPU clock if the prescaler = 1 (i.e., ACQ PS3−ACQ
PS0 bits are all zero) and if CPS = 0. For any other value of the prescaler, the
magnitude of PS will be magnified (effectively increasing the S/H window time)
as described by the “Acquisition Time Window” column in the bit description
for ACQ PS3−ACQ PS0. If the CPS bit is made 1, the S/H window is doubled.
This doubling of the S/H window is in addition to the “stretching” provided by
the prescaler. Figure 7−7 shows the role played by the various prescaler bits
in the ADC module. Note that PS and ACLK will be equal to CPU clock if
CPS = 0.
A/D
converter
(11 * ACLK)
7-18
Calibration
7.4 Calibration
In the calibration mode, the sequencers are not operational and the ADCINn
pins are not connected to the A/D converter. The signal that gets connected
to the A/D converter input is determined by BRG ENA (Bridge Enable) and
HI/LO (VREFHI/VREFLO selection) bits. These two signals connect either
VREFLO or VREFHI or their midpoint to the A/D converter input and a single
conversion is then done. The calibration mode can calculate the zero,
midpoint, or full-scale offset errors of the ADC. The 2’s complement of the
offset error should then be loaded in the CALIBRATION register. (The 2’s
complement operation is applicable for “negative” errors only.) From that point
on, the ADC hardware automatically adds the offset error to the converted
value.
D9 D8 D7 D6 D5 D4 D3 D2
7 6 5 4 3 2 1 0
D1 D0 0 0 0 0 0 0
15 14 13 12 11 10 9 8
Reserved RESET SOFT FREE ACQ PS3 ACQ PS2 ACQ PS1 ACQ PS0
CPS CONT RUN INT PRI SEQ CASC CAL ENA BRG ENA HI/LO STEST ENA
Note: R = Read access, W = Write access, S = Set only, -0 = value after reset
Bit 15 Reserved
This bit causes a master reset on the entire ADC module. All register bits and
sequencer state machines are reset to the initial state as occurs when the
device reset pin is pulled low (or after a power-on reset).
0 No effect
1 Resets entire ADC module (bit is then set back to 0 by ADC
logic)
7-20
Register Bit Descriptions
Source Source
Pre- Z Z
ACQ ACQ ACQ ACQ scaler Acquisition Time (CPS=0) (CPS=1)
# PS3 PS2 PS1 PS0 (div by) Window (Ω) (Ω)
0 0 0 0 0 1 2 x Tclk 67 385
1 0 0 0 1 2 4 x Tclk 385 1020
2 0 0 1 0 3 6 x Tclk 702 1655
3 0 0 1 1 4 8 x Tclk 1020 2290
4 0 1 0 0 5 10 x Tclk 1337 2925
5 0 1 0 1 6 12 x Tclk 1655 3560
6 0 1 1 0 7 14 x Tclk 1972 4194
7 0 1 1 1 8 16 x Tclk 2290 4829
8 1 0 0 0 9 18 x Tclk 2607 5464
9 1 0 0 1 10 20 x Tclk 2925 6099
A 1 0 1 0 11 22 x Tclk 3242 6734
B 1 0 1 1 12 24 x Tclk 3560 7369
C 1 1 0 0 13 26 x Tclk 3877 8004
D 1 1 0 1 14 28 x Tclk 4194 8639
E 1 1 1 0 15 30 x Tclk 4512 9274
F 1 1 1 1 16 32 x Tclk 4829 9909
Notes: 1) Period of Tclk is dependent on the “Conversion Clock Prescale” bit (Bit 7); i.e.,
CPS = 0: Tclk = 1/CLK (example, for CLK = 30 MHz, Tclk = 33 ns)
CPS = 1: Tclk = 2 × (1/CLK) (example, for CLK = 30 MHz, Tclk = 66 ns)
2) Source impedance Z is a design estimate only.
7-22
Register Bit Descriptions
Source Source
Pre- Z Z
ACQ ACQ ACQ ACQ scaler Acquisition Time (CPS=0) (CPS=1)
# PS3 PS2 PS1 PS0 (div by) Window (Ω) (Ω)
0 0 0 0 0 1 2 x Tclk 53 291
1 0 0 0 1 2 4 x Tclk 291 767
2 0 0 1 0 3 6 x Tclk 529 1244
3 0 0 1 1 4 8 x Tclk 767 1720
4 0 1 0 0 5 10 x Tclk 1005 2196
5 0 1 0 1 6 12 x Tclk 1244 2672
6 0 1 1 0 7 14 x Tclk 1482 3148
7 0 1 1 1 8 16 x Tclk 1720 3625
8 1 0 0 0 9 18 x Tclk 1958 4101
9 1 0 0 1 10 20 x Tclk 2196 4577
A 1 0 1 0 11 22 x Tclk 2434 5053
B 1 0 1 1 12 24 x Tclk 2672 5529
C 1 1 0 0 13 26 x Tclk 2910 6005
D 1 1 0 1 14 28 x Tclk 3148 6482
E 1 1 1 0 15 30 x Tclk 3386 6958
F 1 1 1 1 16 32 x Tclk 3625 7434
Notes: 1) Period of Tclk is dependent on the “Conversion Clock Prescale” bit (Bit 7); i.e.,
CPS = 0: Tclk = 1/CLK (example, for CLK = 40 MHz, Tclk = 25 ns)
CPS = 1: Tclk = 2 × (1/CLK) (example, for CLK = 40 MHz, Tclk = 50 ns)
2) Source impedance Z is a design estimate only.
7-24
Register Bit Descriptions
Together with the HI/LO bit, BRG ENA allows a reference voltage to be
converted in calibration mode. See the description of the HI/LO bit for
reference voltage selections during calibration.
0 Full reference voltage is applied to the ADC input
1 A reference midpoint voltage is applied to the ADC input
When the fail self-test mode is enabled (STEST ENA = 1), HI/LO defines the
test voltage to be connected. In calibration mode, HI/LO defines the reference
source polarity; see Table 7−5. In normal operating mode, HI/LO has no effect.
0 VREFLO is used as precharge value at ADC input
1 VREFHI is used as precharge value at ADC input
7 6 5 4 3 2 1 0
Note: R = Read access, W = Write access, S = Set only, C = Clear, -0 = value after reset
Bit 15 EVB SOC SEQ. EVB SOC enable for cascaded sequencer
(Note: This bit is active only in cascaded mode.)
0 No action
1 Setting this bit allows the cascaded sequencer to be started by an
Event Manager B signal. The Event Manager can be programmed
to start a conversion on various events. See chapter 6, Event Man-
ager (EV), for details.
7-26
Register Bit Descriptions
Bit 13 SOC SEQ1. Start-of-conversion (SOC) trigger for Sequencer 1 (SEQ1). This
bit can be set by the following triggers:
S/W – Software writing a 1 to this bit
Note:
The RST SEQ1 (ADCTRL2.14) and the SOC SEQ1 (ADCTRL2.13) bits
should not be set in the same instruction. This will reset the sequencer, but
will not start the sequence. The correct sequence of operation is to set the
RST SEQ1 bit first, and the SOC SEQ1 bit in the following instruction. This
ensures that the sequencer is reset and a new sequence started. This se-
quence applies to the RST SEQ2 (ADCTRL2.6) and SOC SEQ2
(ADCTRL2.5) bits also.
Example code:
ADC_LOOP1:
LDP #ADCTRL1>>7
SPLK #0100000000000000b,ADCTRL2 ;Reset for SEQ1
SPLK #0010000000000000b,ADCTRL2 ;SOC for SEQ1
NOP ;Wait for Busy
;bit to set.
NOP
NOP
NOP
CHK_EOS1:
BIT ADCTRL2, 3 ; Wait for SEQ1 Busy bit
; to clear
BCND CHK_EOS1, TC ; If TC=1, keep looping.
A better approach would be to check the INT FLAG SEQn bit for
end-of-sequence. This does not require NOPs, as the bit should already be
cleared prior to starting a sequenced conversion. To reiterate, the NOPs are
required only when polling the SEQn BUSY bit; interrupt-driven conversions
do not have this requirement.
7-28
Register Bit Descriptions
Bit 9 INT FLAG SEQ1. ADC interrupt flag bit for SEQ1
This bit indicates whether an interrupt event has occurred or not. This bit must
be cleared by the user writing a 1 to it.
0 No interrupt event
1 An interrupt event has occurred.
Bit 8 EVA SOC SEQ1. Event Manager A SOC mask bit for SEQ1
0 SEQ1 cannot be started by EVA trigger.
1 Allows SEQ1/SEQ to be started by Event Manager A trigger. The
Event Manager can be programmed to start a conversion on vari-
ous events. See chapter 6, Event Manager (EV), for details.
Bit 7 EXT SOC SEQ1. External signal start-of-conversion bit for SEQ1
0 No action
1 Setting this bit enables an ADC autoconversion sequence to be
started by a signal from the ADCSOC device pin.
7-30
Register Bit Descriptions
Bit 1 INT FLAG SEQ2. ADC interrupt flag bit for SEQ2
This bit indicates whether an interrupt event has occurred or not. This bit must
be cleared by the user writing a 1 to it.
0 No interrupt event.
1 An interrupt event has occurred.
Bit 0 EVB SOC SEQ2. Event Manager B SOC mask bit for SEQ2
0 SEQ2 cannot be started by EVB trigger.
1 Allows SEQ2 to be started by Event Manager B trigger. The Event
Manager can be programmed to start a conversion on various
events. See chapter 6, Event Manager (EV), for details.
Reserved
R-x
7 6 5 4 3 2 1 0
Bits 6−0 MAX CONVn. MAX CONVn bit field defines the maximum number of conver-
sions executed in an autoconversion session. The bit fields and their operation
vary according to the sequencer modes (dual/cascaded).
An autoconversion session always starts with the initial state and continues
sequentially until the end state if allowed. The result buffer is filled in a
sequential order. Any number of conversions between 1 and (MAX CONVn
+1) can be programmed for a session.
If a value for MAX CONV1, which is greater than 7, is chosen for the dual-
sequencer mode (i.e., two separate 8-state sequencers), then SEQ CNTR n
will continue counting past seven, causing the sequencer to wrap around to
CONV00 and continue counting.
7-32
Register Bit Descriptions
Table 7−6. Bit Selections for MAX CONV1 for Various Number of Conversions
MAX CONV1.3−0 Number of conversions
0000 1
0001 2
0010 3
0011 4
0100 5
0101 6
0110 7
0111 8
1000 9
1001 10
1010 11
1011 12
1100 13
1101 14
1110 15
1111 16
Bits 11−8 SEQ CNTR 3 − SEQ CNTR 0. Sequencing counter status bits
The SEQ CNTR n 4-bit status field is used by SEQ1, SEQ2, and the cascaded
sequencer.
SEQ CNTR n
Number of conversions remaining
(read only)
0000 1
0001 2
0010 3
0011 4
0100 5
0101 6
0110 7
0111 8
1000 9
1001 10
1010 11
1011 12
1100 13
1101 14
1110 15
1111 16
Bit 7 Reserved
Reflects the state of SEQ2 sequencer at any point of time. If necessary, you
can poll these bits to read interim results before an EOS. SEQ2 is irrelevant
in cascaded mode.
Reflects the state of SEQ1 sequencer at any point of time. If need be, user can
poll these bits to read interim results before an EOS.
Note: The AUTO_SEQ_SR register and the RESULTn registers of the 240xA ADC module are
“Read-only.” Any attempt to write to these registers causes an NMI.
7-34
Register Bit Descriptions
Figure 7−13. ADC Input Channel Select Sequencing Control Registers (CHSELSEQn)
Each of the 4-bit fields, CONVnn, selects one of the sixteen muxed analog
input ADC channels for an autosequenced conversion.
Table 7−8. CONVnn Bit Values and the ADC Input Channels Selected
7-36
Register Bit Descriptions
D9 D8 D7 D6 D5 D4 D3 D2
D1 D0 0 0 0 0 0 0
Each category is listed in Table 7−9 with the number of CLKOUT cycles it takes
to complete.
7-38
ADC Conversion Clock Cycles
Example 7−4. Calculating the Conversion Time for a Multiple Conversion Sequence With
CPS = 0 and ACQ = 0:
1st conversion − 15 CLKOUT cycles
2nd conversion − 13 CLKOUT cycles
3rd conversion − 13 CLKOUT cycles
Last conversion − 14 CLKOUT cycles.
Example 7−5. Calculating the Conversion Time for a Single Conversion Sequence With
CPS = 1 and ACQ = 1:
1st and only conversion − 33 or 34 CLKOUT cycles.
To ensure data integrity, the SCI checks received data for break detection,
parity, overrun, and framing errors. The bit rate (baud) is programmable to over
65,000 different speeds through a 16-bit baud-select register.
Topic Page
8-1
C240 SCI vs. LF/LC240xA SCI
The CLKENA bit in SCICTL1 (7051h) has been removed, since it served no
purpose in 2-pin SCI implementations.
The function of the SCIENA bit in SCICCR (7050h) has changed, and is now
a LOOP BACK ENA test mode bit. The enable function is no longer required
for correct operation of the SCI.
Parity error
Overrun error
Framing error
Break detect error
8-2
C240 SCI vs. LF/LC240xA SCI
Idle-line wake-up
Address-bit wake-up
RXSHF
RXWAKE register
SCIRXST.1
SCIRXD
RXENA
RXERRINTENA
SCICTL1.6 SCICTL1.0 8 SCI RX interrupt
RXRDY RX/BKINTENA
Receiver data SCIRXST.6
RXINT
Note: All SCI registers are eight bits wide. These eight bits are mapped to the lower eight bits of the 16-bit
words.
8-4
C240 SCI vs. LF/LC240xA SCI
8.1.2 Architecture
The major elements used in full-duplex operation are shown in Figure 8−1,
SCI Block Diagram, and include:
A transmitter (TX) and its major registers (upper half of Figure 8−1)
A receiver (RX) and its major registers (lower half of Figure 8−1)
Described In
8-6
C240 SCI vs. LF/LC240xA SCI
The basic unit of data is called a character and is one to eight bits in length.
Each character of data is formatted with a start bit, one or two stop bits, and
optional parity and address bits. A character of data with its formatting
information is called a frame and is shown in Figure 8−2.
Idle-line mode
(Normal nonmultiprocessor communications)
Address bit
To program the data format, use the SCICCR register. The bits used to
program the data format are shown in Table 8−2.
8-8
SCI Multiprocessor Communication
Address Byte
The first byte of a block of information that the talker sends contains an address
byte that is read by all listeners. Only listeners with the correct address can be
interrupted by the data bytes that follow the address byte. The listeners with
an incorrect address remain uninterrupted until the next address byte.
Sleep Bit
All processors on the serial link set their SCI’s SLEEP bit (SCICTL1.2) to 1 so
that they are interrupted only when the address byte is detected. When a
processor reads a block address that corresponds to the CPU’s device
address as set by your application software, your program must clear the
SLEEP bit to enable the SCI to generate an interrupt on receipt of each data
byte.
Although the receiver still operates when the SLEEP bit is 1, it does not set
RXRDY, RXINT, or any of the receiver error status bits to 1 unless the address
byte is detected and the address bit in the received frame is a 1 (applicable to
address-bit mode). The SCI does not alter the SLEEP bit; your software must
alter the SLEEP bit.
The idle-line mode (section 8.3.1 on page 8-10) leaves a quiet space be-
fore the address byte. This mode does not have an extra address/data bit
and is more efficient than the address-bit mode for handling blocks that
contain more than ten bytes of data. The idle-line mode should be used
for typical non-multiprocessor SCI communication.
The address-bit mode (section 8.3.2 on page 8-13) adds an extra bit (that
is, an address bit) into every byte to distinguish addresses from data. This
mode is more efficient in handling many small blocks of data because, un-
like the idle mode, it does not have to wait between blocks of data. Howev-
er, at a high transmit speed, the program is not fast enough to avoid a
10-bit idle in the transmission stream.
The multiprocessor mode is software selectable via the ADDR/IDLE MODE bit
(SCICCR.3). Both modes use the TXWAKE flag bit (SCICTL1.3), RXWAKE
flag bit (SCIRXST.1), and the SLEEP flag bit (SCICTL1.2) to control the SCI
transmitter and receiver features of these modes.
Receipt Sequence
1) At the receipt of an address block, the SCI port wakes up and requests an
interrupt (bit RX/BK INT ENA-SCICTL2.1 must be enabled to request an
interrupt). It reads the first frame of the block, which contains the destina-
tion address.
2) A software routine is entered through the interrupt and checks the incom-
ing address. This address byte is checked against its device address byte
stored in memory.
3) If the check shows that the block is addressed to the device CPU, the CPU
clears the SLEEP bit and reads the rest of the block; if not, the software
routine exits with the SLEEP bit still set and does not receive interrupts un-
til the next block start.
8-10
SCI Multiprocessor Communication
Start
Start
Start
First frame within block Frame within Idle period Idle period
Is address; it follows idle block less than of 10 bits
period of 10 bits or more 10 bits or more
3) The interrupt service routine compares the received address (sent by a re-
mote transmitter) to its own.
4) If the CPU is being addressed, the service routine clears the SLEEP bit
and receives the rest of the data block.
5) If the CPU is not being addressed, the SLEEP bit remains set. This lets
the CPU continue to execute its main program without being interrupted
by the SCI port until the next detection of a block start.
Method 2: The SCI port first sets the TXWAKE bit (SCICTL1.3) to 1 before
writing to the SCITXBUF register. This sends an idle time of exactly 11 bits.
In this method, the serial communications line is not idle any longer than
necessary. (A don’t care byte has to be written to SCITXBUF after setting
TXWAKE, and before sending the address, so as to transmit the idle time.)
1 8
WUT TXSHF
A don’t-care data word must first be written to register SCITXBUF so that the
TXWAKE bit value can be shifted to WUT. After the don’t-care data word is
8-12
SCI Multiprocessor Communication
shifted to the TXSHF register, the SCITXBUF (and TXWAKE if necessary) can
be written to again because TXSHF and WUT are both double-buffered.
Receiver Operation
The receiver operates regardless of the SLEEP bit. However, the receiver
neither sets RXRDY nor the error status bits, nor does it request a receive
interrupt until an address frame is detected.
Sending an Address
The TXWAKE bit value is placed in the address bit. During transmission, when
the SCITXBUF register and TXWAKE are loaded into the TXSHF register and
WUT respectively, TXWAKE is reset to 0 and WUT becomes the value of the
address bit of the current frame. Thus, to send an address:
1) Set the TXWAKE bit to 1 and write the appropriate address value to the
SCITXBUF register.
When this address value is transferred to the TXSHF register and
shifted out, its address bit is sent as a 1. This flags the other proces-
sors on the serial link to read the address.
2) Write to SCITXBUF and TXWAKE after TXSHF and WUT are loaded.
(Can be written to immediately since both TXSHF and WUT are both
double-buffered.
ÉÉÉÉÉ ÉÉÉÉÉÉÉÉÉÉÉÉÉÉÉÉ
ÉÉÉÉÉ ÉÉÉÉÉÉÉÉÉÉÉÉÉÉÉÉ
Data format
(Pins SCIRXD, SCITXD)
One block
Start
Start
Start
Data format expanded Addr 1 Data 0 Addr 1
Idle time is of
no significance
Address bit
8-14
SCI Communication Format
The receiver begins operation on receipt of a valid start bit. A valid start bit is
identified by four consecutive internal SCICLK periods of zero bits as shown
in Figure 8−6. If any bit is not zero, then the processor starts over and begins
looking for another start bit.
For the bits following the start bit, the processor determines the bit value by
making three samples in the middle of the bits. These samples occur on the
fourth, fifth, and sixth SCICLK periods, and bit-value determination is on a
majority (two out of three) basis. Figure 8−6 illustrates the asynchronous
communication format for this with a start bit showing how edges are found and
where a majority vote is taken.
Since the receiver synchronizes itself to frames, the external transmitting and
receiving devices do not have to use a synchronized serial clock. The clock
can be generated locally.
SCIRXD
Start bit LSB of data
8 SCICLK periods per data bit 8 SCICLK periods per data bit
Address-bit wake-up mode (address bit does not appear in idle-line mode)
RXRDY
3 4
2 5
Frame
Notes: 1) Flag bit RXENA (SCICTL1.0) goes high to enable the receiver.
2) Data arrives on the SCIRXD pin, start bit detected.
3) Data is shifted from RXSHF to the receiver buffer register (SCIRXBUF); an interrupt is requested. Flag bit RXRDY
(SCIRXST.6) goes high to signal that a new character has been received.
4) The program reads SCIRXBUF; flag RXRDY is automatically cleared.
5) The next byte of data arrives on the SCIRXD pin; the start bit is detected, then cleared.
6) Bit RXENA is brought low to disable the receiver. Data continues to be assembled in RXSHF but is not transferred
to the receiver buffer register.
8-16
SCI Communication Format
Address-bit wake-up mode (address bit does not appear in idle-line mode)
TXRDY
2 3 4
5
TX EMPTY
Frame Frame
Notes: 1) Bit TXENA (SCICTL1.1) goes high, enabling the transmitter to send data.
2) SCITXBUF is written to; thus, (1) the transmitter is no longer empty, and (2) TXRDY goes low.
3) The SCI transfers data to the shift register (TXSHF). The transmitter is ready for a second character (TXRDY goes
high), and it requests an interrupt (to enable an interrupt, bit TX INT ENA — SCICTL2.0 — must be set).
4) The program writes a second character to SCITXBUF after TXRDY goes high (item 3). (TXRDY goes low again after
the second character is written to SCITXBUF.)
5) Transmission of the first character is complete. Transfer of the second character to shift register TXSHF begins.
6) Bit TXENA goes low to disable the transmitter; the SCI finishes transmitting the current character.
7) Transmission of the second character is complete; transmitter is empty and ready for new character.
The SCI has independent peripheral interrupt vectors for the receiver and
transmitter. Peripheral interrupt requests can be either high priority or low
priority. This is indicated by the priority bits which are output from the peripheral
to the PIE controller. SCI interrupts can be programmed to assert the high- or
low-priority levels by the SCIRX PRIORITY (SCIPRI.5) and SCITX PRIORITY
(SCIPRI.6) control bits. When both RX and TX interrupt requests are made at
the same priority level, the receiver always has higher priority than the
transmitter, reducing the possibility of receiver overrun.
If the RX/BK INT ENA bit (SCICTL2.1) is set, the receiver peripheral inter-
rupt request is asserted when one of the following events occurs:
The SCI receives a complete frame and transfers the data in the
RXSHF register to the SCIRXBUF register. This action sets the
RXRDY flag (SCIRXST.6) and initiates an interrupt.
A break detect condition occurs (the SCIRXD is low for ten bit periods
following a missing stop bit). This action sets the BRKDT flag bit
(SCIRXST.5) and initiates an interrupt.
If the TX INT ENA bit (SCICTL2.0) is set, the transmitter peripheral inter-
rupt request is asserted whenever the data in the SCITXBUF register is
transferred to the TXSHF register, indicating that the CPU can write to
SCITXBUF; this action sets the TXRDY flag bit (SCICTL2.7) and initiates
an interrupt.
Note:
Interrupt generation due to the RXRDY and BRKDT bits is controlled by the
RX/BK INT ENA bit (SCICTL2.1). Interrupt generation due to the RX ERROR
bit is controlled by the RX ERR INT ENA bit (SCICTL1.6).
8-18
SCI Baud Rate Calculations
See the bit descriptions in section 8.7.3, Baud-Select Registers, on page 8-26
for the formula to use when calculating the SCI asynchronous baud.
Table 8−3 shows the baud-select values for common SCI bit rates.
Table 8−3. Asynchronous Baud Register Values for Common SCI Bit Rates
Device Clock Frequency, 40 MHz
RX Receiver
7055h SCIRXST RXRDY BRKDT FE OE PE RXWAKE Reserved
ERROR status
EMU data
7056h SCIRXEMU ERXDT7 ERXDT6 ERXDT5 ERXDT4 ERXDT3 ERXDT2 ERXDT1 ERXDT0
buffer
Receiver
7057h SCIRXBUF RXDT7 RXDT6 RXDT5 RXDT4 RXDT3 RXDT2 RXDT1 RXDT0
data buffer
Transmitter
7059h SCITXBUF TXDT7 TXDT7 TXDT5 TXDT4 TXDT3 TXDT2 TXDT1 TXDT0
data buffer
8-20
SCI Module Registers
This bit specifies the number of stop bits transmitted. The receiver checks for
only one stop bit.
0 One stop bit
1 Two stop bits
If the PARITY ENABLE bit (SCICCR.5) is set, PARITY (bit 6) designates odd
or even parity (odd or even number of bits with the value of 1 in both transmitted
and received characters).
0 Odd parity
1 Even parity
This bit enables or disables the parity function. If the SCI is in the address-bit
multiprocessor mode (set using bit 3 of this register), the address bit is included
in the parity calculation (if parity is enabled). For characters of less than eight
bits, the remaining unused bits should be masked out of the parity calculation.
0 Parity disabled; no parity bit is generated during transmission or is
expected during reception
1 Parity is enabled
This bit enables the Loop Back test mode where the Tx pin is internally
connected to the Rx pin.
0 Loop Back test mode disabled
1 Loop Back test mode enabled
These bits select the SCI character length from one to eight bits. Characters
of less than eight bits are right-justified in SCIRXBUF and SCIRXEMU and are
padded with leading zeros in SCIRXBUF. SCITXBUF doesn’t need to be
padded with leading zeros. Table 8−4 lists the bit values and character lengths
for SCI CHAR2-0 bits.
0 0 1 2
0 1 0 3
0 1 1 4
1 0 0 5
1 0 1 6
1 1 0 7
1 1 1 8
8-22
SCI Module Registers
7 6 5 4 3 2 1 0
RX ERR SW
Reserved Reserved TXWAKE SLEEP TXENA RXENA
INT ENA RESET
Note: R = Read access, W = Write access, S = Set only, -0 = value after reset
Writing a 0 to this bit initializes the SCI state machines and operating flags
(registers SCICTL2 and SCIRXST) to the reset condition.
The SW RESET bit does not affect any of the configuration bits.
All affected logic is held in the specified reset state until a 1 is written to
SW RESET (the bit values following a reset are shown beneath each register
diagram in this section). Thus, after a system reset, re-enable the SCI by
writing a 1 to this bit.
Clear this bit after a receiver break detect (BRKDT flag, bit SCIRXST.5).
SW RESET affects the operating flags of the SCI, but it neither affects the
configuration bits nor restores the reset values.
Once SW RESET is asserted, the flags are frozen until the bit is de-asserted.
TX EMPTY SCICTL2.6 1
RXWAKE SCIRXST.1 0
PE SCIRXST.2 0
OE SCIRXST.3 0
FE SCIRXST.4 0
BRKDT SCIRXST.5 0
RXRDY SCIRXST.6 0
RX ERROR SCIRXST.7 0
8-24
SCI Module Registers
The receiver still operates when the SLEEP bit is set; however, operation does
not update the receiver buffer ready bit (SCIRXST.6, RXRDY) or the error
status bits (SCIRXST.5−2: BRKDT, FE, OE, and PE) unless the address byte
is detected. SLEEP is not cleared when the address byte is detected.
Data is transmitted through the SCITXD pin only when TXENA is set. If reset,
transmission is halted but only after all data previously written to SCITXBUF
has been sent.
0 Transmitter disabled
1 Transmitter enabled
Data is received on the SCIRXD pin and is sent to the receiver shift register
and then the receiver buffers. This bit enables or disables the receiver (transfer
to the buffers).
0 Prevent received characters from transfer into the SCIRXEMU and
SCIRXBUF receiver buffers
1 Send received characters to SCIRXEMU and SCIRXBUF
Clearing RXENA stops received characters from being transferred to the two
receiver buffers and also stops the generation of receiver interrupts. However,
the receiver shift register can continue to assemble characters. Thus, if
RXENA is set during the reception of a character, the complete character will
be transferred into the receiver buffer registers, SCIRXEMU and SCIRXBUF.
BAUD15
BAUD14 BAUD13 BAUD12 BAUD11 BAUD10 BAUD9 BAUD8
(MSB)
BAUD0
BAUD7 BAUD6 BAUD5 BAUD4 BAUD3 BAUD2 BAUD1
(LSB)
Alternatively,
BRR = CLKOUT − 1
SCI Asynchronous Baud × 8
Note that the above formulas are applicable only when 1 ≤ BRR ≤ 65535. If
BRR = 0, then
8-26
SCI Module Registers
RX
RXRDY BRKDT FE OE PE RXWAKE Reserved
ERROR
8-28
SCI Module Registers
least ten bits, beginning after a missing first stop bit. The occurrence of a break
causes a receiver interrupt to be generated if the RX/BK INT ENA bit is a 1,
but it does not cause the receiver buffer to be loaded. A BRKDT interrupt can
occur even if the receiver SLEEP bit is set to 1. BRKDT is cleared by an active
SW RESET or by a system reset. It is not cleared by receipt of a character after
the break is detected. In order to receive more characters, the SCI must be
reset by toggling the SW RESET bit or by a system reset.
0 No break condition
1 Break condition occurred
The SCI sets this bit when an expected stop bit is not found. Only the first stop
bit is checked. The missing stop bit indicates that synchronization with the start
bit has been lost and that the character is incorrectly framed. The FE bit is reset
by a clearing of the SW RESET bit or by a system reset.
0 No framing error detected
1 Framing error detected
The SCI sets this bit when a character is transferred into registers SCIRXEMU
and SCIRXBUF before the previous character is fully read by the CPU. The
previous character is overwritten and lost. The OE flag bit is reset by an active
SW RESET or by a system reset.
0 No overrun error detected
1 Overrun error detected
This flag bit is set when a character is received with a mismatch between the
number of 1s and its parity bit. The address bit is included in the calculation.
If parity generation and detection is not enabled, the PE flag is disabled and
read as 0. The PE bit is reset by an active SW RESET or a system reset.
0 No parity error or parity is disabled
1 Parity error is detected
The transfer of the first byte after the address byte to SCIRXBUF
An active SW RESET
A system reset
This is the register which should be used in an emulator watch window to view
the contents of SCIRXBUF register.
8-30
SCI Module Registers
When the current data received is shifted from RXSHF to the receiver buffer,
flag bit RXRDY is set and the data is ready to be read. If the RX/BK INT ENA
bit (SCICTL2.1) is set, this shift also causes an interrupt. When SCIRXBUF is
read, the RXRDY flag is reset. SCIRXBUF is cleared by a system reset.
SCIPRI contains the receiver and transmitter interrupt priority select bits and
controls the SCI operation on the XDS emulator during a program-suspend
event, such as hitting a breakpoint.
7 6 5 4 3 2−0
SCITX SCIRX
Reserved SCI SOFT SCI FREE Reserved
PRIORITY PRIORITY
Bit 6 SCITX PRIORITY. SCI transmitter interrupt priority select. This bit specifies
the priority level of the SCI transmitter interrupts.
0 Interrupts are high-priority requests
1 Interrupts are low-priority requests
Bit 5 SCIRX PRIORITY. SCI receiver interrupt priority select. This bit specifies the
priority level of the SCI receiver interrupts.
0 Interrupts are high-priority requests
1 Interrupts are low-priority requests
Bits 4,3 SCI SOFT and FREE bits. These bits determine what occurs when an emula-
tion suspend event occurs (for example, when the debugger hits a breakpoint).
The peripheral can continue whatever it is doing (free-run mode), or if in stop
mode, it can either stop immediately or stop when the current operation (the
current receive/transmit sequence) is complete.
Bit 4 Bit 3
SOFT FREE
0 0 Immediate stop on suspend
1 0 Complete current receive/transmit sequence before
stopping
X 1 Free run. Continues SCI operation regardless of suspend
8-32
Chapter 9
Most SPI registers are eight bits in width (except for the data registers), a
carryover from the 8-bit version of the SPI on the TMS320C240 device. The
upper 8 bits return zeros when read.
Topic Page
9-1
C240 SPI vs. LF/LC240xA SPI
Note that there is a software change required since writes of transmit data to
the serial data register, SPIDAT (and the new transmit buffer, SPITXBUF),
must be left-justified. On the C240, these writes had to be left-justified within
an 8-bit register. Now they must be left-justified within a 16-bit register.
The control and data bits for general-purpose bit I/O multiplexing have been
removed from this peripheral, along with the associated registers, SPIPC1
(704Dh) and SPIPC2 (704Eh). These bits are now in the General-Purpose I/O
registers.
The polarity of the SPI SW RESET bit in 240xA is the opposite of the 240 SPI.
9-2
C240 SPI vs. LF/LC240xA SPI
The basic function of the strobe (SPISTE) pin is to act as a transmit enable
input for the SPI module in slave mode. It stops the shift register so it cannot
receive data and puts the SPISOMI pin in the high-impedance state.
SPIFFENA
Receiver Overrun
SPIFFTX.14 Overrun Flag INT ENA
16
M M
SPIDAT S
Data Register S SW1 SPISIMO
M M
SPIDAT.15 − 0
S
S SW2 SPISOMI
Talk
SPICTL.1
SPISTE†
*
State Control
Master/Slave
SPI Char SPICCR.3 − 0 SPICTL.2
S
3 2 1 0 SW3
Clock Clock
SPI Bit Rate M S Polarity Phase
LSPCLK SPIBRR.6 − 0 SPICCR.6 SPICTL.3 SPICLK
M
6 5 4 3 2 1 0
9-4
Overview of SPI Module Registers
SPICCR (SPI configuration control register). Contains control bits used for
SPI configuration
SPI module software reset
SPICLK polarity selection
Four SPI character-length control bits
SPICTL (SPI operation control register). Contains control bits for data
transmission
Two SPI interrupt enable bits
SPICLK phase selection
Operational mode (master/slave)
Data transmission enable
SPISTS (SPI status register). Contains two receive buffer status bits and
one transmit buffer status bit
RECEIVER OVERRUN
SPI INT FLAG
TX BUF FULL FLAG
SPIBRR (SPI baud rate register). Contains seven bits that determine the
bit transfer rate
SPIRXBUF (SPI receive buffer — the serial receive buffer register). Con-
tains the received data
SPITXBUF (SPI transmit buffer — the serial transmit buffer register). Con-
tains the next character to be transmitted
SPIPRI (SPI priority register). Contains bits that specify interrupt priority
and determine SPI operation on the XDS emulator during program sus-
pensions
7043h Reserved
7045h Reserved
704Ah Reserved
704Bh Reserved
704Ch Reserved
704Dh Reserved
704Eh Reserved
9-6
SPI Operation
The master initiates data transfer by sending the SPICLK signal. For both the
slave and the master, data is shifted out of the shift registers on one edge of
the SPICLK and latched into the shift register on the opposite SPICLK clock
edge. If the CLOCK PHASE bit (SPICTL.3) is high, data is transmitted and
received a half-cycle before the SPICLK transition (see section 9.3.2, SPI
Module Slave and Master Operation Modes, on page 9-8). As a result, both
controllers send and receive data simultaneously. The application software
determines whether the data is meaningful or dummy data. There are three
possible methods for data transmission:
The master can initiate data transfer at any time because it controls the
SPICLK signal. The software, however, determines how the master detects
when the slave is ready to broadcast data.
SPI
SPISTE SPISTE
strobe
SPIDAT.15−0 SPIDAT.15−0
Shift register SPISOMI Slave out/ SPISOMI Shift register
MSB
(SPIDAT) LSB master in
MSB
(SPIDAT) LSB
Serial
SPICLK SPICLK
clock
SPITXBUF.15−0 SPITXBUF.15−0
Serial transmit buffer Serial transmit buffer
SPITXBUF SPITXBUF
Processor 1 Processor 2
Master Mode
In the master mode (MASTER/SLAVE = 1), the SPI provides the serial clock
on the SPICLK pin for the entire serial communications network. Data is output
on the SPISIMO pin and latched from the SPISOMI pin.
The SPIBRR register determines both the transmit and receive bit transfer rate
for the network. SPIBRR can select 126 different data transfer rates.
Data written to SPIDAT or SPITXBUF initiates data transmission on the
SPISIMO pin, MSB (most significant bit) first. Simultaneously, received data
is shifted through the SPISOMI pin into the LSB (least significant bit) of
SPIDAT. When the selected number of bits has been transmitted, the received
data is transferred to the SPIRXBUF (buffered receiver) for the CPU to read.
Data is stored right-justified in SPIRXBUF.
When the specified number of data bits has been shifted through SPIDAT, the
following events occur:
SPIDAT contents are transferred to SPIRXBUF.
9-8
SPI Operation
In a typical application, the SPISTE pin serves as a chip-enable pin for a slave
SPI device and drives this pin high again after transmitting the master data.
This pin is driven low by the master before transmitting data to the slave and
is taken high after the transmission is complete.
Slave Mode
In the slave mode (MASTER/SLAVE = 0), data shifts out on the SPISOMI pin
and in on the SPISIMO pin. The SPICLK pin is used as the input for the serial
shift clock, which is supplied from the external network master. The transfer
rate is defined by this clock. The SPICLK input frequency should be no greater
than the CLKOUT frequency divided by 4.
Data written to SPIDAT or SPITXBUF is transmitted to the network when
appropriate edges of the SPICLK signal are received from the network master.
Data written to the SPITXBUF register will be transferred to the SPIDAT
register when all bits of the character to be transmitted have been shifted out
of SPIDAT. If no character is currently being transmitted when SPITXBUF is
written to, the data will be transferred immediately to SPIDAT. To receive data,
the SPI waits for the network master to send the SPICLK signal and then shifts
the data on the SPISIMO pin into SPIDAT. If data is to be transmitted by the
slave simultaneously, and SPITXBUF has not been previously loaded, the
data must be written to SPITXBUF or SPIDAT before the beginning of the
SPICLK signal.
When the TALK bit (SPICTL.1) is cleared, data transmission is disabled, and
the output line (SPISOMI) is put into the high-impedance state. If this occurs
while a transmission is active, the current character is completely transmitted
even though SPISOMI is forced into the high-impedance state. This ensures
that the SPI is still able to receive incomming data correctly. This TALK bit
allows many slave devices to be tied together on the network, but only one
slave at a time is allowed to drive the SPISOMI line.
The SPISTE pin operates as the slave-select pin. An active-low signal on the
SPISTE pin allows the slave SPI to transfer data to the serial data line; an
inactive-high signal causes the slave SPI’s serial shift register to stop and its
serial output pin to be put into the high-impedance state. This allows many
slave devices to be tied together on the network, although only one slave
device is selected at a time.
When the SPI interrupt-enable bit is set and an interrupt condition occurs, the
corresponding interrupt is asserted.
0 Disable SPI interrupts
1 Enable SPI interrupts
This status flag indicates that a character has been placed in the SPI receiver
buffer and is ready to be read.
When a complete character has been shifted into or out of SPIDAT, the SPI INT
FLAG bit (SPISTS.6) is set, and an interrupt is generated if enabled by the SPI
INT ENA bit (SPICTL.0). The interrupt flag remains set until it is cleared by one
of the following events:
The CPU reads the SPIRXBUF (reading the SPIRXEMU does not clear
the SPI INT FLAG bit).
When the SPI INT FLAG bit is set, a character has been placed into the
SPIRXBUF and is ready to be read. If the CPU does not read the character by
the time the next complete character has been received, the new character is
9-10
SPI Interrupts
written into SPIRXBUF, and the RECEIVER OVERRUN Flag bit (SPISTS.7)
is set.
Setting the overrun interrupt enable bit allows the assertion of an interrupt
whenever the RECEIVER OVERRUN Flag bit (SPISTS.7) is set by hardware.
Interrupts generated by SPISTS.7 and by the SPI INT FLAG bit (SPISTS.6)
share the same interrupt vector.
0 Disable RECEIVER OVERRUN Flag bit interrupts
1 Enable RECEIVER OVERRUN Flag bit interrupts
The value of the SPI PRIORITY bit determines the priority of the interrupt
request from the SPI.
0 Interrupts are high-priority requests
1 Interrupts are low-priority requests
0 1 1 1 0 0 1 1 0 1 1 1 1 0 1 1
(TXed) 0 ← 1 1 1 0 0 1 1 0 1 1 1 1 0 1 1 x ← (RXed)
1 1 1 0 0 1 1 0 1 1 1 1 0 1 1 x
Note: x = 1 if SPISOMI data is high; x = 0 if SPISOMI data is low; master mode is assumed.
In the slave mode, the SPI clock is received on the SPICLK pin from the
external source, and can be no greater than the CLKOUT frequency
divided by 4.
In the master mode, the SPI clock is generated by the SPI and is output
on the SPICLK pin, and can be no greater than the CLKOUT frequency
divided by 4.
9-12
SPI Interrupts
For SPIBRR = 0, 1, or 2:
where:
To determine what value to load into SPIBRR, you must know the device
system clock (CLKOUT) frequency (which is device-specific) and the baud
rate at which you will be operating.
Example 9−2 shows how to determine the maximum baud rate at which a
240xA can communicate. Assume that CLKOUT = 40 MHz.
Falling Edge Without Delay. The SPI transmits data on the falling edge of
the SPICLK and receives data on the rising edge of the SPICLK.
Falling Edge With Delay. The SPI transmits data one half-cycle ahead of
the falling edge of the SPICLK signal and receives data on the falling edge
of the SPICLK signal.
Rising Edge Without Delay. The SPI transmits data on the rising edge of
the SPICLK signal and receives data on the falling edge of the SPICLK sig-
nal.
Rising Edge With Delay. The SPI transmits data one half-cycle ahead of
the rising edge of the SPICLK signal and receives data on the rising edge
of the SPICLK signal.
The selection procedure for the SPI clocking scheme is shown in Table 9−2.
Examples of these four clocking schemes relative to transmitted and received
data are shown in Figure 9−3.
SPICLK cycle 1 2 3 4 5 6 7 8
number
SPICLK
(Rising edge
without delay)
SPICLK
(Rising edge
with delay)
SPICLK
(Falling edge
without delay)
SPICLK
(Falling edge
with delay)
SPISTE
(Into slave)
Receive latch
points
9-14
SPI Interrupts
For the SPI, SPICLK symmetry is retained only when the result of (SPIBRR+1)
is an even value. When (SPIBRR + 1) is an odd value and SPIBRR is greater
than 3, SPICLK becomes asymmetrical. The low pulse of SPICLK is one
CLKOUT longer than the high pulse when the CLOCK POLARITY bit is
clear (0). When the CLOCK POLARITY bit is set to 1, the high pulse of the
SPICLK is one CLKOUT longer than the low pulse, as shown in Figure 9−4.
Figure 9−4. SPI: SPICLK-CLKOUT Characteristic when (BRR + 1) is Odd, BRR > 3, and
CLOCK POLARITY = 1
2 cycles 3 cycles 2 cycles
CLKOUT
SPICLK
1) Clear the SPI SW RESET bit (SPICCR.7) to 0 to force the SPI to the reset
state.
2) Initialize the SPI configuration, format, baud rate, and pin functions as de-
sired.
3) Set the SPI SW RESET bit to 1 to release the SPI from the reset state.
Note:
Do not change SPI configuration when communication is in progress.
The timing diagram with SPICLK unsymmetrical (Figure 9−4) shares similar
characterizations with Figure 9−5 except that the data transfer is one CLKOUT
cycle longer per bit during the low pulse (CLOCK POLARITY = 0) or during the
high pulse (CLOCK POLARITY = 1) of the SPICLK.
Figure 9−5, Five Bits per Character, is applicable for 8-bit SPI only and is not
for 24x devices that are capable of working with 16-bit data. The figure is
shown for illustrative purposes only.
9-16
SPI Interrupts
CLOCK POLARITY = 0
CLOCK PHASE = 1
CLOCK POLARITY = 1
CLOCK PHASE = 0
CLOCK POLARITY = 1
CLOCK PHASE = 1
SPISTE
A. Slave writes 0D0h to SPIDAT and waits for the master to shift out the data.
B. Master sets the slave SPISTE signal low (active).
C. Master writes 058h to SPIDAT, which starts the transmission procedure.
D. First byte is finished and sets the interrupt flags.
E. Slave reads 0Bh from its SPIRXBUF (right-justified).
F Slave writes 04Ch to SPIDAT and waits for the master to shift out the data.
G. Master writes 06Ch to SPIDAT, which starts the transmission procedure.
H. Master reads 01Ah from the SPIRXBUF (right−justified).
I. Second byte is finished and sets the interrupt flags.
J. Master reads 89h and the slave reads 8Dh from their respective SPIRXBUF. After the user’s software masks off the
unused bits, the master receives 09h and the slave receives 0Dh.
K. Master clears the slave SPISTE signal high (inactive).
− illegal
9-18
SPI Module Registers
7 6 5−4 3 2 1 0
SPI SW CLOCK
Reserved SPI CHAR3 SPI CHAR2 SPI CHAR1 SPI CHAR0
RESET POLARITY
Bit 7 SPI SW RESET. SPI Software Reset. When changing configuration, you
should clear this bit before the changes and set this bit before resuming opera-
tion. (See Section 9.4.5.1 on page 9-16.)
0 Initializes the SPI operating flags to the reset condition.
Specifically, the RECEIVER OVERRUN Flag bit (SPISTS.7), the
SPI INT FLAG bit (SPISTS.6), and the TXBUF FULL Flag bit
(SPISTS.5) are cleared. The SPI configuration remains un-
changed. If the module is operating as a master, the SPICLK sig-
nal output returns to its inactive level.
1 SPI is ready to transmit or receive the next character.
When the SPI SW RESET bit is a 0, a character written to the
transmitter will not be shifted out when this bit is set. A new char-
acter must be written to the serial data register.
Bit 6 CLOCK POLARITY. Shift Clock Polarity. This bit controls the polarity of the
SPICLK signal. CLOCK POLARITY and CLOCK PHASE (SPICTL.3) control
four clocking schemes on the SPICLK pin. See Section 9.4.4, SPI Clocking
Schemes, on page 9-13.
0 Data is output on rising edge and input on falling edge. When no
SPI data is sent, SPICLK is at low level.
The data input and output edges depend on the value of the
CLOCK PHASE bit (SPICTL.3) as follows:
CLOCK PHASE = 0: Data is output on the rising edge of the
SPICLK signal; input data is latched on the falling edge of the
SPICLK signal.
CLOCK PHASE = 1: Data is output one half-cycle before the first
rising edge of the SPICLK signal and on subsequent falling edges
of the SPICLK signal; input data is latched on the rising edge of
the SPICLK signal.
Bits 3−0 SPI CHAR3−SPI CHAR0. Character Length Control Bits 3−0. These four bits
determine the number of bits to be shifted in or out as a single character during
one shift sequence.
Table 9−3 lists the character length selected by the bit values.
9-20
SPI Module Registers
Bit 4 OVERRUN INT ENA. Overrun Interrupt Enable. Setting this bit causes an in-
terrupt to be generated when the RECEIVER OVERRUN Flag bit (SPISTS.7)
is set by hardware. Interrupts generated by the RECEIVER OVERRUN Flag
bit and the SPI INT FLAG bit (SPISTS.6) share the same interrupt vector.
0 Disable RECEIVER OVERRUN Flag bit (SPISTS.7) interrupts
1 Enable RECEIVER OVERRUN Flag bit (SPISTS.7) interrupts
Bit 3 CLOCK PHASE. SPI Clock Phase Select. This bit controls the phase of the
SPICLK signal.
0 Normal SPI clocking scheme, depending on the CLOCK POLAR-
ITY bit (SPICCR.6)
1 SPICLK signal delayed by one half-cycle; polarity determined by
the CLOCK POLARITY bit
Bit 2 MASTER/SLAVE. SPI Network Mode Control. This bit determines whether
the SPI is a network master or slave. During reset initialization, the SPI is auto-
matically configured as a network slave.
0 SPI configured as a slave.
1 SPI configured as a master.
Bit 1 TALK. Master/Slave Transmit Enable. The TALK bit can disable data trans-
mission (master or slave) by placing the serial data output in the high-
impedance state. If this bit is disabled during a transmission, the transmit shift
register continues to operate until the previous character is shifted out. When
the TALK bit is disabled, the SPI is still able to receive characters and update
the status flags. TALK is cleared (disabled) by a system reset.
0 Disables transmission:
Slave mode operation: If not previously configured as a general-
purpose I/O pin, the SPISOMI pin will be put in the high-
impedance state.
Master mode operation: If not previously configured as a general-
purpose I/O pin, the SPISIMO pin will be put in the high-
impedance state.
1 Enables transmission
For the 4-pin option, ensure to enable the receiver’s SPISTE input
pin.
Bit 0 SPI INT ENA. SPI Interrupt Enable. This bit controls the SPI’s ability to gener-
ate a transmit/receive interrupt. The SPI INT FLAG bit (SPISTS.6) is unaf-
fected by this bit.
0 Disables interrupt
1 Enables interrupt
7 6 5 4−0
RECEIVER
TX BUF FULL
OVERRUN SPI INT FLAG†‡ Reserved
FLAG‡
FLAG†‡
Bit 7 RECEIVER OVERRUN FLAG. SPI Receiver Overrun Flag. This bit is a read/
clear-only flag. The SPI hardware sets this bit when a receive or transmit op-
eration completes before the previous character has been read from the buff-
er. The bit indicates that the last received character has been overwritten and
therefore lost (when the SPIRXBUF was overwritten by the SPI module before
the previous character was read by the user application). The SPI requests
9-22
SPI Module Registers
one interrupt sequence each time this bit is set if the OVERRUN INT ENA bit
(SPICTL.4) is set high. The bit is cleared in one of three ways:
If the OVERRUN INT ENA bit (SPICTL.4) is set, the SPI requests only one
interrupt upon the first occurrence of setting the RECEIVER OVERRUN Flag
bit. Subsequent overruns will not request additional interrupts if this flag bit is
already set. This means that in order to allow new overrun interrupt requests
the user must clear this flag bit by writing a 1 to SPISTS.7 each time an overrun
condition occurs. In other words, if the RECEIVER OVERRUN Flag bit is left
set (not cleared) by the interrupt service routine, another overrun interrupt will
not be immediately re-entered when the interrupt service routine is exited.
However, the RECEIVER OVERRUN Flag bit should be cleared during the
interrupt service routine because the RECEIVER OVERRUN Flag bit and SPI
INT FLAG bit (SPISTS.6) share the same interrupt vector. This will alleviate
any possible doubt as to the source of the interrupt when the next byte is
received.
Bit 6 SPI INT FLAG. SPI Interrupt Flag. SPI INT FLAG is a read-only flag. The SPI
hardware sets this bit to indicate that it has completed sending or receiving the
last bit and is ready to be serviced. The received character is placed in the re-
ceiver buffer at the same time this bit is set. This flag causes an interrupt to be
requested if the SPI INT ENA bit (SPICTL.0) is set. This bit is cleared in one of
three ways:
Reading SPIRXBUF
Bit 5 TX BUF FULL FLAG. SPI Transmit Buffer Full Flag. This read-only bit gets set
to 1 when a character is written to the SPI Transmit buffer SPITXBUF. It is
cleared when the character is automatically loaded into SPIDAT when the
shifting out of a previous character is complete. It is cleared at reset.
SPI BIT SPI BIT SPI BIT SPI BIT SPI BIT SPI BIT SPI BIT
Reserved
RATE 6 RATE 5 RATE 4 RATE 3 RATE 2 RATE 1 RATE 0
Bits 6−0 SPI BIT RATE 6−SPI BIT RATE 0. SPI Bit Rate (Baud) Control. These bits de-
termine the bit transfer rate if the SPI is the network master. There are 125
data-transfer rates (each a function of the CPU clock, CLKOUT) that can be
selected. One data bit is shifted per SPICLK cycle. (SPICLK is the baud rate
clock output on the SPICLK pin.)
If the SPI is a network slave, the module receives a clock on the SPICLK pin
from the network master; therefore, these bits have no effect on the SPICLK
signal. The frequency of the incoming SPICLK from the master should not
exceed CLKOUT/4.
In master mode, the SPI clock is generated by the SPI and is output on the
SPICLK pin. The SPI baud rates are determined by the following formula:
For SPIBRR = 0, 1, or 2:
9-24
SPI Module Registers
Bits 15−0 ERXB15−ERXB0. Emulation Buffer Received Data. SPIRXEMU functions al-
most identically to SPIRXBUF, except that reading SPIRXEMU does not clear
the SPI INT FLAG bit (SPISTS.6). Once the SPIDAT has received the com-
plete character, the character is transferred to SPIRXEMU and SPIRXBUF,
where it can be read. At the same time, SPI INT FLAG is set.
It is recommended that you view SPIRXEMU in the normal emulator run mode.
Figure 9−12. SPI Serial Receive Buffer Register (SPIRXBUF) — Address 7047h
15 14 13 12 11 10 9 8
Bits 15−0 RXB15−RXB0. Received Data. Once SPIDAT has received the complete
character, the character is transferred to SPIRXBUF, where it can be read. At
the same time, the SPI INT FLAG bit (SPISTS.6) is set. Since data is shifted
into the SPI’s most significant bit first, it is stored right-justified in this register.
9-26
SPI Module Registers
Figure 9−13. SPI Serial Transmit Buffer Register (SPITXBUF) — Address 7048h
15 14 13 12 11 10 9 8
Bits 15−0 TXB15−TXB0. Transmit Data Buffer. This is where the next character to be
transmitted is stored. When the transmission of the current character has com-
pleted, if the TX BUF FULL Flag bit is set, the contents of this register is auto-
matically transferred to SPIDAT, and the TX BUF FULL Flag is cleared.
Note:
Writes to SPITXBUF must be left-justified.
Bits 15−0 SDAT15−SDAT0. Serial Data. Writing to the SPIDAT performs two functions:
It provides data to be output on the serial output pin if the TALK bit
(SPICTL.1) is set.
9-28
SPI Module Registers
Bit 6 SPI PRIORITY. Interrupt Priority Select. This bit specifies the priority level of
the SPI interrupt.
0 Interrupts are high-priority requests
1 Interrupts are low-priority requests
Bits 5−4 SPI SUSP SOFT and SPI SUSP FREE bits. These bits determine what oc-
curs when an emulation suspend occurs (for example, when the debugger hits
a breakpoint). The peripheral can continue whatever it is doing (free-run
mode) or, if in stop mode, it can either stop immediately or stop when the cur-
rent operation (the current receive/transmit sequence) is complete.
Bit 5 Bit 4
Soft Free
0 0 Immediate stop on suspend
1 0 Complete current receive/transmit sequence before stop-
ping
X 1 Free run, continue SPI operation regardless of suspend
Figure 9−16. CLOCK POLARITY = 0, CLOCK PHASE = 0 (All data transitions are during
the rising edge, non-delayed clock. Inactive level is low.)
Ch1 Period
200 ns
SPICLK
SPISIMO
9-30
SPI Example Waveforms
Figure 9−17. CLOCK POLARITY = 0, CLOCK PHASE = 1 (All data transitions are during
the rising edge, but delayed by half clock cycle. Inactive level is low.)
Ch1 Period
200 ns
SPICLK
SPISIMO
Figure 9−18. CLOCK POLARITY = 1, CLOCK PHASE = 0 (All data transitions are during
the falling edge. Inactive level is high.)
Ch1 Period
199 ns
SPICLK
SPISIMO
9-32
SPI Example Waveforms
Figure 9−19. CLOCK POLARITY = 1, CLOCK PHASE = 1 (All data transitions are during
the falling edge, but delayed by half clock cycle. Inactive level is high.)
Ch1 Period
200 ns
SPICLK
SPISIMO
Figure 9−20. SPISTE Behavior in Master Mode (Master lowers SPISTE during the entire
16 bits of transmission.)
Ch1 Period
200 ns
SPICLK
SPISTE
9-34
SPI Example Waveforms
Figure 9−21. SPISTE Behavior in Slave Mode (Slave’s SPISTE is driven low during the
entire 16 bits of transmission.)
Ch1 Period
398 ns
SPISIMO
SPISTE
This chapter describes the controller area network (CAN) module available on
some members of the 24x/240xA family. The interface signals, configuration
registers, and mailbox RAM are described in detail; however, the CAN protocol
itself is not discussed in depth. For details on the protocol, refer to CAN
Specification, Version 2.0, by Robert Bosch GmBH, Germany. The CAN
module is a full-CAN controller designed as a 16-bit peripheral and is fully
compliant with the CAN protocol, version 2.0B.
Topic Page
10-1
Introduction
10.1 Introduction
The CAN peripheral supports the following features:
Full implementation of CAN protocol, version 2.0B
Standard and extended identifiers
Data and remote frames
Six mailboxes for objects with data lengths of 0- to 8-bytes
Two receive mailboxes (MBOX0,1), two transmit mailboxes
(MBOX4,5)
Two configurable transmit/receive mailboxes (MBOX2,3)
Local acceptance mask registers (LAMn) for mailboxes 0 and 1 and mail-
boxes 2 and 3
Programmable bit rate
10-2
Overview of the CAN Network
Overload frames that provide an extra delay between the preceding and
the succeeding data frames or remote frames
In addition, CAN Specification Version 2.0B defines two different formats that
differ in the length of the identifier field: standard frames with an 11-bit identifier
and extended frames with a 29-bit identifier.
CAN standard data frames contain from 44 to 108 bits, and CAN extended
data frames contain 64 to 128 bits. Furthermore, up to 23 stuff bits can be
inserted in a standard data frame and up to 28 stuff bits in an extended data
frame, depending on the data-stream coding. The overall maximum data
frame length is 131 bits for a standard frame and 156 bits for an extended
frame.
In Figure 10−1, bit fields within the data frame identify:
Start of the frame
Arbitration field containing the identifier and the type of message being
sent
Control field containing the number of data
Up to 8 bytes of data
Cyclic redundancy check (CRC)
Acknowledgment
End-of-frame bits
10-4
Overview of the CAN Network
Control/status registers
Mailbox RAM
4 Transmit only —
5 Transmit only —
CAN_IMR LAM0_H
Mailbox 1
MSG ID0L MSG ID0H
Mailbox 2
MSG CTRL0 Reserved
Mailbox 3
MBX0A MBX0B
Mailbox 4
MBX0C MBX0D
7230 Mailbox 5
FFFF
.
.
.
10-6
Overview of the CAN Network
710Bh LAM0_H Local Acceptance Mask for MBOX0 and 1 (bits 31, 28 to 16)
710Dh LAM1_H Local Acceptance Mask for MBOX2 and 3 (bits 31, 28 to 16)
710Fh Reserved Accesses assert the CAADDRx signal from the CAN peripheral
(which will assert an Illegal Address error)
Note: All unimplemented register bits are read as zero; writes have no effect. All register bits are initialized to zero unless other-
wise stated in the definition.
The mailboxes are located in one 48 × 16 RAM with 16-bit access and can be
written to or read by the CPU (user) or CAN. The CAN write or read access,
as well as the CPU read access, needs one clock cycle. The CPU write access
needs two clock cycles because the CAN controller performs a
read-modify-write cycle; and therefore, inserts one wait state for the CPU.
Mailboxes
Reserved
10-8
Message Objects
Identifier:
SRR: Substitute Remote Request bit − this bit occupies the position as
RTR would in a standard frame
Data: Four 16-bit words are used to store the (maximum) 8-byte data field
of a CAN message
RW RW RW RW
This bit is relevant for receive mailboxes only. Hence, it is applicable for
MBOX0 and MBOX1 and also for MBOX2 and MBOX3, if they are configured
as receive mailboxes. It is a don’t care for mailboxes 4 and 5.
10-10
Message Objects
Bits 12−0 IDH[28:16]. Upper 13 Bits of extended identifier. For a standard identifier, the
11-bit identifier will be stored in bits 12 to 2 of the MSGID’s upper word.
IDL[15:0]
RW
Bits 15−0 IDL[15:0]. The lower part of the extended identifier is stored in these bits.
RW RW
Note:
Write accesses to the identifier can only be accomplished when the mailbox
is disabled (MEn = 0 in MDER register).
10-12
Message Objects
During accesses to the data field or control field, it is critical that the data does
not change while the CAN module is reading it. Therefore, a write access to
the data field or control field is disabled for a receive mailbox. For transmit
mailboxes, the access is usually denied if the transmit request set (TRS) bit
or the transmit request reset (TRR) bit is set. In these cases, a write-denied
interrupt flag (WDIF) is asserted. A way to access mailboxes 2 and 3 is to set
the change data field request (CDR) bit before accessing the mailbox data.
After the CPU access is finished, the CPU must clear the CDR flag by writing
a 0 to it. The CAN module checks for that flag before and after reading the
mailbox. If the CDR flag is set during the mailbox checks, the CAN module
does not transmit the message but continues to look for other transmit
requests. The setting of the CDR flag also stops the write-denied interrupt
(WDI) from being asserted. CAN read/write and CPU read accesses to the
mailbox RAM take one clock cycle. CPU writes to the mailbox RAM take two
clock cycles.
If more than one mailbox is configured as a transmit mailbox and more than
one corresponding TRS bit is set, the messages are sent one after another,
in falling order, beginning with the highest enabled mailbox.
If a second message has been received for this mailbox and the RMP bit is
already set, the corresponding receive message lost (RML) bit is set. In this
case, the stored message is overwritten with the new data if the overwrite
protection control (OPC) bit is cleared. Otherwise, the next mailboxes are
checked.
Note:
For the mailbox interrupt flag (MIFn) bits in the CAN_IFR register to be set,
the corresponding bits in the CAN_IMR register must be enabled. If “polling”
is desired to complete transmission or reception of messages (as opposed
to interrupts), the following bits must be used:
For transmission: TAn bits in the TCR register
If the CPU wants to change the data in a message object that is configured as
a remote frame mailbox (AAM bit set), it has to set the mailbox number (MBNR)
10-14
Message Objects
in the master control register and the CDR in the master control register first.
The CPU may then perform the access and clear the CDR to tell the CAN
module that the access is finished. Until the CDR is cleared, the transmission
of this mailbox is not performed. Since the TRS bit is not affected by the CDR,
a pending transmission is stacked after the CDR is cleared. Thus, the newest
data will be sent.
In order to change the identifier in the mailbox, the message object must be
disabled first (ME bit in the MDER = 0).
If the CPU wants to request data from another node, it may configure the
message object as a receive mailbox (only mailboxes 2 and 3) and set the TRS
bit. See Figure 10−8 (F). In this case, the module sends a remote frame
request and receives the data frame in the same mailbox that sent the request.
Therefore, only one mailbox is necessary to do a remote request.
Note:
After successful transmission of a remote frame, the TRS bit is reset but no
transmit acknowledge (TA) or mailbox interrupt flag is set.
data frame
(D) Receive mailbox RMP = 1
Local acceptance mask register LAM1 is used for mailboxes 2 and 3 while
local acceptance mask register LAM0 is used for mailboxes 0 and 1. During
10-16
Message Objects
Figure 10−9. Local Acceptance Mask Register n (0, 1) High Word (LAMn_H) − Addresses
710Bh, 710Dh
15 14−13 12−0
RW-0 RW-0
Note: R = Read access; W = Write access; value following dash (−) = value after reset
Figure 10−10. Local Acceptance Mask Register n (0, 1) Low Word (LAMn_L) −
Addresses 710Ch, 710Eh
15−0
LAMn[15:0]
RW-0
Note: R = Read access; W = Write access; value following dash (−) = value after reset
Bits 15−0 LAMn[15:0]. Lower part of the local acceptance mask. These bits enable the
masking of any identifier bit of an incoming message.
0 Received identifier bit value must match the identifier bit of the
receive mailbox.
1 Accept a 0 or a 1 (don’t care) for the corresponding bit of the
receive identifier.
10-18
CAN Control Registers
Reserved
7 6 5 4 3 2 1 0
Bits 7−6 MDn. Mailbox direction for mailbox n. Mailboxes 2 and 3 can be configured as
a transmit or receive mailbox.
Bits 5−0 MEn. Mailbox-enable for mailbox n. Each mailbox can be enabled or disabled.
If the bit MEn is 0, the corresponding mailbox n is disabled. The mailbox must
be disabled before writing to any identifier field.
Mailboxes that are disabled may be used as additional memory for the DSP.
10-20
CAN Control Registers
If TRSn is set, write access to the corresponding mailbox is denied, and the
message in mailbox n will be transmitted. Several TRS bits can be set
simultaneously.
TRS bits can be set by the CPU (user) or the CAN module and reset by internal
logic. If the CPU tries to set a bit while the CAN tries to clear it, the bit is set.
TRS bits are set by the user writing a 1. Writing a 0 has no effect.
In the event of a remote frame request, the TRS bits are set by the CAN module
for mailboxes 2 and 3.
The TRSn bits are reset after a successful or an aborted transmission (if an
abort is requested).
A write to a mailbox with TRS set will have no effect and will generate the WDIF
interrupt if enabled. A successful transmission initiates a mailbox interrupt, if
enabled.
TRS bits are used for mailboxes 4 and 5, and also for 2 and 3 if they are
configured for transmission.
1) A successful transmission
2) An abort due to a lost arbitration
3) An error condition detected on the CAN bus line
If the transmission is successful, the status bit TAn is set. If the transmission
is aborted, the corresponding status bit AAn is set. In case of an error
condition, an error status bit is set in the ESR.
The status of the TRR bits can be read from the TRS bits. For example, if TRS
is set and a transmission is ongoing, TRR can only be reset by the actions
described above. If the TRS bit is reset and the TRR bit is set, no effect occurs
because the TRR bit will be immediately reset.
Bits 15−12 RFPn. Remote Frame Pending Register (for mailbox n).
Whenever a remote frame request is received by the CAN Peripheral, the
corresponding bit RFPn is set.
It may be cleared by the CPU if the TRSn is not set; otherwise, it is reset
automatically. If the CPU tries to reset a bit and the CAN Peripheral tries to set
the bit at the same time, the bit is cleared.
If the AAM bit in the MSGIDn register is not set (and thus no answer is sent
automatically), the CPU must clear bit RFPn after handling the event.
If the message is sent successfully, RFPn is cleared by the CAN Peripheral.
The CPU cannot interrupt an ongoing transfer.
Bits 11−8 RMLn. Receive Message Lost (for mailbox n).
If an old message is overwritten by a new one in mailbox n, bit RMLn is set.
RMLn is not set in mailboxes that have the OPCn bit set. Thus, a message may
be lost without notification.
These bits can only be reset by the CPU and can be set by the internal logic.
They can be cleared by writing a 1 to RMPn. If the CPU tries to reset a bit and
the CAN tries to set the bit at the same time, the bit is set.
If one or more RML bits in the RCR register are set, the RMLIF in the CAN_IFR
register is also set. This may initiate an interrupt if the RMLIM bit in the
CAN_IMR register is set.
10-22
CAN Control Registers
Before the CPU enters its IDLE mode (if IDLE shuts off the peripheral clocks),
it must request a CAN power down by writing to the PDR bit. The CPU must
then poll the PDA bit in the GSR, and enter IDLE only after PDA is set.
0 The power-down mode is not requested (normal operation).
1 The power-down mode is requested.
Note:
The DBO bit is used to define the order in which the data bytes are stored
in the mailbox when received and in which the data bytes are transmitted.
Byte 0 is the first byte in the message and Byte 7 is the last one as shown
in the figure of the CAN message (Figure 10−4).
10-24
CAN Control Registers
The CDR bit is applicable for mailboxes 2 and 3 only and in the following
situation: 1) either (or both) of these mailboxes are configured for transmission
and 2) the corresponding AAM bit (MSGIDxH.13) is set.
0 The CPU requests normal operation.
1 The CPU requests write access to the data field of the mailbox in
MBNR (also located in MCR). The CDR bit must be cleared by the
CPU after accessing the mailbox. The CAN module does not transmit
the mailbox if the CDR is set. This is checked by the state machine
before and after it reads the data from the mailbox to store it in the
transmit buffer.
The CPU requests a write access to the data field for the mailbox
having this number and configured for Remote Frame Handling.
These are mailboxes 2 (10) or 3 (11), but not 0, 1, 4 or 5.
The bit configuration registers (BCR1 and BCR2) are used to configure the
CAN node with the appropriate network timing parameters. These registers
must be programmed before using the CAN module and are writeable only in
configuration mode. The CCR bit (MCR.12) must be set to put the CAN module
in configuration mode. Figure 10−15 and Figure 10−16 illustrate BCR2 and
BCR1, respectively.
Note:
To avoid unpredictable behavior, BCR1 and BCR2 should never be pro-
grammed with values not allowed by the CAN protocol specification.
The length of a bit on the CAN bus is determined by the parameters time
segment 1 (TSEG1) and 2 (TSEG2) and by the baud rate prescaler value
(BRP). All controllers on the CAN bus must have the same baud rate and bit
length. At different clock frequencies of the individual controllers, the baud rate
has to be adjusted by the given parameters. In the bit timing logic, the
conversion of the parameters to the required bit timing is realized.
Reserved
7−0
BRP[7:0]
RW-0
Note: R = Read access; W = Write access; value following dash (−) = value after reset
Bits 7 to 0 of this field specify the duration of a time quantum (TQ) in CAN
module system clock units. The length of one TQ is defined by:
TQ + ǒCLKOUT
1 Ǔ (BRP ) 1) ns
If BRP = BCR2 = 0, then 1 TQ = 1 CPU clock cycle.
10-26
CAN Control Registers
RW-0 RW-0
7 6−3 2−0
Note: R = Read access; W = Write access; value following dash (−) = value after reset
Note:
Since the SJW[1:0] value is enhanced by one by the CAN module, the
value that is written in bits [1:0] is actually (SJW − 1), where SJW is
the timing segment referred to in Figure 10−17, CAN Bit
Timing.
TSEG1 combines PROP SEG and PHASE SEG1 segments (CAN protocol).
Note:
Since the TSEG1[3:0] value is enhanced by one by the CAN module, the
value that is written in bits [3:0] is actually (TSEG1 − 1), where TSEG1
is the timing segment referred to in Figure 10−17, CAN Bit
Timing.
Note:
Since the TSEG2[2:0] value is enhanced by one by the CAN module, the val-
ue that is written in bits [2:0] is actually (TSEG2 − 1), where TSEG2 is the
timing segment referred to in Figure 10−17 CAN Bit
Timing.
Note:
The user-defined values for the SJW, TSEG1, and TSEG2 parameters are
enhanced by one (by the internal logic) when the CAN module accesses
these parameters.
10-28
CAN Control Registers
SYNCSEG
SJW SJW
1 TQ
Sample point
Transmit point
Note: TSEG1 and TSEG2 are the values written by the user in BCR1 register.
Sampling
TSEG1 TSEG2 Bit Time BRP Point Baud Rate
4 3 10 3 60% 1 Mbit/s
11 6 20 39 65% 50 Kbit/s
Bits 8 to 3 are error bits that can be read and cleared by writing a 1 to them.
Bits 2 to 0 are status bits that cannot be cleared, only read.
Reserved FER
RC-0
7 6 5 4 3 2 1 0
Note: R = Read access; C = Clear; value following dash (−) = value after reset
10-30
Status Registers
Reserved
7−6 5 4 3 2 1 0
10-32
Status Registers
This bit reflects what the CBM is actually doing regardless of mailbox
configuration.
0 The CAN core module is not transmitting a message.
1 The CAN core module is transmitting a message.
TEC[7:0]
R-0
7−0
REC[7:0]
R-0
Note: R = Read access; value following dash (−) = value after reset
After exceeding the error passive limit (128), REC is not increased any further.
When a message is received correctly, the counter is set again to a value
between 119 and 127. After reaching the bus-off status, TEC is undefined,
while REC is cleared and its function is changed: It will be incremented after
every 11 consecutive recessive bits on the bus. These 11 bits correspond to
the gap between two telegrams on the bus. If the receive counter reaches 128,
the module changes automatically back to the status bus-on if the ABO bit in
MCR is set. Otherwise, it changes when the recovery sequence of 11 × 128
bits has finished and the CCR bit in the MCR register is reset by the DSP. All
internal flags are reset and the error counters are cleared. The configuration
registers keep the programmed values.
After the power-down mode, the error counters stay unchanged. They are
cleared when entering the configuration mode.
10-34
Interrupt Logic
Mailbox Interrupt
The CPU tried to write to a mailbox but was not allowed to. This event
asserts the Error interrupt.
Wake-up Interrupt
After wake-up, this interrupt is generated. This event asserts the Error
interrupt, even when clocks are not running.
An old message was overwritten by a new one. This event asserts the
Error interrupt.
Bus-Off Interrupt
The CAN module enters the bus-off state. This event asserts the Error
interrupt.
The CAN module enters the error passive mode. This event asserts
the Error interrupt.
One or both of the error counters is greater than or equal to 96. This
event asserts the Error interrupt.
Note: While servicing a CAN interrupt, the user should check all the bits in the
CAN_IFR register to ascertain if more than one bit has been set. The
corresponding interrupt service routines (ISRs) should be executed for all the
set bits. This must be done since the core interrupt will be asserted only once,
even if multiple bits are set in the CAN_IFR register.
The interrupt flag bits are set if the corresponding interrupt condition occurs.
The appropriate mailbox interrupt request is asserted only if the corresponding
interrupt mask in CAN_IMR register is set. The peripheral interrupt request
stays active until the interrupt flag is cleared by the CPU by writing a 1 to the
appropriate bit. An interrupt acknowledge does not clear the interrupt flags.
The MIFx flags cannot be cleared by writing to the IF register; instead, they
must be cleared by writing a 1 to the appropriate TA bit in the TCR register for
a transmit mailbox (mailboxes 2 to 5), or the RMP bit in the RCR register for
the receive mailbox (mailboxes 0 to 3).
In order to recognize future interrupts, the flag bit of the current interrupt(s)
must be cleared immediately upon entering the ISR. One method of
implementing this is to copy the CAN_IFR register in a memory variable and
then clear the set bits in CAN_IFR. The memory variable could then be read
to determine the appropriate routines to be executed.
15−14 13 12 11 10 9 8
Note: R = Read access; C = Clear; value following dash (−) = value after reset
Each of the six mailboxes may initiate an interrupt. These interrupts can be a
receive or a transmit interrupt depending on the mailbox configuration. If one
of the configurable mailboxes is configured as Remote Request Mailbox (AAM
set) and a remote frame is received, a transmit interrupt is set after sending
the corresponding data frame. If a remote frame is sent, a receive interrupt is
set after the reception of the desired data frame.
10-36
Interrupt Logic
There is one interrupt mask bit for each mailbox. If a message is received, the
corresponding RMPn bit in the RCR is set. If a message is sent, the
corresponding TAn bit in the TCR register is set. The setting of the RMPn bit
or the TAn bit also sets the appropriate MIFx flag in the CAN_IFR register if the
corresponding interrupt mask bit is set. The MIFx flag generates an interrupt.
The MIMx mask bits in the CAN_IMR register determine if an interrupt can be
generated by a mailbox.
Bit 7 Reserved.
Note: R = Read access; W = Write access; value following dash (−) = value after reset
Bit 14 Reserved.
Bits 13−8 See section 10.6.1, CAN Interrupt Flag Register (CAN_IFR), on page 10-36.
For the error interrupts RMLIF, AAIF, WDIF, WUIF, BOIF, EPIF, and WLIF.
0 The named interrupts generate high-priority requests.
1 The named interrupts generate low-priority requests.
Bits 6−0 See section 10.6.1, CAN Interrupt Flag Register (CAN_IFR), on page 10-36.
10-38
Configuration Mode
Before the CPU enters its IDLE mode prior to the device low-power mode that
potentially shuts off all device clocks, it must first request a CAN peripheral
power down by writing a 1 to the PDR bit in MCR. If the module is transmitting
a message when PDR is set, the transmission is continued until a successful
transmission, a lost arbitration, or an error condition on the CAN bus line
occurs. Then the PDA is asserted. Thus, the module causes no error condition
on the CAN bus line. When the module is ready to enter the power-down mode,
the status bit PDA is set. The CPU must then poll the PDA bit in GSR, and only
enter IDLE after PDA is set.
On exiting the power-down mode, the PDR flag in the MCR must be cleared
by software, or automatically, if the WUBA bit in MCR is set and there is bus
activity on the CAN bus line. When detecting a dominant signal on the CAN
bus, the wake-up interrupt flag (WUIF) is asserted. The power-down mode is
exited as soon as the clock is switched on. There is no internal filtering for the
CAN bus line.
After leaving the sleep mode with a wake up, the PDR and PDA are cleared.
The CAN error counters remain unchanged.
10-40
Suspend Mode
When the module enters the Soft suspend mode, the status bit SMA (in GSR)
is set. If the module is actually transmitting a message when the SUSPEND
signal is activated, the transmission is continued until a successful
transmission, a lost arbitration, or an error condition on the CAN bus line
occurs. Otherwise, it enters suspend mode immediately and sets the SMA bit.
In Free mode, the peripheral ignores the suspend signal and continues to
operate, receiving and transmitting messages.
Either way, the module causes no error condition on the CAN bus line.
When suspended (in Soft mode), the module does not send or receive any
messages. The module is not active on the CAN bus line. Acknowledge flags
and error flags are not sent. The error counters and all other internal registers
are frozen. Suspend is only asserted when a system is being debugged with
an in-circuit emulator.
The module leaves the suspend mode when the SUSPEND signal is
deactivated. It waits for the next 11 recessive bits on the bus and goes back
to normal operation. This is called the idle mode (different from the CPU’s IDLE
mode). The module waits for the next message or tries to send one itself. When
the module is in bus-off mode, it continues to wait for the bus-on condition. This
occurs when 128 × 11 recessive bits are received. It also counts those that
occurred during the suspend mode.
Note: The clock is not switched off internally for suspend or low-power mode.
For easy reference, Table 10−5 provides a listing of the CAN notation,
definition, and register and bit number.
10-42
Suspend Mode
10-44
Chapter 11
- (-%)
Most conditions that temporarily disrupt chip operation and inhibit proper CPU
function can be cleared and reset by the watchdog function. By its consistent
performance, the watchdog increases the reliability of the CPU, thus ensuring
system integrity.
All registers in this peripheral are eight bits in width and are attached to the
lower byte of the peripheral data bus of the 16-bit CPU.
The only difference between the 240xA WD timer and that of the C240 is the
lack of real-time interrupt capability.
This implementation of the WD timer generates its own watchdog clock locally
by dividing down the CLKOUT from CPU.
Topic Page
11-1
Watchdog Timer Features
6-bit free-running counter that feeds the WD counter via the WD counter
prescale
A WD reset key (WDKEY) register that clears the WD counter when the
correct combination of values are written, and generates a reset if an in-
correct value is written to the register
11-2
Watchdog Timer Features
Register Name
8-bit watchdog
counter 1-cycle PS/257
Prescale delay
CLR
WDKEY.7−0 selection System
reset
Bad key request
Watchdog 55+AA
detector Good
reset key WDCHK2−0
key
register
WDCR.5−3 Bad WDCR key
3
System reset
3
1 0 1
(Constant value)
Writing to bits WDCR.5−3 with anything but the correct pattern (101) generates a system reset.
These prescale values are with respect to the WDCLK signal.
WDCLK = (CLKOUT)/512
WDCLK is seen at the CLKOUT pin only when the watchdog is enabled. If the
watchdog is enabled, the watchdog counter should be reset before it
overflows; otherwise, the DSP will be reset.
Note that the watchdog timer clock does not run when the real-time monitor
is running. This is different from the F/C240.
11-4
Watchdog Timer Operations
The 8-bit WDCNTR can be clocked directly by the WDCLK signal or through
one of six taps from the free-running counter. The 6-bit free-running counter
continuously increments at a rate provided by WDCLK. The WD functions are
enabled as long as WDCLK is provided to the module. Any one of the six taps
(or the direct input from WDCLK) can be selected by the WD prescale select
(bits WDPS2−0) as the input to the time base for the WDCNTR. This prescale
provides selectable watchdog overflow rates of from 3.28 ms to 209.7 ms for
a WDCLK rate of 78125 Hz. While the chip is in normal operating mode, the
free-running counter cannot be stopped or reset, except by a system reset.
Clearing WDCNTR does not clear the free-running counter.
The WDCNTR is reset when the proper sequence is written to the WDKEY
before the WDCNTR overflows. The WDCNTR is reset-enabled when a value
of 55h is written to the WDKEY. When the next AAh value is written to the
WDKEY, then the WDCNTR actually is reset. Any value written to the WDKEY
other than 55h or AAh causes a system reset. Any sequence of 55h and AAh
values can be written to the WDKEY without causing a system reset; only a
write of 55h followed by a write of AAh to the WDKEY resets the WDCNTR.
Step 3 above is the first action that enables the WDCNTR to be reset. The
WDCNTR is not actually reset until step 6. Step 8 re-enables the WDCNTR to
be reset, and step 9 resets the WDCNTR. Step 10 again re-enables the
WDCNTR to be reset. Writing the wrong key value to the WDKEY in step 11
causes a system reset.
A WDCNTR overflow or an incorrect key value written to the WDKEY also sets
the WD flag (WDFLAG). After a reset, the program reads this flag to determine
the source of the reset. After reset, WDFLAG should be cleared by the
software to allow the source of subsequent resets to be determined. WD resets
are not prevented when the flag is set.
11.2.4.3 WD Reset
When the WDCNTR overflows, the WD timer asserts a system reset. Reset
occurs one WDCNTR clock cycle (either WDCLK or WDCLK divided by a
prescale value) later. The reset cannot be disabled in normal operation as long
as WDCLK is present. The WD timer is, however, disabled in the oscillator
power-down mode when WDCLK is not active. For software development or
flash programming purposes, the WD timer can be disabled by setting the
WDDIS bit in the WD control register (WDCR.6). Note that there is no WDDIS
pin in the 240xA devices. The “watchdog override” bit in the SCSR2 register
provides the functionality of the WDDIS pin.
11-6
Watchdog Timer Operations
The check bits are always read as zeros (0002), regardless of what value has
been written to them.
11.2.4.5 WD Setup
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
7028h — Reserved
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
7029h WDCR WDFLAG WDDIS WDCHK2 WDCHK1 WDCHK0 WDPS2 WDPS1 WDPS0
D7 D6 D5 D4 D3 D2 D1 D0
Bits 7−0 D7−D0. Data Values. These read-only data bits contain the 8-bit WD counter
value. Writing to this register has no effect.
11-8
Watchdog Control Registers
The WD reset key register clears the WDCNTR register when a 55h followed
by an AAh is written to WDKEY. Any combination of AAh and 55h is allowed,
but only a 55h followed by an AAh resets the counter. Any other value causes
a system reset.
7 6 5 4 3 2 1 0
D7 D6 D5 D4 D3 D2 D1 D0
Bits 7−0 D7−D0. Data Values. These write-only data bits contain the 8-bit WD reset key
value. When read, the WDKEY register does not return the last key value but
rather returns the contents of the WDCR register.
WDCR contains control bits used for watchdog configuration. These include
flag bits that indicate if the WD timer initiated a system reset; check bits that
assert a system reset if an incorrect value is written to the WDCR register; and
watchdog prescale select bits that select the counter overflow tap which is
used to clock the WD counter.
7 6 5 4 3 2 1 0
Note: R = Read access, C = Clear by writing 1, W = Write access, Wc = Write access conditional on WD OVERRIDE bit being
equal to 1, -0 = value after reset, -x = value after reset determined by action/inaction of WD timer
Bit 7 WDFLAG: Watchdog Flag Bit. This bit indicates if a system reset was asserted
by the WD timer. The bit is set to 1 by a WD-generated reset.
0 Indicates that the WD timer has not asserted a reset since the bit
was last cleared
1 Indicates that the WD timer has asserted a reset since the bit was
last cleared
Bit 6 WDDIS. Watchdog Disable. This bit can be written only when the WD OVER-
RIDE bit in the SCSR2 register is 1.
0 Watchdog is enabled.
1 Watchdog is disabled.
Clearing the WD OVERRIDE bit in the SCSR2 register after disab-
ling the WD would re-enable the WD.
Bit 5 WDCHK2. Watchdog Check Bit 2. This bit must be written as a 1 when you
write to the WDCR register; otherwise, a system reset is asserted. This bit is
always read as 0.
0 System reset is asserted.
1 Normal operation continues if all check bits are written correctly.
Bit 4 WDCHK1. Watchdog Check Bit 1. This bit must be written as a 0 when you
write to the WDCR register; othewise, a system reset is asserted. This bit is
always read as 0.
0 Normal operation continues if all check bits are written correctly.
1 System reset is asserted.
Bit 3 WDCHK0. Watchdog Check Bit 0. This bit must be written as a 1 when you
write to the WDCR register; otherwise, a system reset is asserted. This bit is
always read as 0.
0 System reset is asserted.
1 Normal operation continues if all check bits are written correctly.
11-10
Watchdog Control Registers
Bits 2−0 WDPS2−WDPS0. Watchdog Prescale Select Bits. These bits select the
counter overflow tap that is used to clock the WD counter. Each selection sets
up the maximum time that can elapse before the WD key logic is serviced.
Table 11−3 shows the overflow times for each prescaler setting when the
WDCLK is running at 78125 Hz. Because the WD timer counts 257 clocks be-
fore overflowing, the times given are the minimum for overflow (reset). The
maximum timeout can be up to 1/256 longer than the times listed in Table 11−3
because of the added uncertainty resulting from not clearing the prescaler.
0 1 0 2 152.6 6.6
0 1 1 4 76.3 13.1
1 0 0 8 38.1 26.2
1 0 1 16 19.1 52.4
1 1 0 32 9.5 104.9
1 1 1 64 4.8 209.7
X = Don’t care
† Generated by a 40-MHz clock
This chapter describes the compatibility issues between the 240xA and 240
family of processors.
The software changes required between 240 code and 240xA code have been
kept to a minimum. A majority of the register addresses, bit positions, and
functions are identical between the 240 and 240xA devices.
Topic Page
12-1
General
12.1 General
The 240 is a 5-V part, whereas the 240xA devices operate on 3.3 V.
Low-power mode 2 (HALT) is the lowest power mode on the 240xA. It is similar
to the LPM3 (oscillator power down) on the 240. There is no equivalent to
LPM2 (PLL power down) on the 240. The low-power-mode bits are in a
different register (SCSR1) and in different bit positions on the 240xA.
Illegal address detection does not have 100% coverage on the 240; however,
it does on 240xA devices. Furthermore, an illegal address generates a reset
on the 240, and an NMI on the 240xA. The NMI service routine must poll the
ILLADDR bit in SCSR1 to determine whether the NMI was caused by an illegal
address.
External interrupts XINT2 and XINT3 on the 240 are similar to external
interrupts XINT1 and XINT2 on the 240xA. The addresses of the registers are
different, however, and the general-purpose I/O multiplexing control bits are
located in the digital I/O registers, not in the external interrupt control registers.
The external interrupt flags are cleared by writing a 1 to the flag bit. This is in
order to be consistent with the other peripherals.
The CLOCKOUT control bits are in a different register (SCSR1) and bit
position.
A code security module (CSM) has been added to the 240xA devices.
12-2
Event Manager
Capture 4 on the 240 cannot be used, when porting code from the 240 to
the 240xA.
When porting code from the the 240 to the 240xA, the capture interrupt
code needs to allow for the fact that an interrupt is usually generated after
every second capture and not every capture as on the 240.
The compare mode of the (full) compare units cannot be used; only the
PWM mode can be used.
All general interrupt service routines must be changed to get their periph-
eral interrupt vectors from the PIVR (701Eh) and not one of EVIVRA,
EVIVRB or EVIVRC. Reading from PIVR does not clear interrupt flags. In-
terrupt flags must be cleared manually.
Some code changes are required. This is code that switches the SPI pins
between their SPI functions and their digital I/O functions, and accesses them
in digital I/O mode. When code is ported from 240 to 240xA devices, it must
access the relevant bits in the digital I/O peripheral instead of the SCIPC1 and
SCIPC2 register.
When code is ported from a 240 to a 240xA device, writes of transmit data to
the serial data register, SPIDAT, must be left-justified within a 16-bit register,
not within an 8-bit register.
12-4
Chapter 13
It outlines the points to be considered while migrating from the 24x family to
the 240x/240xA family.
Topic Page
13-1
Introduction
13.1 Introduction
This chapter highlights the major differences (in terms of features/peripherals)
between the 240xA and the 24x (TMS320F243/F241/C242) family of DSP
devices. The 240xA devices share most of the 24x features; however, 240xA
devices have some enhancements. The common features, differences, and
enhancements are described in Table 13−1 and Table 13−2.
13-2
Introduction
2) After reset in the 240x/240xA devices, the clock to all of the peripherals
is disabled. The peripheral clock must be enabled as part of the peripheral
initialization. This requirement does not apply to 24x devices since clock
to the peripherals is always on.
TMS320LF2407A, TMS320LF2406A,
TMS320LF2403A, TMS320LF2402A,
2 On-Chip SARAM TMS320LC2406A, TMS320LC2404A,
TMS320LC2402A DSP Controllers Data Sheet
(literature number SPRS145)
4 ADC Chapter 7
9 PLL Chapter 4
For additional reference materials, see the application report 3.3-V DSP for
Digital Motor Control (literature number SPRA550) or go to http://www.ti.com
and search for a list of 24x application notes.
SARAM −
2K words 2K words 512 words −
Program/Data
PDPINTA, PDPINTA,
PDPINT, XINT1,
External Interrupts PDPINTB, XINT1, PDPINTB, XINT1, PDPINTA, XINT2
XINT2, NMI
XINT2 XINT2
13-4
Memory Map
3FFF
4000
12K Sector
7FFF
8000 6FFF
SARAM 7000
2K words 4K Sector
(Program/Data) 7FFF
87FF
8800
External
(off-chip)
FDFF
FE00
DARAM (B0)
256 words
(CNF=1)
FEFF 32K on-chip Flash memory
FF00 Note: (External if MP/MC = 1)
DARAM (B0)
(CNF=1)
FFFF
Note: When boot ROM is enabled, on-chip locations 0000−00FFh in program memory is mapped to the bootloader. Boot ROM
and Flash Memory share the same starting address, and hence, are not visible (active) at the same time. If the BOOT
EN/XF pin = 0 during reset, the BOOT EN bit in SCSR2 register (bit 3) will be set and enable the Boot ROM at 0000 in
program space. While Boot ROM is enabled, the entire Flash memory will be disabled. The SCSR2.3 bit should be dis-
abled (0) to have Flash array enabled instead of Boot ROM. See Appendix D for bootloader details.
Value
13-6
System Features
240xA devices have a watchdog override bit in the SCSR2 register, which is
similar to the WDDIS pin available on the 24x devices. Refer to the description
of SCSR2 register bit 5 (section 2.2.1 on page 2-3) for details on this bit
function.
Oscillator clock/
External clock
CLKOUT WDCLK
All 240xA devices have a clock-enable bit in the SCSR1 register to save power
and selectively enable peripheral functions. At reset, these peripheral
clock-enable bits are disabled, and the applications software should enable
the required modules. The peripheral clocks of the following peripherals can
be independently enabled/disabled. See section 2.2.1 on page 2-3 for bit
descriptions of the SCSR1 register.
240xA devices have two system control and status registers: SCSR1 and
SCSR2 (see section 2.2.1 on page 2-3). These registers have control and
status bits for several on-chip modules. These register bits should be
initialized after reset to enable/disable on-chip functionality for the selected
application. 24x has only one SCSR register and all its on-chip peripherals are
powered up after reset. The SCSR2 register is unique to 240xA and its
peripherals are disabled after reset.
During the Reset phase (i.e., RS low), this pin functions as a Boot EN input pin,
and its logic level is latched into bit 3 of the SCSR2 register. If the bit is set to 1,
Boot ROM is active.
At the completion of the reset phase (rising edge of RS), this pin will be XF
output (external flag) function, and the Boot EN function is no longer available
through this pin. However, the Boot EN bit in SCSR2 can be used to control
the visibility of the Boot ROM or the Flash array.
SCSR2 Boot En
Boot EN
Boot EN/XF
pin
XF (from core)
RS
13-8
System Features
LF2407 is the only device that supports external memory interface (XMIF) to
expand the internal memory space with the addition of external memory
devices. The interface offers decode signals for Program, Data, and I/O space.
LF2407 external memory interface signals have critical timings while
interfacing zero-wait-state memory at higher CPU clock speeds. CPU memory
reads are single-cycle and read-enable (RD) timing is critical to meet the
output-enable timing for memories that can be interfaced to this device. To
alleviate the memory read interface timing, an additional signal W/R is
provided to be used as output-enable signal instead of RD. W/R is essentially
an inverted R/W signal from the core.
In the LF2407A device, the W/R signal will remain low all the time after reset
and will go high during external write cycles. In other LF240xA devices, the
W/R signal will remain low all the time after reset until the application
configures it as a GPIO pin and drives it to the desired level. During reset, this
pin floats and gets pulled up by the internal pullup circuitry. If an application
needs this pin to be low even during reset, then an external pulldown resistor
may be added.
In LC240xA devices, the W/R signal will remain “pulled up” all the time from
reset until the application configures it as a GPIO pin and drives it to the desired
level.
Address bus
A0−A15
C2xx
CPU
core
Data bus
D0−D15
XMIF
module
Control bus
PS, DS, IS,
STRB,
R/W, WR
RD
RD
R/W
W/R/IOPC0
LF2407 DSP
13-10
Digital I/O (GPIO Pins)
Note that when multiplexed I/O pins are in input mode, the pin is connected
to both the I/O data register and the shared peripheral. The I/O Mux control
register (MCRx) in 240xA devices is synonymous to the OCRx in 24x devices.
Both MCRx and OCRx have the same function in 240xA and 24x devices,
respectively.
13.5.1 Digital I/O and Shared Pin Functions for the 240xA
LF2407 device has a total of 41 pins shared between primary functions and
I/Os.
Table 13−7 lists all the pins that are shared between the primary functions and
the dedicated I/O Ports A, B, C, D, E, F.
13-12
Digital I/O (GPIO Pins)
Table 13−8. Event Manager Module and Signal Names for EVA and EVB
13-14
240xA-24x Family Compatibility 13-15
Appendix
AppendixAA
* 1
A-1
Changes Made in This Revision
Page Additions/Modifications/Deletions
5-7 Changed secondary pin function of Bit 14, IOPF6 in the MCRC Register to reserved
A-2
Changes Made in This Revision
Page Additions/Modifications/Deletions
6-71 Added a sentence to the fifth (second on page 6-71) bullet in Section 6.8.1, Capture Unit
Features
6-72 Changed the CAPQEPN field (14:13) to CAP12EN bit in Figure 6−32
Deleted “and QEP circuit” from description of Bit 15 in CAPCONA Register (Figure 6−32)
6-74 Changed name and description of Bits 14−13 of CAPCONB Register (Figure 6−30)
6-82, Modified lists in Section 6.9.5, Register Setup for the QEP Circuit
6-83
7-2 Modified second bullet item (conversion time rates) in Section 7.1, Features
8-28 Modified first paragraph of Section 8.7.5, Receiver Status Register (SCIRXST)
10-27 Modified descriptions for Bits 10−0 in BCR1 Register (Figure 10−16)
Page Additions/Modifications/Deletions
11-10 Changed description of Bit 6 in the WDCR Register (Figure 11−4) and changed reset information
on bits 5:3
12-2 Added new first paragraph and new last paragraph to Section 12.1
12-3 Added a new bullet item to port code instructions in Section 12.2
A-4
Appendix
AppendixBA
Table B−1 starting on page B-2 shows the peripheral register map for 240xA
devices. The shaded table entries represent the registers that are in addition
to the 24x registers. These additions are also explained in the data sheet titled
TMS320LF2407A, TMS320LF2406A, TMS320LF2403A, TMS320LF2402A,
TMS320LC2406A, TMS320LC2404A, TMS320LC2402A DSP Controllers
(literature number SPRS145), and TMS320LF2401A DSP Controller
(literature number SPRS161). Note that:
The ADC registers are completely different from those in the 24x.
The ADC register map has been moved from 7030h to 70A0h.
Table B−2 on page B-9 shows the code security module (CSM) registers.
B-1
Summary of Programmable Registers on the 240xA
B-2
Summary of Programmable Registers on the 240xA
B-4
Summary of Programmable Registers on the 240xA
B-6
Summary of Programmable Registers on the 240xA
B-8
Summary of Programmable Registers on the 240xA
Data Memory
Address Register Name Reset Values Register Description
KEY registers − Accessible by the user
B-10
Appendix
AppendixCA
$
A brief introduction to the tools used for generating executable COFF files
that run on the 240xA devices.
This appendix is not intended to teach you how to use the software
development tools. The following documents cover these tools in detail:
Topic Page
C-1
About
About These
These Program
Program Examples
Examples
Note:
The procedure here applies to the PC development environment and is giv-
en only as an example.
Step 1
Using any ASCII editor, create source program
test.asm
and command file
240xA.cmd
C-2
About These Program Examples
240xA.h Header file that designates labels for the addresses of the various registers.
REM_ANS.asm Programs that perform RTR (Remote Transmission Request) operations in the
REM_REQ.asm CAN module
MEMORY
{
SECTIONS
C-4
Program Examples
;************************************************************************
; File name: 240x.h
;
; Description: 240x register definitions, Bit codes for BIT instruction
;************************************************************************
; ADC registers
; SPI registers
; SCI registers
C-6
Program Examples
; CAN registers
C-8
Program Examples
;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
; I/O space mapped registers
;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
WSGR .set 0FFFFh ; Wait-State Generator Control register
FCMR .set 0FF0Fh ; Flash control mode register
;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
; Bit codes for Test bit instruction (BIT) (15 Loads bit 0 into TC)
;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
BIT15 .set 0000h ; Bit Code for 15
BIT14 .set 0001h ; Bit Code for 14
BIT13 .set 0002h ; Bit Code for 13
BIT12 .set 0003h ; Bit Code for 12
BIT11 .set 0004h ; Bit Code for 11
BIT10 .set 0005h ; Bit Code for 10
C-10
Program Examples
;************************************************************
; File name: vector.h
; Interrupt Vector declarations
; This section contains the vectors for various interrupts in
; the ’240x. Unused interrupts are shown to branch to a ”phantom”
; interrupt service routine which loops on itself. Users should
; replace the label PHANTOM with the label of their interrupt
; subroutines in case these interrupts are used.
;************************************************************
.sect ”vectors”
RSVECT B START ; Reset Vector
INT1 B GISR1 ; Interrupt Level 1
INT2 B GISR2 ; Interrupt Level 2
INT3 B GISR3 ; Interrupt Level 3
INT4 B GISR4 ; Interrupt Level 4
INT5 B GISR5 ; Interrupt Level 5
INT6 B GISR6 ; Interrupt Level 6
RESERVED B PHANTOM ; Reserved
SW_INT8 B PHANTOM ; Software Interrupt
SW_INT9 B PHANTOM ; Software Interrupt
SW_INT10 B PHANTOM ; Software Interrupt
SW_INT11 B PHANTOM ; Software Interrupt
SW_INT12 B PHANTOM ; Software Interrupt
SW_INT13 B PHANTOM ; Software Interrupt
SW_INT14 B PHANTOM ; Software Interrupt
SW_INT15 B PHANTOM ; Software Interrupt
SW_INT16 B PHANTOM ; Software Interrupt
TRAP B PHANTOM ; Trap vector
NMI B NMI ; Non−maskable Interrupt
EMU_TRAP B PHANTOM ; Emulator Trap
SW_INT20 B PHANTOM ; Software Interrupt
SW_INT21 B PHANTOM ; Software Interrupt
SW_INT22 B PHANTOM ; Software Interrupt
SW_INT23 B PHANTOM ; Software Interrupt
SW_INT24 B PHANTOM ; Software Interrupt
SW_INT25 B PHANTOM ; Software Interrupt
SW_INT26 B PHANTOM ; Software Interrupt
SW_INT27 B PHANTOM ; Software Interrupt
SW_INT28 B PHANTOM ; Software Interrupt
SW_INT29 B PHANTOM ; Software Interrupt
SW_INT30 B PHANTOM ; Software Interrupt
SW_INT31 B PHANTOM ; Software Interrupt
; Code−security passwords are stored from 40h − 43h
.word 0000h ; Replace values with
.word 0000h ; code−security passwords
.word 0000h
.word 0000h
;=================================================================================
* File Name: SPI.asm
* Description: PROGRAM TO OUTPUT SERIAL DATA THROUGH THE SPI PORT
* This program outputs a set of incrementing words (that roll over) through
* the SPI. If a Digital−to−analog (DAC) converter is connected to the SPI,
* the DAC outputs a sawtooth waveform. The program sends data to the serial DAC
* by means of the SPI. For this example, the TLC5618 serial DAC from TI was used.
;=================================================================================
.include 240xA.h
.include vector.h
;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
; Variable Declarations for on chip RAM Blocks
;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
.bss GPR0,1 ;General purpose registers.
.bss GPR3,1
;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
; M A C R O − Definitions
;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
KICK_DOG .macro ;Watchdog reset macro
LDP #00E0h
SPLK #05555h, WDKEY
SPLK #0AAAAh, WDKEY
LDP #0h
.endm
;===========================================================================
; M A I N C O D E − starts here
;===========================================================================
.text
START: LDP #0
SETC INTM ;Disable interrupts during initialization.
SPLK #0h,GPR3
OUT GPR3,WSGR ;Set XMIF to run with no wait states.
CLRC SXM ;Clear Sign Extension Mode
CLRC OVM ;Reset Overflow Mode
CLRC CNF ;Config Block B0 to Data mem.
LDP #WDCR>>7
SPLK #006Fh,WDCR ;Disable WD
KICK_DOG
LDP #SCSR1>>7 ;Set PLL for x4 mode
SPLK #0020h,SCSR1 ;Enable clock to SPI module
C-12
Program Examples
;===========================================================================
; SPI Initialization
;===========================================================================
SPI_INIT: LDP #SPICCR>>7
SPLK #000Fh, SPICCR ;16 char bits,
SPLK #0006h, SPICTL ;Enable master mode, normal clock
;and enable talk.
SPLK #0002h, SPIBRR ;Set up the SPI to max speed.
LDP #MCRB>>7 ;Set up the GPIO pins to function
SPLK #003CH, MCRB ;as SPI pins
LDP #SPICCR>>7
SPLK #008Fh, SPICCR ;Relinquish SPI from Reset.
;===========================================================================
; This section generates the sawtooth by ramping a counter down to zero
; reloading it every time it under−flows.
;===========================================================================;
LP: LAR AR0,#07FEh ;Load AR0 with a count
XMIT_VALUE: LDP #0
SAR AR0,GPR0
LACC GPR0
ADD #8000H ;MSB should be one (DAC requirement)
XOR #07FFH ;To change the direction of counting to
;upward
LDP #SPITXBUF>>7
SACL SPITXBUF ;Write xmit value to SPI Trasmit Buffer.
LDP #SPISTS>>7
XMIT_RDY: BIT SPISTS,BIT6 ;Test SPI_INT bit
BCND XMIT_RDY, NTC ;If SPI_INT=0,then repeat loop
;i.e. wait for the completion of
;transmission.
LDP #SPIRXBUF>>7 ;else read SPIRXBUF
LACC SPIRXBUF ;dummy read to clear SPI_INT flag.
MAR *,AR0
BANZ XMIT_VALUE ;xmit next value, if counter is non zero.
B LP ;if counter reaches zero repeat loop
;re−loading the counter.
PHANTOM RET
GISR1 RET
GISR2 RET
GISR3 RET
GISR4 RET
GISR5 RET
GISR6 RET
;===========================================================================
* File Name: SCI.asm
* Description: PROGRAM TO PERFORM A LOOPBACK IN THE SCI MODULE
* This program is capable of doing either an internal loopback or an external
* loopback, depending on the value written in SCICCR. SCITXD−SCIRXD pins
* should be connected together, if external loopback is desired. This is not
* required for an internal loopback. The SCI receives the bit−stream and stores
* the received data in memory (60h and above) for verification.
* An 8 bit value is transmitted through the SCITXD pin at a baud rate of
* 9600 bits/sec. A counter is used to determine how many times data is
* transmitted and received.
* This code is useful to determine the health of the SCI hardware quickly
* without the aid of any other equipment.
;===========================================================================
.include 240x.h
;===========================================================================
;SCI TRANSMISSION TEST − starts here
;===========================================================================
LDP #SCICCR>>7
SPLK #17h, SCICCR ; 17 for internal loopback
; 07−External
; 1 stop bit,odd parity,8 char bits,
; async mode, idle−line protocol
SPLK #0003h, SCICTL1 ; Enable TX, RX, internal SCICLK,
; Disable RX ERR, SLEEP, TXWAKE
SPLK #0000h, SCICTL2 ; Disable RX & TX INTs
C-14
Program Examples
XMIT_RDY:
BIT SCICTL2,BIT7 ; Test TXRDY bit
BCND XMIT_RDY,NTC ; If TXRDY=0,then repeat loop
RCV_RDY:
BIT SCIRXST,BIT6 ; Test TXRDY bit
BCND RCV_RDY,NTC ; If RXRDY=0,then repeat loop
READ_CHR:
LACL *,AR3 ; The received (echoed) character is
; stored in 60h
SACL *+,AR2 ; This loop is executed 20h times
BANZ XMIT_CHAR ; Repeat the loop again
;===========================================================================
* File Name: PC−ECHO.asm
* Description: PROGRAM TO ECHO RECEIVED CHARACTERS BACK TO THE SOURCE
* The SCI is set up to bounce back any character received through the
* serial link. When connected to a PC (running a terminal emulation program),
* the PC sees the transmitted characters bounce back.
* This code is useful to determine the health of the communication channel
* between the SCI and any other serial device, such as PC’s serial port.
;===========================================================================
.include 240x.h
;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
; M A C R O − Definitions
;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
KICK_DOG .macro ;Watchdog reset macro
LDP #00E0h
SPLK #05555h, WDKEY
SPLK #0AAAAh, WDKEY
LDP #0h
.endm
;================================================================
; M A I N C O D E − starts here
;================================================================
.text
START:
LDP #0
SPLK #0,60h
OUT 60h,WSGR ; Set XMIF to run w/no wait states
SETC INTM ; Disable interrupts
LDP #00E0h
SPLK #0040h,SCSR1 ; Enables clock to the SCI module
;=============================================================
;SCI TRANSMISSION TEST − starts here
;=============================================================
SCI:
LDP #0E1h
SPLK #0003h,MCRA
LAR AR1, #SCIRXBUF ;Load AR1 with SCI_RX_BUF address
LAR AR0, #SCITXBUF ;Load AR0 with SCI_TX_BUF address
LARP AR0
LDP #0E0h
SPLK #0007h, SCICCR ;1 stop bit,No parity,8 char bits,
;async mode, idle−line protocol
SPLK #0003h, SCICTL1 ;Enable TX, RX, internal SCICLK,
;Disable RX ERR, SLEEP, TXWAKE
SPLK #0000h, SCICTL2 ; Disable RX & TX INTs
* Baud rate prescaler values for 240x devices running @ 40 MHz.
C-16
Program Examples
;============================================================================*
* File name : ADC.asm *
* Description : PROGRAM TO INITIALIZE THE ADC MODULE OF 240xA *
* This program initializes the ADC module of the 240xA and does a conversion*
* of all the analog input channels. The results of the conversion are *
* available in the RESULTSn register, which can be accessed by the user *
* application. The ADC operates as one 16−state sequencer & the conversions *
* are stopped once the sequencer reaches EOS (End of sequence) *
;============================================================================*
.title ”ADC”
;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
; M A C R O − Definitions
;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
KICK_DOG .macro ; Watchdog reset macro
LDP #00E0h ; DP−−>7000h−707Fh
SPLK #05555h, WDKEY
SPLK #0AAAAh, WDKEY
LDP #0h ; DP−−>0000h−007Fh
.endm
.text
START: LDP #0h ; Set DP=0
SETC INTM ; Disable interrupts
CLRC SXM
SPLK #0000h,IMR ; Mask all core interrupts
LACC IFR ; Read Interrupt flags
SACL IFR ; Clear all interrupt flags
LDP #00E0h ; (E0=224)(E0*80=7000)
SPLK #006Fh, WDCR ; Disable WD
SPLK #0080h,SCSR1 ; Enable clock to ADC module
KICK_DOG
SPLK #0h,GPR0 ; Set wait state generator for:
OUT GPR0,WSGR ; Program Space, 0−7 wait states
LDP #0E1h
SPLK #0100000000000000b,ADCTRL1 ; Reset ADC module
NOP
SPLK #0011000000010000b,ADCTRL1 ; Take ADC out of reset
; ||||||||||||||||
; 5432109876543210
; 15 − RSVD | 14 − Reset(1) | 13,12 − Soft & Free
; 11,10,9,8 − Acq.prescalers | 7 − Clock prescaler
; 6 − Cont.run (1) | 5 − Int.priority (Hi.0)
; 4 − Seq.casc (0−dual)
C-18
Program Examples
* Program the conversion sequence. This is the sequence of channels that will
* be used for the 16 conversions.
RPT #8
NOP
;=========================================================================
* File name : GPIO_OUT.asm
* Description : PROGRAM TO CHECK THE GPIO PINS OF 240xA as outputs *
* This program writes a running pattern of 0’s to the GPIO pins of 240xA*
* It ouputs a total of 8 bit patterns to the five GPIO ports (A,B,C,E,F) *
* Each bit pattern forces a particular bit low and forces the other 7 *
* bits high. This goes on in an endless loop. *
;=========================================================================
.include 240xA.h
;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
; M A C R O − Definitions
;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
KICK_DOG .macro ;Watchdog reset macro
LDP #00E0h ;DP−−>7000h−707Fh
SPLK #05555h, WDKEY
SPLK #0AAAAh, WDKEY
LDP #0h ;DP−−>0000h−007Fh
.endm
.text
START: LDP #0h ; Set DP=0
SETC INTM ; Disable interrupts
SETC CNF
SPLK #0000h,IMR ; Mask all core interrupts
LACC IFR ; Read Interrupt flags
SACL IFR ; Clear all interrupt flags
LDP #00E0h ; (E0=224)(E0*80=7000)
SPLK #0000h,SCSR1
SPLK #006Fh, WDCR ; Disable WD
KICK_DOG
SPLK #0h,GPR0 ; Set wait state generator for
OUT GPR0,WSGR ; external address space
LDP #00E1h
SPLK #00000h,MCRA ; Select IOPAn & IOPBn as GPIO pins
SPLK #0FF00h,MCRB ; Select IOPCn as GPIO pins
SPLK #00000h,MCRC ; Select IOPEn & IOPFn as GPIO pins
C-20
Program Examples
MAIN LDP #0
LAR AR0,#300h ; AR0 points to bit pattern in
; data memory
LAR AR1,#7 ; AR1 is the counter
;=========================================================================
* File name : GPIO_IN.asm *
* Description : PROGRAM TO CHECK GPIO PINS OF 240xA as inputs *
* All GPIO bits are programmed as inputs and the values read from the *
* GPIO pins are written in 60h,61h,62h,63h,64h of Data memory *
;=========================================================================
.include 240xA.h
;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
; M A C R O − Definitions
;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
KICK_DOG .macro ; Watchdog reset macro
LDP #00E0h ; DP−−>7000h−707Fh
SPLK #05555h, WDKEY
SPLK #0AAAAh, WDKEY
LDP #0h ; DP−−>0000h−007Fh
.endm
.text
START: LDP #0h ; Set DP=0
SETC INTM ; Disable interrupts
SETC CNF
SPLK #0000h,IMR ; Mask all core interrupts
LACC IFR ; Read Interrupt flags
SACL IFR ; Clear all interrupt flags
LDP #00E0h ; (E0=224)(E0*80=7000)
SPLK #006Fh, WDCR ; Disable WD
SPLK #0,SCSR1 ; Put PLL in x4 mode.
KICK_DOG
SPLK #0h,GPR0 ; Set wait state generator for
OUT GPR0,WSGR ; external address space.
LDP #00E1h
SPLK #00000h,MCRA ; Select IOPAn & IOPBn as GPIO pins
SPLK #0FF00h,MCRB ; Select IOPCn as GPIO pins
SPLK #00000h,MCRC ; Select IOPEn & IOPFn as GPIO pins
LACL PADATDIR
SACL *+
C-22
Program Examples
LACL PBDATDIR
SACL *+
LACL PCDATDIR
SACL *+
LACL PEDATDIR
SACL *+
LACL PFDATDIR
SACL *+
B MAIN
PHANTOM
B PHANTOM
C-24
Program Examples
; FEDCBA9876543210
;**************************************************************************
;*********** Write CAN Mailboxes **********
;**************************************************************************
LDP #DP_CAN2
SPLK #1011111111111111b,CANMSGID2H
; ||||||||||||||||
; FEDCBA9876543210
;bit 0−12 upper 13 bits of extended identifier
;bit 13 Auto answer mode bit
;bit 14 Acceptance mask enable bit
;bit 15 Identifier extension bit
SPLK #1111111111111111b,CANMSGID2L
; ||||||||||||||||
; FEDCBA9876543210
;bit 0−15 lower part of extended identifier
SPLK #0000000000001000b,CANMSGCTRL2
; ||||||||||||||||
; FEDCBA9876543210
;bit 0−3 Data length code: 1000 = 8 bytes
;bit 4 0: data frame
LDP #DP_CAN
SPLK #0000000100000000b,CANMCR ; Set CDR bit before writing
; ||||||||||||||||
; FEDCBA9876543210
LDP #DP_CAN2
SPLK #0BEBEh,CANMBX2A ; Message to transmit
SPLK #0BABAh,CANMBX2B
SPLK #0DEDEh,CANMBX2C
SPLK #0DADAh,CANMBX2D
LDP #DP_CAN
SPLK #0000000000000000b,CANMCR ; Clear CDR bit after writing
; ||||||||||||||||
; FEDCBA9876543210
;**************************************************************************
;*********** Enable Mailbox **********
;**************************************************************************
SPLK #0000000000000100b,CANMDER
; ||||||||||||||||
; FEDCBA9876543210
;bit 0−5 Enable MBX2
;bit 6 MBX2 configured as Transmit MBX
;**************************************************************************
;*********** Bit timing Registers configuration **********************
;**************************************************************************
SPLK #0001000000000000b,CANMCR
; ||||||||||||||||
; FEDCBA9876543210
;bit 12 Change configuration request for write−access to BCR (CCR=1)
W_CCE BIT CANGSR,#0Bh ; Wait for Change config Enable
BCND W_CCE,NTC ; bit to be set in GSR
;SPLK #0000000000000000b,CANBCR2 ; For 1 Mbps @ 20 MHz CLKOUT
SPLK #0000000000000001b,CANBCR2 ; For 1 Mbps @ 40 MHz CLKOUT
; ||||||||||||||||
; FEDCBA9876543210
C-26
Program Examples
This program transmits a remote frame and expects a data frame in response.
Transmission of a remote frame by (and reception of the data frame in) MBX3. To be
used along with REM−ANS.asm
;==============================================================================
* File name : REM_REQ.asm *
* PROGRAM TO TRANSMIT A REMOTE FRAME REQUEST IN THE 24x/240xA CAN
* This program transmits a remote frame and expects a data frame in response
* Transmission of a remote frame by (and reception of the data frame in) MBX3
* To be used along with REM−ANS.asm
;==============================================================================
; M A I N C O D E − starts here
;==============================================================================
.text
START: KICK_DOG ; Reset Watchdog counter
SPLK #0,60h
OUT 60h,WSGR ; Set waitstates for external memory (if used)
SETC INTM ; Disable interrupts
SPLK #0000h,IMR ; Mask all core interrupts
LDP #0E0h
SPLK #006Fh, WDCR ; Disable WD
SPLK #0010h,SCSR1 ; Enable clock to CAN module (For 240xA only)
LDP #225
SPLK #00C0H,MCRB ; Configure CAN pins
LDP #DP_CAN
SPLK #1011111111111111b,CANIMR ; Enable all CAN interrupts
;**************************************************************************
;****** DISABLE MBX BEFORE WRITING TO MSGID/MSGCTRL OF MBX3 **********
;**************************************************************************
SPLK #0000000000000000b,CANMDER
; ||||||||||||||||
; FEDCBA9876543210
;**************************************************************************
;*********** Write CAN Mailboxes **********
;**************************************************************************
LDP #DP_CAN2
SPLK #1001111111111111b,CANMSGID3H
; ||||||||||||||||
; FEDCBA9876543210
;bit 0−12 upper 13 bits of extended identifier
;bit 13 Auto answer mode bit
;bit 14 Acceptance mask enable bit
;bit 15 Identifier extension bit
SPLK #1111111111111111b,CANMSGID3L
; ||||||||||||||||
; FEDCBA9876543210
;bit 0−15 lower part of extended identifier
SPLK #0000000000011000b,CANMSGCTRL3
; ||||||||||||||||
; FEDCBA9876543210
;bit 0−3 Data length code. 1000 = 8 bytes
;bit 4 1: Remote frame
;**************************************************************************
;*********** Enable Mailbox **********
;**************************************************************************
LDP #DP_CAN
SPLK #0000000010001000b,CANMDER
; ||||||||||||||||
; FEDCBA9876543210
;bit 0−5 enable mailbox 3
;bit 7 1: mailbox 3 = receive
;**************************************************************************
;*********** Bit timing Registers configuration **********************
;**************************************************************************
SPLK #0001000000000000b,CANMCR
; ||||||||||||||||
; FEDCBA9876543210
;bit 12 Change configuration request for write−access to BCR (CCR=1)
W_CCE BIT CANGSR,#0Bh ; Wait for Change config Enable
BCND W_CCE,NTC ; bit to be set in GSR
;SPLK #0000000000000000b,CANBCR2 ; For 1 Mbps @ 20 MHz CLKOUT
SPLK #0000000000000001b,CANBCR2 ; For 1 Mbps @ 40 MHz CLKOUT
; ||||||||||||||||
; FEDCBA9876543210
; bit 0−7 Baud rate prescaler
; bit 8−15 Reserved
SPLK #0000000011111010b,CANBCR1 ; For 1 Mbps @ 85 % samp. pt
; ||||||||||||||||
; FEDCBA9876543210
; bit 0−2 TSEG2
; bit 3−6 TSEG1
; bit 7 Sample point setting (1: 3 times, 0: once)
; bit 8−9 Synchronization jump width
; bit A−F Reserved
SPLK #0000000000000000b,CANMCR
; ||||||||||||||||
; FEDCBA9876543210
C-28
Program Examples
;**************************************************************************
;*********** TRANSMIT **********
;**************************************************************************
SPLK #0020h,CANTCR ; Transmit request for MBX3
W_TA BIT CANTCR,2 ; Wait for transmission acknowledge
BCND W_TA,NTC
SPLK #2000h,CANTCR ; reset TA
RX_LOOP:
W_RA BIT CANRCR,BIT7 ; Wait for data from remote node
BCND W_RA,NTC ; to be written into MBX3
LOOP B LOOP
GISR1:
GISR2:
GISR3:
GISR4:
GISR5:
GISR6:
PHANTOM RET
.end
;=========================================================================
* File name : EV_T1INT.asm *
* Description : PROGRAM TO CHECK THE OPERATION OF TIMER1 IN EVA *
* Mode: Continous Up/Down counting, x/128 *
* Output: OF,UF,CMPR & PERIOD interrupts that toggles IOPB0,1,2,3 *
;=========================================================================
;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
; M A C R O − Definitions
;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
KICK_DOG .macro ;Watchdog reset macro
LDP #00E0h ;DP−−>7000h−707Fh
SPLK #05555h, WDKEY
SPLK #0AAAAh, WDKEY
LDP #0h ;DP−−>0000h−007Fh
.endm
.text
SPLK #1111111111111111b,T1PR
SPLK #0000000011111111b,T1CMPR
SPLK #0000011110000000b,EVAIMRA
; Enable OV,U,C,P interrupt bits
C-30
Program Examples
SPLK #0000011110000000b,EVAIFRA
; clear interrupts
LDP #0
SPLK #0000000000000010b,IMR ; Enable INT2
CLRC INTM
SISR2a:
LDP #0E1h ; Peripheral page
SPLK #0FF01h,PBDATDIR ; Set IOPB0
CALL DELAY
LDP #GPTCONA >> 7h ; Peripheral page
LACC #0400h ; clear overflow int. flag
SACL EVAIFRA ; in EVAIFRA
CLRC INTM ; Enable all interrupts
RET
SISR29:
LDP #0E1h ; Peripheral page
SPLK #0FF02h,PBDATDIR ; Set IOPB1
CALL DELAY
LDP #GPTCONA >> 7h ; Peripheral page
LACC #0200h ; clear underflow int. flag
SACL EVAIFRA ; in EVAIFRA
CLRC INTM ; Enable all interrupts
RET
SISR28:
LDP #0E1h ; Peripheral page
SPLK #0FF04h,PBDATDIR ; Set IOPB2
CALL DELAY
LDP #GPTCONA >> 7h ; Peripheral page
LACC #0100h ; clear compare int. flag
SACL EVAIFRA ; in EVAIFRA
CLRC INTM ; Enable all interrupts
RET
SISR27:
LDP #0E1h ; Peripheral page
SPLK #0FF08h,PBDATDIR ; Set IOPB3
CALL DELAY
LDP #GPTCONA >> 7h ; Peripheral page
LACC #0080h ; clear period int. flag
SACL EVAIFRA ; in EVAIFRA
CLRC INTM ; Enable all interrupts
RET
GISR1: RET
GISR3: RET
GISR4: RET
GISR5: RET
GISR6: RET
PHANTOM RET
.end
C-32
Program Examples
;===========================================================================
* File name : CAP.asm *
* Description : PROGRAM TO CHECK THE CAPTURE UNITS OF 240X *
* This program checks the Capture units of EVA & EVB. On each EV module, *
* the capture units are setup to detect different transitions. On EVA, *
* CAP1 detects a rising edge, CAP2 detects a falling edge and CAP3 detects *
* both edges. All capture interrupts are enabled. Timers 1 & 2 provide *
* input signals (through external connections) and also serve as a *
* time−base for these capture units. Upon detection, the capture interrupt *
* reads the proper CAPFIFO value to ensure that the capture units detected *
* the correct transition. The same scheme is implemented on EVB, to check *
* CAP4,5 and 6 using Timers 3 and 4. *
;===========================================================================
.text
START: LDP #0h ; set DP=0
SETC INTM ; Disable interrupts
SPLK #0000h,IMR ; Mask all core interrupts
LACC IFR ; Read Interrupt flags
SACL IFR ; Clear all interrupt flags
LDP #WDKEY >> 7h ; Peripheral page
SPLK #006Fh, WDCR ; Disable WD if VCCP=5V
LDP #SCSR1>>7
SPLK #000Ch,SCSR1 ; EVA & EVB modules clock enable
*=====================================================================
* EVA Capture test
* This portion of the code tests the EVA Capture unit. It is assumed
* that the test is failed, unless an interrupt is called (error code 4)
* GISR4 verifies the values in CAPFIFO and reports the results.
SPLK #1111111111111111b,T1PR
SPLK #0011111100000000b,T1CMPR
SPLK #0011111100000000b,T2CMPR
SPLK #0000000000000000b,EVAIMRA
SPLK #0000000000000000b,EVAIMRB
; disable group A,B interrupts
C-34
Program Examples
SPLK #0011001001101100b,CAPCONA
; 0 clear capture registers
; 01−enable Capture 1,2 disable QEP
; 1 −enable Capture 3
; 0 −reserved
; 0 −Use GPTimer 2 for CAP3
; 1 −Use GPTimer 1 for CAP1,2
; 0 −No ADC start on CAP3 interrupt
; 01 −CAP1 is rising edge detect
; 10 −CAP2 is falling edge detect
; 11 −CAP3 on both edges
; 00 −reserved
SPLK #0000000000000111b,EVAIMRC
; 0000 0000 0000 0
; 111, enable CAP3,CAP2,CAP1
; interrupts
LDP #0
SPLK #0000000000001000b,IMR ; Enable INT4
CLRC INTM ; Enable interrupts globally
CALL CAPDLY
*=====================================================================
* EVB Capture test
* This portion of the code tests the EVB Capture unit. It is assumed
* that the test is failed, unless an interrupt is called (error code 4)
* GISR4 verifies the values in CAPFIFO and reports the results.
; 10 − T2 CMP active hi
; 01 − T1 CMP active lo
SPLK #0000000000000000b,T3CNT ; zero timer 3 count
SPLK #0000000000000000b,T4CNT ; zero timer 4 count
SPLK #0001011101000010b,T3CON
; 000 10 Cont, Up
; 111 x/128,
; 0 reserved for T3,Tenable select
; 1 Tenable for Timer 3
; 00 Internal clk
; 00 cntr =0
; 1 enable compare
; 0 use own period register
SPLK #0001011111000011b,T4CON
; TSWT3=1: Use Timer 3 tenable bit
; SELT3PR=1: Use Timer 3 period
; register
SPLK #1111111111111111b,T3PR
SPLK #0011111100000000b,T3CMPR
SPLK #0011111100000000b,T4CMPR
SPLK #0000000000000000b,EVBIMRA
SPLK #0000000000000000b,EVBIMRB
; disable group A,B interrupts
SPLK #0011001001101100b,CAPCONB
; 0 clear capture registers
; 01−enable Capture 4,5 disable QEP
; 1 −enable Capture 6
; 0 −reserved
; 0 −Use GPTimer 4 for CAP6
; 1 −Use GPTimer 3 for CAP4,5
; 0 −No ADC start on CAP6 interrupt
; 01 −CAP4 is rising edge detect
; 10 −CAP5 is falling edge detect
; 11 −CAP6 on both edges
; 00 −reserved
SPLK #0000000000000111b,EVBIMRC
; 0000 0000 0000 0
; 111, enable CAP6,CAP5,CAP4
; interrupts
CALL CAPDLY
C-36
Program Examples
;=====================================================================
; Exit routine
;=====================================================================
LDP #0h
SPLK #0h,IMR ; Mask all interrupts
LACC IFR ; Read Interrupt flags
SACL IFR ; Clear all interrupt flags
SETC INTM
LDP #EVAIMRA>>7 ; Peripheral page
SPLK #0h,EVAIMRA ; Mask all EVA interrupts
SPLK #0h,EVAIMRB
SPLK #0h,EVAIMRC
SPLK #0FFFFh,EVAIFRA ; clear all EVA interrupt flags
SPLK #0FFFFh,EVAIFRB
SPLK #0FFFFh,EVAIFRC
LDP #EVBIMRA>>7 ; Peripheral page
SPLK #0h,EVBIMRA ; Mask all EVB interrupts
SPLK #0h,EVBIMRB
SPLK #0h,EVBIMRC
SPLK #0FFFFh,EVBIFRA ; clear all EVB interrupt flags
SPLK #0FFFFh,EVBIFRB
SPLK #0FFFFh,EVBIFRC
LDP #SCSR1>>7
SPLK #0000h,SCSR1 ; disable EVA & EVB clocks
LDP #GPTCONA>>7
SPLK #0000000000000000b,T1CON
SPLK #0000000000000000b,T2CON
LDP #GPTCONB>>7
SPLK #0000000000000000b,T3CON
SPLK #0000000000000000b,T4CON
;==================================================================
; ISR
;==================================================================
GISR4: ; Int4 GISR
NOP
LDP #PIVR >> 7h ; Peripheral page
LACL PIVR ; PIVR value
XOR #0033h ; CAP1 interrupt
BCND SISR33,eq
LACL PIVR ; PIVR value
XOR #0034h ; CAP2 interrupt
BCND SISR34,eq
LACL PIVR ; PIVR value
XOR #0035h ; CAP3 interrupt
BCND SISR35,eq
LACL PIVR ; PIVR value
XOR #0036h ; CAP4 interrupt
BCND SISR36,eq
LACL PIVR ; PIVR value
XOR #0037h ; CAP5 interrupt
BCND SISR37,eq
LACL PIVR ; PIVR value
C-38
Program Examples
CAP5PASS
LDP #6h
SPLK #6200h,62h
CLRC INTM
RET
;======================================================================
; Delay routine
;======================================================================
PHANTOM RET
GISR1 RET
GISR2 RET
GISR3 RET
GISR5 RET
GISR6 RET
.end
C-40
Appendix
AppendixDA
Topic Page
D-1
Introduction
D.1 Introduction
The LF240xA/LF240x Digital Signal Processors (DSPs) include on-chip
read-only memory (ROM) containing bootloader code. This code loads code
from an external serial boot device at reset and transfers control to the code
loaded from the external device. This chapter describes working with this
feature of the device.
The LF240xA/LF240x device Boot ROM offers the user two options: it can load
code through either asynchronous or synchronous serial transfer.
The synchronous transfer is done through the serial peripheral interface (SPI),
and the asynchronous transfer is done through the serial communications
interface (SCI). The code is loaded to a user-specified location which is
completely flexible; it can be anywhere in program memory where RAM is
available. The serial transfer packet must contain the address as specified in
the applicable Serial Transfer Format, which is described in section D.2,
Protocol Definitions, on page D-6.
D-2
Introduction
page D-8 for the effect on the SCI bootload lock. Also note that the com-
bination of the PLL multiplication factor chosen and the input clock fre-
quency must result in a clock rate less than or equal to the maximum CPU
clock rate allowed for the device.
On the LF240x devices, the PLL multiplication factor is always set to x4 by
the Boot ROM initialization code.
4) SCI or SPI selection. The bootloader code selects the source of the in-
coming code, depending on the state of the IOPC2 pin on the device. The
code takes a snapshot of this pin after being invoked, and determines
which loader (SPI or SCI) to invoke based on the status of this pin.
If IOPC2 is pulled low, an SCI transfer is commenced.
If IOPC2 is pulled high, an SPI transfer is commenced.
Note that the SPI selection is invalid on devices without the SPI.
It is suggested that this pin should be driven via a resistor as well,
because SPISIMO will be an output if the SPI is used at any time dur-
ing the operation of the system.
5) Destination check. The incoming destination is now compared to the
range FE00h to FFFFh. If the destination matches this range, the CNF bit
(Bit 12) in status register ST1 is set, configuring the DARAM memory block
B0 to Program Memory Space. No other checks are performed and it is
entirely up to the host/external boot device to supply a valid combination
of the memory destination address and the length for the incoming
code.This means that the target code must fit into the internal memory or
external memory must be available.
6) Data transfer. Once the incoming destination and length are fetched (this
protocol is defined in separate sections for the SCI and SPI), the actual
data transfer commences. The fetch is basically destination, length, and
data with no error-checking. On the SCI, the incoming data is echoed back
allowing the host to implement error-checking, if desired.
7) Execution of incoming code. Once the Boot ROM loader completes
transfer of the packet, a branch is made into the incoming code.
8) Watchdog. The watchdog timer on the device is active during the entire
sequence and is being reset at key points in the code. When a branch is
made into the user code, it is the responsibility of the user code to handle
watchdog overflow as appropriate.
9) Restrictions on the incoming code.
The combination of the destination address and transfer length must
point to valid locations. There is absolutely no error-handling whatso-
ever.
Figure D−1. Example Hardware Configuration for LF240xA Boot ROM Operation
SCI boot SPI boot
load load
VDD
LF240xA EEPROM
SPISIMO/IOPC2 DIN
SPISOMI DOUT
SPICLK CLK
BOOT EN/XF CS
BOOT EN
Boot Flash
ROM execute Host
VDD
RS232
transceiver
SCITXD/IOPAO
SCIRXD
Note: For LF240x devices, the bootloader sets the PLL to x4 mode. For LF240xA devices, the multiplier depends on the state of
the IOPA0 pin. For a list of valid CLKIN frequencies, refer to Table D−1, Clock Speeds At Which Baud Rate Locks, on
page D-8.
D-4
Introduction
Figure D−2. Memory Maps for the LF240xA/LF240x Devices in Microcontroller Mode
0000
0000
ÉÉÉÉÉÉÉÉÉÉÉ
Bootloader
ÉÉÉÉÉÉÉÉÉÉÉ
00FF
ÉÉÉÉÉÉÉÉÉÉÉ
ÉÉÉÉÉÉÉÉÉÉÉ
ÉÉÉÉÉÉÉÉÉÉÉ Reserved
ÉÉÉÉÉÉÉÉÉÉÉ
ÉÉÉÉÉÉÉÉÉÉÉ
7FFF
ÉÉÉÉÉÉÉÉÉÉÉ
8000
SARAM
ÉÉÉÉÉÉÉÉÉÉÉ
2K words
(Program/Data) 7FFF
87FF
8800
Bootloader enabled
(BOOT EN/XF = 0)
External
(off-chip)
FDFF
FE00
Reserved† (CNF = 1) 32K on-chip Flash memory
External (CNF = 0) (External if MP/MC = 1)
FEFF
Note: Flash size varies depending on the
FF00
On-Chip DARAM (B0)† (CNF = 1) device. LF2407A is depicted as an
External (CNF = 0) example.
FFFF
† When CNF = 1, addresses FE00h−FEFFh and FF00h−FFFFh are mapped to the same physical block (B0) in program-memory
space. For example, a write to FE00h has the same effect as a write to FF00h. For simplicity, addresses FE00h−FEFFh are
referred to as reserved when CNF = 1.
Note: When boot ROM is enabled, on-chip locations 0000−00FFh in program memory is mapped to the bootloader. Boot ROM
and Flash Memory share the same starting address, and hence, are not visible (active) at the same time. If the BOOT
EN/XF pin = 0 during reset, the BOOT EN bit in SCSR2 register (bit 3) will be set and will enable the Boot ROM at 0000 in
program space. While Boot ROM is enabled, the entire Flash memory will be disabled. The SCSR2.3 bit should be dis-
abled (0) to have Flash array enabled instead of Boot ROM. See Appendix D for bootloader details.
D-6
Protocol Definitions
Byte0:Byte1 Destination
Byte4:Byte5 Opcode 0
Byte6:Byte7 Opcode 1
•
•
•
Opcode n−1
36† 9† 18†
32† 8† 16†
30 7.5 15†
28 7 14†
24 6 12†
20 5 10†
16 4 8†
† Note that these clocking options are valid only on the LF240xA; i.e., not available on the LF240x.
D-8
Protocol Definitions
Figure D−4. Flowchart for the Serial Loader Baud Rate Match Algorithm
N
Is the RX flag set?
Fetch character
N
Is Char = 0x0D?
Increment VBR
N
Is VBR > max?
Figure D−5. Flowcharts for Serial Asynchronous Loader and the Fetch Header Routine
Start
B
FETCH HEADER
Store destination address
Store length
D-10
Protocol Definitions
Start
N Has a character
been received?
N Has a character
been received?
Return
;*****************************************************************************
;*****************************************************************************
; Debug directives
;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
.def GPR0 ;General purpose registers.
.def GPR1
.def GPR2
.def GPR3
.def DEST
.def LENGTH
.def data_buf
.def VBR_CNTR
.def DELAY
.def CHAR_RETRY_CNTR
.def BAUD_TBL_PTR
;*****************************************************************************
; Include header file for peripheral address references.
;
;*****************************************************************************
.include 240x.h
;*****************************************************************************
; Variable Declarations for on chip RAM Blocks
;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
.bss GPR0,1 ;General purpose registers.
.bss GPR1,1
.bss GPR2,1
.bss GPR3,1
.bss DEST,1
.bss LENGTH,1
.bss stk0,1
.bss stk1,1
.bss data_buf,1
.bss VBR_CNTR,1
.bss DELAY,1
.bss CHAR_RETRY_CNTR,1
.bss BAUD_TBL_PTR,1
;*****************************************************************************
; M A C R O − Definitions
;*****************************************************************************
POINT_B1 .macro
LDP #06h
.endm
D-12
Protocol Definitions
POINT_PF1 .macro
LDP #0E0h
.endm
;*****************************************************************************
; M A I N C O D E − starts here
;*****************************************************************************
.text
START:
SELECT_PLLMULT: LDP #PADATDIR>>7
SPLK #0000H,PADATDIR ;Config all I/O to be inputs.
LACC PADATDIR ;Read I/O pins.
AND #0001H ;Mask out all bits except IOPA0.
BCND PLL_MULT_4,NEQ ;If the pin is high, multiply
;by 4 (backward compatible).
;else
;continue with PLL_MULT_2.
;*****************************************************************************
; SPI Initialization
;*****************************************************************************
SPI_INIT:
LACC MCRB ;Set up the SPI pins to primary
;functions.
OR #001CH
SACL MCRB
LDP #SPICCR>>7
SPLK #0007h, SPICCR ;8 char bits,
SPLK #000Eh, SPICTL ;Enable master mode and enable talk.
;*****************************************************************************
; Select the Serial EEPROM
; by driving the select line low.
;*****************************************************************************
CS_ACTIVE CLRC XF ;Drive (!CS=XF) Low.
;*****************************************************************************
; Next send the Serial EEPROM a ’Read Command’ − it is then
; read out in burst mode, two bytes at a time by using GET_WORD
; Note that CS stays low all the time.
;*****************************************************************************
LACC #READ_COMMAND ;Load Read Command for EEPROM
CALL XMIT_VALUE ;Transmit Read Command.
;*****************************************************************************
; Now send a word (16 bits) to the EEPROM as address.
; Hard coded zero bytes are sent by the GET_WORD, but this is fine
; since the EEPROM is defined to contain boot code at origin.
;
;*****************************************************************************
CALL GET_WORD ;Get word sends two zero chars
;i.e. Top address in EEPROM
;*****************************************************************************
; Do two word transfers and have the two words for
; (DEST)ination and (LENGTH) of code boot−loaded.
;*****************************************************************************
CALL GET_WORD
SACL DEST
SACL GPR1 ;GPR1 used as dest ptr in TBLW
CALL CHECK_DEST ;Decide if B0 is to be switched to
;program space
CALL GET_WORD
SACL LENGTH
;*****************************************************************************
; This segment does all the work to transfer the code to program memory.
;
;*****************************************************************************
MAR *,AR0
LAR AR0,LENGTH ;Load AR0 and set ARP = AR0
SBRK #1 ;AR = length−1, since the loop is
;executed N times for AR=(N−1).
D-14
Protocol Definitions
;*****************************************************************************
; Finally the program is loaded in the memory.
; Branch to it and get there.
; As a last step, the Chip Select is de−activated.
;*****************************************************************************
POINT_B1
LACC DEST ;Branch to Boot Loader Code.
BACC ;
;*****************************************************************************
;
; G E T _ W O R D
;
; This routine gets a word from the EEPROM and packs it.
; It is returned in the accumulator
;
;
; Exit Conditions:
; 1. DP is set to B1 on Exit.
; 2. ACC,GPR0 are destroyed.
; 3. Result returned in ACC
; 4. Does not care about DP on enter.
;*****************************************************************************
;*****************************************************************************
; Transmit a char on the SPI Bus and return received data in accumulator
;
;
; Exit Conditions:
; 1. DP is set to B1 on Exit
; 2. ACC is destroyed.
; 3. Does not care about DP on enter
;
;*****************************************************************************
XMIT_VALUE: LDP #SPITXBUF>>7
SACL SPITXBUF ;Write xmit value to SPI TX Buffer.
XMIT_NCOMPL: BIT SPISTS,BIT6 ;Test SPI_INT bit
BCND XMIT_NCOMPL,NT ;If (bit=TC=0) ,then wait for TX Compl
;i.e., wait for transmit to finish
LACC SPIRXBUF ;Read also clears SPI_INT flag.
RET
;*****************************************************************************
; Transmit a char on the SPI Bus and return received data in accumulator
;
;
; Exit Conditions:
; 1. DP is set to B1 on Exit
; 2. ACC is destroyed.
;
;
;*****************************************************************************
;*****************************************************************************
; The rest of the implementation is the asynchronous serial port loader.
;*****************************************************************************
;Initialization
;*****************************************************************************
SCI_LOADER:
UART_INIT:
;*****************************************************************************
;SCI Initialization
;*****************************************************************************
SCI_INIT: LDP #MCRA>>7
LACC MCRA ; Set up pins as SCI pins.
OR #0003H
SACL MCRA
LDP #SCICCR>>7 ;1 stop bit, no parity,8bits/ch
SPLK #0007h, SCICCR ;async mode, idle−line protocol
LACK #0
D-16
Protocol Definitions
;*****************************************************************************
; The SCI module is held in ’reset’ until the parameter is loaded
; for the Baud Rate register from the Baud Rate table in SCILBAUD
; so the next lines stay commented out!
;*****************************************************************************
; SPLK #0023h, SCICTL1 ;Relinquish SCI from Reset.
; SPLK #65, SCILBAUD ;
;*****************************************************************************
;Baudrate lock protocol with Host
;*****************************************************************************
CLR_VBR_CNTR: POINT_B1
SACL CHAR_RETRY_CNTR ;Clear retry counter
SACL VBR_CNTR ;Clear valid baud rate counter
SACL BAUD_TBL_PTR ;BAUD_TBL_PTR is really only
;the offset from BAUD_TBL.
UI00
SET_BAUD: LACC BAUD_TBL_PTR
ADD #BAUD_TBL
POINT_PF1
INC_VBRC POINT_B1
LACC VBR_CNTR ;Inc VBR counter
ADD #1h
SACL VBR_CNTR
SUB #VBR_MAX ;Is VBR counter > max value ?
POINT_PF1
BCND UI01, NEQ ;No! fetch another char
BAUD_RETRY POINT_B1
SPLK #0h, VBR_CNTR
LACC CHAR_RETRY_CNTR ;Inc CRC counter
ADD #1h
SACL CHAR_RETRY_CNTR
SUB #CRC_MAX ;Is CRC > max value ?
BCND INC_TBL_PTR, GEQ ;Yes! try next baud rate
POINT_PF1
;*****************************************************************************
; Routine Name: F E T C H _ H E A D E R Routine Type: SR
;*****************************************************************************
FETCH_HEADER: CALL FETCH_SCI_WORD
LACC data_buf
SACL DEST
CALL FETCH_SCI_WORD
LACC data_buf
SACL LENGTH
RET
;*****************************************************************************
; Routine Name: X F E R _ S C I _ 2 _ P R O G Routine Type: SR
;*****************************************************************************
XFER_SCI_2_PROG:
MAR *, AR0
LAR AR0, LENGTH
LACC DEST ;ACC=dest address
D-18
Protocol Definitions
;*****************************************************************************
; Routine Name: F E T C H _ S C I _ W O R D Routine Type: SR
;
; Description: Version that expects Lo byte/Hi byte sequence from Host &
; also echoes byte
;*****************************************************************************
FETCH_SCI_WORD: POINT_B1
SACL stk0
LDP #SCIRXST>>7
FSW0 CALL RESET_WD
BIT SCIRXST,BIT6 ;Test RXRDY bit
BCND FSW0, NTC ;If RXRDY = 0,then repeat loop
LACC SCIRXBUF ;First byte is Lo byte
SACL SCITXBUF ;Echo byte back
AND #0FFh ;Clear upper byte
POINT_B1
SFR ;restore ACC as before
SACL data_buf ;Save received word
LACC stk0
RET
;*****************************************************************************
; Check the destination address, and switch B0 into program space if needed.
;*****************************************************************************
;*****************************************************************************
;*****************************************************************************
;*****************************************************************************
; Table of SCI_LBAUD Contents.
;*****************************************************************************
; SCI_LBAUD @38.4 Kbps ; SYSCLK ; CLKIN
;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
BAUD_TBL: .word 130 ; 40MHz ; 10 MHz
.word 117 ; 36MHz ; 9.0 MHz
.word 104 ; 32MHz ; 8.0 MHz
.word 97 ; 30MHz ; 7.5 MHz
.word 91 ; 28MHz ; 7.0 MHz
.word 78 ; 24MHz ; 6.0 MHz
.word 65 ; 20MHz ; 5.0 MHz
.word 52 ; 16MHz ; 4.0 MHz
.end
D-20
Appendix
AppendixEA
&'
! &! ./0,%$%*
This chapter describes the Flash/ROM code security features, lists the code
security module (CSM) registers, and discusses programming considerations
for TMS320LF/LC240xA devices with and without code security.
Topic Page
E-1
Flash/ROM Security Feature
240xA memory
Mode access Mode select conditions Device status Remarks
1 Runtime using on-chip MP/MC = 0 (upon reset) − Unsecure Code is free-run from
program memory Microcontroller mode. on-chip flash/ROM.
(without JTAG (On-chip bootloader Typical usage of the DSP
connector connected) disabled) in an end-product.
2 Runtime using external MP/MC = 1 (upon reset) − Secure Code is run from external
program memory Microprocessor mode. program memory.
(On-chip flash/ROM and
bootloader disabled)
E-2
Flash/ROM Security Feature
Mode 1: This is the typical mode that would be employed in the end-customer
application. The application code stored in on-chip flash/ROM free runs. In this
mode, the device is unsecure, since the core should be able to read the
contents of on-chip flash/ROM to be able to execute it. The JTAG port is left
unconnected. Connecting the JTAG connector would immediately secure the
device, thereby thwarting any attempt to read the contents of flash/ROM. To
reiterate, during run-time execution of the application, the device will run the
application without any impact from the “Code Security Module (CSM)”, which
is inactive. If visibility to flash/ROM contents is desired, the device must be first
unsecured.
In all the four modes, the device is unsecured by executing the “Password
Match Flow (PMF)”.
RAM blocks such as DARAM and SARAM − These memory blocks can
be freely accessed and code run from them, whether the device is in se-
cure or unsecure mode.
Boot ROM contents − Visibility to the boot ROM contents is not impacted
by the CSM; however, invoking the boot ROM code would immediately se-
cure the device.
To summarize, it is possible to load code onto on-chip program RAM via the
JTAG connector without any impact from the CSM. The code can be debugged
and the peripheral registers initialized, independent of whether the device is
in secure or unsecure mode.
E-4
Technical Definitions
KEY registers − User accessible registers (four 16-bit words) which will
be used to secure or unsecure the device. These registers are mapped in
the data memory space at addresses 77F0h, 77F1h, 77F2h and 77F3h.
Data Memory
Address Register Name Reset Values Register Description
77F0h KEY3 FFFFh High word of the 64-bit KEY register
E-6
Environments that Require Security Unlocking
Following are the typical situations under which unsecuring may be required:
Figure E−1 explains how PMF helps to initialize the security logic registers and
disable security logic. See the flowchart boxes for the actual instructions that
accomplish the PMF.
Flash/ROM Device
secure,
after reset or runtime
KEY = Undefined
Do dummy Read
Example code for dummy read
of PWL, 0040−0043h
LDP #0
BLPD #40h, 60h ; update high word
BLPD #41h, 60h ; third word
BLPD #42h, 60h ; second word
BLPD #43h, 60h ; low word
Is PWL = Yes
240xA instructions all 0’s or F’s?
Example to update KEY register
Assume xpwd has password
Yes
Correct Password
Device unsecure!
? CPU
can access
No on chip Flash/ROM !
E-8
Unsecuring Considerations for Devices With/Without Code Security
2) Write the password into the KEY registers (locations 77F0h through
77F3h in data memory).
E.5.1 DOs
To keep the debug and code development phase simple, use the device
in the unsecure mode; i.e., use 0000 0000 0000 0000h or FFFF FFFF
FFFF FFFFh as PWL words (or use a password that is easy to remember).
Use passwords after the development phase when the code is frozen.
Recheck the passwords in PWL before programming the COFF file using
flash utilities.
While migrating code from 240x or 24x devices to the 240xA devices,
recheck the PWL contents before committing the code to flash memory.
Note that program memory locations 0040h through 0043h in 240x/24x
devices are not reserved for passwords and these locations can contain
user code. If 0040h−0043h contain code, it would inadvertently secure the
240xA device.
Refer to Table E−1, Security Mode Table, on page E-2 and its conditions
before designing the reset circuit for the LC/LF240xA devices.
E.5.2 DON’Ts
There are some situations when the code security feature could be
compromised. However, awareness of these situations during the design
phase could eliminate any possibility of code security being violated. Some
design configurations to be avoided are:
An application code should not transfer control to any code that could be
loaded through a peripheral (such as SCI or CAN). For example, suppose
that a customer develops their own version of the bootloader to be able
to bootload from CAN. Typically, this program would initialize the CAN
module, transfer a piece of code through the CAN bus onto on-chip RAM
and then transfer control to the loaded code. A hacker could potentially
transfer a piece of code that could read the flash/ROM contents and then
output the same through any on-chip peripheral or the external memory
interface, if present. This is not a concern with the boot-ROM embedded
in the LF240xA device since the device is secured the moment the on-chip
boot-loader is invoked.
E-10
DOs and DON’Ts to Protect Security Logic
LF2407A is the only device that has external memory interface (XMIF).
This device can execute code in microprocessor mode using external
memory. If the device powers up in microprocessor mode (MP/MC pin =1),
the on-chip flash memory will be disabled and the flash access will remain
secure. If on-chip flash access is desired, it can be done only if the
password is known. The CPU has to initiate a PMF and flash access will
be granted, if the password is valid. However, if the device powers up in
micro-controller mode (MP/MC pin =0) and branches to an external
memory address, the flash memory cannot be protected. A hacker could
potentially have code in the external memory that could read the
flash/ROM contents.
Similarly, code running in flash should not transfer control to on-chip boot
ROM. A hacker could potentially transfer a piece of code that could read
the flash contents.
2) The standard way of running code out of the flash is to program the flash
with the code and powering up the DSP in microcomputer mode. Since the
flash is unsecured after reset (provided none of the security conditions are
violated), the code will function correctly.
3) Connecting a JTAG emulator at any time will immediately put the flash into
secure mode. In addition, running the ROM bootloader at reset, or having
the MP/MC pin high at reset also puts the flash into secure mode. This
functionality keeps hackers from accessing the flash by using the emula-
tor, by trying to bootload code into the device that copies the flash contents
to the outside world, or by booting up directly into external memory and
running code that tries to copy the flash contents to the outside world.
E-12
CSM — Frequently Asked Questions
What is CSM?
4) When the KEY register values and the PWL values are different.
ROM: Place password into ROM code at location 40h−43h. This password will
be fabricated into the ROM with the ROM code.
Flash: Program addresses 40h−43h with a password other than all zeros or
all ones.
1) Do a “dummy” read of PWL. The word “dummy” implies that the destina-
tion address of this read is insignificant. Only the read of the PWL is impor-
tant.
2) Write the passwords to the KEY. The value of these passwords should al-
ready be known by the user and should match the value stored in the PWL.
I have programmed the PWL with “dummy” passwords. Do I still need to perform
dummy reads of the PWL when I am doing JTAG emulation/debug?”
A dummy read of the PWL is still essential to gain visibility to on-chip
flash/ROM. A write to the KEY is not required. In situations where a debugger
is used, a read of the PWL by the debugger (in the disassembly window) is
sufficient. For example, right-click in the disassembly window, select Start
Address, and enter 0x0040 in the box. This will unsecure the on-chip
ROM/FLASH.
E-14
CSM — Frequently Asked Questions
Yes. The device must be unsecure in order to be able to execute code out of
on-chip Flash/ROM memory.
This is not advisable. Keeping tab of the password may be difficult, especially
if code changes are possible. It is a good practice to define a password section
in the project to isolate the PWL from the rest of the code. This forces the user
code to begin at 44h and precludes the possibility of code starting from 40h.
This practice is especially advantageous when migrating code from LF240x,
where code starts at 40h.
How does the presence of CSM affect flash programming of LF240xA devices? Or,
I successfully programmed the flash once, but I am unable to do it again. What could
be wrong?
After I invoked Code Composer, I couldn’t see my code (programmed in flash) in the
disassembly window. I see some “garbage” code instead. What could be wrong?
The device is still in secure mode. In order to be able to view your code in the
disassembly window, the device must first be unsecured.
LOOP B LOOP
I forgot the password I programmed in PWL. Will I be able to reprogram the flash?
No. Not unless you know which COFF file you used to program the flash. It is
for this reason you should always store a known value in the PWL during the
code development phase.
Are there any restrictions on debug capabilities when secure mode is used?
No. Once the device is unsecured, the CSM has no impact on debug
capabilities.
Does the addition of Secure Mode require any modifications to the Application Code
itself?
The only requirement is the presence of passwords in the PWL.
E-16
CSM — Frequently Asked Questions
Are there any ’bad practices’ which should be avoided (which compromise security)?
Please refer to section E.5, DOs and DON’Ts to Protect Security Logic, of this
reference guide.
In mass production, can the Flash be programmed, and made secure, in ONE, fast,
operation?
There is no special operation needed “to secure” a device, other than ensuring
the presence of passwords in the PWL.
Do the BLPD and TBLR instructions still work when in secure mode ? If so, what pre-
vents a ’Trojan Horse’ program...attached to the external bus, from copying from Pro-
gram to Data space, then allowing data space to be copied to the UART ...or being vis-
ible via JTAG?
No, BLPD and TBLR do not work when the device is in secure mode. Using
the external bus implies Microprocessor mode. The device is secured in MP
mode. The device will also be secured immediately when the JTAG connector
is connected.
5
A
A0−A15: Collectively, the external address bus; the 16 pins are used in par-
allel to address external data memory, program memory, or I/O space.
ACC: See accumulator.
ACCH: Accumulator high word. The upper 16 bits of the accumulator. See
also accumulator.
ACCL: Accumulator low word. The lower 16 bits of the accumulator. See
also accumulator.
accumulator: A 32-bit register that stores the results of operations in the
central arithmetic logic unit (CALU) and provides an input for subsequent
CALU operations. The accumulator also performs shift and rotate opera-
tions.
address: The location of program code or data stored in memory.
addressing mode: A method by which an instruction interprets its operands
to acquire the data it needs. See also direct addressing; immediate
addressing; indirect addressing.
analog-to-digital (A/D) converter: A circuit that translates an analog signal
to a digital signal.
AR: See auxiliary register.
AR0−AR7: Auxiliary registers 0 through 7. See auxiliary register.
ARAU: See auxiliary register arithmetic unit (ARAU).
ARB: See auxiliary register pointer buffer (ARB).
ARP: See auxiliary register pointer (ARP).
auxiliary register: One of eight 16-bit registers (AR7−AR0) used as point-
ers to addresses in data space. The registers are operated on by the aux-
iliary register arithmetic unit (ARAU) and are selected by the auxiliary
register pointer (ARP).
F-1
Glossary
auxiliary register pointer (ARP): A 3-bit field in status register ST0 that
points to the current auxiliary register.
auxiliary register pointer buffer (ARB): A 3-bit field in status register ST1
that holds the previous value of the auxiliary register pointer (ARP).
B
B0: An on-chip block of dual-access RAM that can be configured as either
data memory or program memory, depending on the value of the CNF
bit in status register ST1.
BIO pin: A general-purpose input pin that can be tested by the conditional
branch instruction (BCND) that causes a branch when BIO is driven low
externally.
F-2
Glossary
C
C bit: See carry bit.
CALU: See central arithmetic logic unit (CALU).
carry bit: Bit 9 of status register ST1; used by the CALU for extended
arithmetic operations and accumulator shifts and rotates. The carry bit
can be tested by conditional instructions.
central arithmetic logic unit (CALU): The 32-bit wide main arithmetic logic
unit for the 24x CPU that performs arithmetic and logic operations. It
accepts 32-bit values for operations, and its 32-bit output is held in the
accumulator.
CLKIN: Input clock signal. A clock source signal supplied to the on-chip
clock generator at the CLKIN/X2 pin or generated internally by the
on-chip oscillator. The clock generator divides or multiplies CLKIN to
produce the CPU clock signal, CLKOUT.
CLKOUT: Master clock output signal. The output signal of the on-chip clock
generator. The CLKOUT high pulse signifies the CPU’s logic phase
(when internal values are changed), and the CLKOUT low pulse signifies
the CPU’s latch phase (when the values are held constant).
CNF bit: DARAM configuration bit. Bit 12 in status register ST1. CNF is used
to determine whether the on-chip RAM block B0 is mapped to program
space or data space.
Glossary F-3
Glossary
CPU cycle: The time required for the CPU to go through one logic phase
(during which internal values are changed) and one latch phase (during
which the values are held constant).
current AR: See current auxiliary register.
current auxiliary register: The auxiliary register pointed to by the auxiliary
register pointer (ARP). The auxiliary registers are AR0 (ARP = 0)
through AR7 (ARP = 7). See also auxiliary register; next auxiliary
register.
current data page: The data page indicated by the content of the data page
pointer (DP). See also data page; DP.
D
D0−D15: Collectively, the external data bus; the 16 pins are used in parallel
to transfer data between the 24x and external data memory, program
memory, or I/O space.
DARAM: Dual-access RAM. RAM that can be accessed twice in a single
CPU clock cycle. For example, your code can read from and write to
DARAM in the same clock cycle.
DARAM configuration bit (CNF): See CNF bit.
data-address generation logic: Logic circuitry that generates the address-
es for data memory reads and writes. This circuitry, which includes the
auxiliary registers and the ARAU, can generate one address per
machine cycle. See also program-address generation logic.
data page: One block of 128 words in data memory. Data memory contains
512 data pages. Data page 0 is the first page of data memory (addresses
0000h−007Fh); data page 511 is the last page (addresses
FF80h−FFFFh). See also data page pointer (DP); direct addressing.
data page 0: Addresses 0000h−007Fh in data memory; contains the
memory-mapped registers, a reserved test/emulation area for special
information transfers, and the scratch-pad RAM block (B2).
data page pointer (DP): A 9-bit field in status register ST0 that specifies
which of the 512 data pages is currently selected for direct address
generation. When an instruction uses direct addressing to access a data-
memory value, the DP provides the nine MSBs of the data-memory
address, and the instruction provides the seven LSBs.
data-read address bus (DRAB): A 16-bit internal bus that carries the
address for each read from data memory.
F-4
Glossary
data read bus (DRDB): A 16-bit internal bus that carries data from data
memory to the CALU and the ARAU.
data-write address bus (DWAB): A 16-bit internal bus that carries the
address for each write to data memory.
data write bus (DWEB): A 16-bit internal bus that carries data to both
program memory and data memory.
DS: Data memory select pin. The 24x asserts DS to indicate an access to
external data memory (local or global).
dummy cycle: A CPU cycle in which the CPU intentionally reloads the
program counter with the same address.
E
execute phase: The fourth phase of the pipeline; the phase in which the
instruction is executed. See also pipeline; instruction-fetch phase;
instruction-decode phase; operand-fetch phase.
Glossary F-5
Glossary
F
FIFO buffer: First-in, first-out buffer. A portion of memory in which data is
stored and then retrieved in the same order in which it was stored. The
synchronous serial port has two four-word-deep FIFO buffers: one for its
transmit operation and one for its receive operation.
G
general-purpose input/output pins: Pins that can be used to accept input
signals or send output signals. These pins are the input pin BIO, the out-
put pin XF, and the GPIO pins.
H
hardware interrupt: An interrupt triggered through physical connections
with on-chip peripherals or external devices.
I
IFR: See interrupt flag register (IFR).
immediate addressing: One of the methods for obtaining data values used
by an instruction; the data value is a constant embedded directly into the
instruction word; data memory is not accessed.
indirect addressing: One of the methods for obtaining data values used by
an instruction. When an instruction uses indirect addressing, data
memory is addressed by the current auxiliary register. See also direct
addressing.
input shifter: A 16- to 32-bit left barrel shifter that shifts incoming 16-bit data
from 0 to 16 positions left relative to the 32-bit output.
F-6
Glossary
instruction-fetch phase: The first phase of the pipeline; the phase in which
the instruction is fetched from program-memory. See also pipeline;
instruction-decode phase; operand-fetch phase; instruction-execute
phase.
interrupt: A signal sent to the CPU that (when not masked or disabled)
forces the CPU into a subroutine called an interrupt service routine (ISR).
This signal can be triggered by an external device, an on-chip peripheral,
or an instruction (INTR, NMI, or TRAP).
interrupt latency: The delay between the time an interrupt request is made
and the time it is serviced.
interrupt mode bit (INTM): Bit 9 in status register ST0; either enables all
maskable interrupts that are not masked by the IMR or disables all mask-
able interrupts.
Glossary F-7
Glossary
IS: I/O space select pin. The 24x asserts IS to indicate an access to external
I/O space.
L
latch phase: The phase of a CPU cycle during which internal values are held
constant. See also logic phase; CLKOUT1.
logic phase: The phase of a CPU cycle during which internal values are
changed. See also latch phase; CLKOUT1.
LSB: Least significant bit. The lowest order bit in a word. When used in plural
form (LSBs), refers to a specified number of low-order bits, beginning
with the lowest order bit and counting to the left. For example, the four
LSBs of a 16-bit value are bits 0 through 3. See also MSB.
M
machine cycle: See CPU cycle.
F-8
Glossary
MP/MC pin: A pin that indicates whether the processor is operating in micro-
processor mode or microcontroller mode. MP/MC high selects micropro-
cessor mode; MP/MC low selects microcontroller mode. This pin is used
to execute the on-chip bootloader/user code at reset. When MP/MC is
held low during reset, program control transfers to on-chip non-volatile
memory at location 0000h. When MP/MC is held high, control transfers
to 0000h in external program memory.
MSB: Most significant bit. The highest order bit in a word. When used in
plural form (MSBs), refers to a specified number of high-order bits, begin-
ning with the highest order bit and counting to the right. For example, the
eight MSBs of a 16-bit value are bits 15 through 8. See also LSB.
multiplier: A part of the CPU that performs 16-bit × 16-bit multiplication and
generates a 32-bit product. The multiplier operates using either signed
or unsigned 2s-complement arithmetic.
N
next AR: See next auxiliary register.
next auxiliary register: The register that is pointed to by the auxiliary regis-
ter pointer (ARP) when an instruction that modifies ARP is finished
executing. See also auxiliary register; current auxiliary register.
Glossary F-9
Glossary
O
operand: A value to be used or manipulated by an instruction; specified in
the instruction.
operand-fetch phase: The third phase of the pipeline; the phase in which
an operand or operands are fetched from memory. See also pipeline;
instruction-fetch phase; instruction-decode phase; instruction-execute
phase.
output shifter: 32- to 16-bit barrel left shifter. Shifts the 32-bit accumulator
output from 0 to 7 bits left for quantization management, and outputs
either the 16-bit high or low half of the shifted 32-bit data to the data write
bus (DWEB).
OV bit: Overflow flag bit. Bit 12 of status register ST0; indicates whether the
result of an arithmetic operation has exceeded the capacity of the
accumulator.
overflow (in a register): A condition in which the result of an arithmetic
operation exceeds the capacity of the register used to hold that result.
overflow mode: The mode in which an overflow in the accumulator causes
the accumulator to be loaded with a preset value. If the overflow is in the
positive direction, the accumulator is loaded with its most positive
number. If the overflow is in the negative direction, the accumulator is
filled with its most negative number.
OVM bit: Overflow mode bit. Bit 11 of status register ST0; enables or
disables overflow mode. See also overflow mode.
P
PAB: See program address bus (PAB).
PAR: Program address register. A register that holds the address currently
being driven on the program address bus for as many cycles as it takes
to complete all memory operations scheduled for the current machine
cycle.
F-10
Glossary
Glossary F-11
Glossary
R
RD: Read select pin. The 24x asserts RD to request a read from external pro-
gram, data, or I/O space. RD can be connected directly to the output en-
able pin of an external device.
READY: External device ready pin. Used to create wait states externally.
When this pin is driven low, the 24x waits one CPU cycle and then tests
READY again. After READY is driven low, the 24x does not continue pro-
cessing until READY is driven high.
repeat counter (RPTC): A 16-bit register that counts the number of times
a single instruction is repeated. RPTC is loaded by an RPT instruction.
reset: A way to bring the processor to a known state by setting the registers
and control bits to predetermined values and signaling execution to start
at address 0000h.
reset pin (RS): A pin that causes a reset.
reset vector: The interrupt vector for reset.
return address: The address of the instruction to be executed when the
CPU returns from a subroutine or interrupt service routine.
F-12
Glossary
RS: Reset pin. When driven low, causes a reset on any 24x device.
R/W: Read/write pin. Indicates the direction of transfer between the 24x and
external program, data, or I/O space.
S
scratch-pad RAM: Another name for DARAM block B2 in data space
(32 words).
sign bit: The MSB of a value when it is seen by the CPU to indicate the sign
(negative or positive) of the value.
sign extend: Fill the unused high order bits of a register with copies of the
sign bit in that register.
software stack: A program control feature that allows you to extend the
hardware stack into data memory with the PSHD and POPD instructions.
The stack can be directly stored and recovered from data memory, one
word at time. This feature is useful for deep subroutine nesting or protec-
tion against stack overflow.
stack: A block of memory reserved for storing return addresses for subrou-
tines and interrupt service routines. The 24x stack is 16 bits wide and
eight levels deep.
status registers ST0 and ST1: Two 16-bit registers that contain bits for
determining processor modes, addressing pointer values, and indicating
various processor conditions and arithmetic logic results. These regis-
ters can be stored into and loaded from data memory, allowing the status
of the machine to be saved and restored for subroutines.
Glossary F-13
Glossary
STRB: External access active strobe. The 24x asserts STRB during ac-
cesses to external program, data, or I/O space.
SXM bit: See sign-extension mode bit (SXM).
T
TC bit: Test/control flag bit. Bit 11 of status register ST1; stores the results
of test operations done in the central arithmetic logic unit (CALU) or the
auxiliary register arithmetic unit (ARAU). The TC bit can be tested by
conditional instructions.
temporary register (TREG): A 16-bit register that holds one of the oper-
ands for a multiply operation; the dynamic shift count for the LACT,
ADDT, and SUBT instructions; or the dynamic bit position for the BITT
instruction.
TOS: Top of stack. Top level of the 8-level last-in, first-out hardware stack.
TREG: See temporary register (TREG).
TTL: Transistor-transistor logic.
V
vector: See interrupt vector.
vector location: See interrupt vector location.
W
wait state: A CLKOUT cycle during which the CPU waits when reading from
or writing to slower external memory.
wait-state generator: An on-chip peripheral that generates a limited
number of wait states for a given off-chip memory space (program, data,
or I/O). Wait states are set in the wait-state generator control register
(WSGR).
WE: Write enable pin. The 24x asserts WE to request a write to external pro-
gram, data, or I/O space.
WSGR: Wait-state generator control register. This register, which is mapped
to I/O memory, controls the wait-state generator.
X
XF bit: XF-pin status bit. Bit 4 of status register ST1 that is used to read or
change the logic level on the XF pin.
F-14
Glossary
XF pin: External flag pin. A general-purpose output pin whose status can be
read or changed by way of the XF bit in status register ST1.
Z
zero fill: A way to fill the unused low or high order bits in a register by insert-
ing 0s.
Glossary F-15
F-16
Index
Index-1
Index
Index-2
Index
Index-3
Index
Index-4
Index
Index-5
Index
Index-6
Index
Index-7
Index
asymmetric waveform generation 6-27 quadrature encoder pulse (QEP) circuit 6-80
asymmetric/symmetric waveform decoding 6-81
generator 6-27 decoding example 6-82
compare/PWM output in up-/down-counting QEP circuit 6-81
mode 6-30 QEP circuit block diagram for EVA 6-80
compare/PWM output in up-counting QEP circuit block diagram for EVB 6-81
mode 6-28 QEP circuit time base 6-80
compare/PWM transition 6-27 QEP counting 6-82
output logic 6-30 operation with GP timer interrupt and associated
symmetric waveform generation 6-28 compare outputs 6-82
GP timer counting operation 6-22 QEP pins 6-80
compare output in continuous register setup for the QEP circuit 6-82
up-/down-counting mode, table 6-31 register addresses 6-11
compare output in continuous up-counting register setup for PWM generation 6-58
mode, table 6-31 registers 6-9
continuous-up counting mode 6-22 space vector PWM 6-62
figure 6-24 3-phase power inverter 6-62
continuous-up/down-counting mode 6-25 basic space vectors and switching pat-
figure 6-26 terns 6-64
directional-up/down-counting mode 6-24 schematic diagram 6-62
figure 6-25 table of switching patterns 6-63
stop/hold mode 6-22 approximating motor voltage with
GP timer reset 6-38 basic space vectors 6-64
operation of capture units 6-71 power inverter switching patterns
capture unit setup 6-72 and basic space vectors 6-62
capture unit time base selection 6-71 space vector PWM boundary conditions 6-66
output logic 6-55 space vector PWM waveform generation with
block diagram for PWM mode 6-56 event manager 6-64
pins 6-6 hardware 6-65
power drive protection interrupt 6-8 software 6-65
programmable dead-band unit 6-50 space vector PWM waveforms 6-66
dead-band generation 6-52 unused compare register 6-66
dead-band generation examples 6-53 symmetric PWM waveform generation 6-60
timer control registers (TxCON and
dead-band timer control registers
GPTCONA/B) 6-32
(DBTCONn) 6-50
individual GP timer control register
dead-band unit block diagram 6-54
(TxCON) 6-32
features of dead-band units 6-55
overall GP timer control register A
inputs and outputs of dead-band unit 6-52
(GPTCONA) 6-35
PWM asymmetric waveform generation with
overall GP timer control register B
compare units and PWM circuits, figure 6-59
(GPTCONB) 6-36
PWM circuits associated with compare
units 6-48 event manager A (EVA)
PWM generation capability of EV 6-49 block diagram 6-3
PWM symmetric waveform generation with pins 6-7
compare units and PWM circuits, figure 6-60 register addresses
PWM symmetric waveforms, figure 6-67 EVA capture registers 6-12
PWM waveform generation with compare units EVA compare control registers 6-11
and PWM circuits 6-57 EVA interrupt registers 6-13
dead band 6-57 EVA timer registers 6-11
PWM signal generation 6-57 EVB capture registers 6-12
Index-8
Index
Index-9
Index
generating executable files, figure C-2 initialization, SPI (serial peripheral interface)
generating wait states with the 2407A wait-state initialization upon reset 9-15
generator 3-17 using the SPI SW RESET bit 9-16
global data memory 3-11 input/output (I/O)
glossary F-1 differences in GPIO implementation in the
GP timer control register A (GPTCONA) 6-35 240xA 5-4
digital I/O ports register implementation on
GP timer control register B (GPTCONB) 6-36
240xA devices
GP timer reset 6-38 shared pin configuration 5-2
GPIO (general-purpose input/output), differences in table of I/O port control registers
GPIO implementation in the 240xA 5-4 implementation 5-3
GSR (global status register) 10-32 I/O mux control register A (MCRA) 5-4
configuration table 5-5
I/O mux control register B (MCRB),
H configuration table 5-6
I/O mux control register C (MCRC) 5-7
hardware, table of hardware features of the 240xA configuration table 5-7
devices 1-7 mux control registers (MCRn) 5-4
highlights, 240xA 1-7 input/output (I/O) ports module 5-1
digital I/O ports register implementation
on 240xA devices 5-2
I instruction register (IR), definition F-7
I/O mux control registers, I/O mux control register B interrupt
(MCRB) 5-5 acknowledge 2-16
I/O space 3-12 definition F-7
address map for 2407A 3-12 hierarchy 2-15
I/O spaces, overview 3-5 latency 2-24
IDE, CAN data frame 10-9 nonmaskable 2-19
operation sequence 2-21
identifier, CAN data frame 10-9
peripheral interrupt acknowledge descriptions
message filtering 10-9
PIACKR0 2-35
message priority 10-9
PIACKR1 2-36
identifiers PIACKR2 2-37
message 10-10 peripheral interrupt request descriptions
message control field (MSGCTRLn) 10-11 PIRQR0 2-31
message identifier for high-word mailboxes 0−5 PIRQR1 2-33
(MSGIDnH) 10-10 PIRQR2 2-34
message identifier for low-word mailboxes 0−5 request structure 2-15
(MSGIDnL) 10-11 requests, figure 2-18
idle-line mode steps, SCI (serial communications vectors 2-17
interface) 8-11 phantom 2-18
idle-line multiprocessor communication format, SCI software hierarchy 2-19
(serial communications interface) 8-11 interrupt flag register (IFR) 2-26 to 2-42
idle-line multiprocessor mode, SCI (serial
communications interface) 8-10 interrupt latency, definition F-7
IFR 2-26 to 2-42 interrupt logic, CAN (controller area
illegal address detect 2-38 network) 10-35
IMR 2-28 to 2-42 interrupt mask register (IMR) 2-28 to 2-42
Index-10
Index
Index-11
Index
Index-12
Index
notation, CAN (controller area network) 10-42 PEDATDIR (port E data and direction control
NPAR (next program address register), register) 5-12
definition F-10 peripheral clock enable bits, 240xA devices 13-7
peripheral interrupt acknowledge descriptions
PIACKR0 2-35
O PIACKR1 2-36, 2-37
PIACKR2 2-37
on-chip RAM 3-2
peripheral interrupt acknowledge register 0
dual-access on-chip RAM (DARAM) 3-2
(PIACKR0) 2-34
single-access on-chip program/data RAM
(SARAM) 3-2 peripheral interrupt acknowledge register 1
(PIACKR1) 2-34
on-chip memory, advantages 3-5
peripheral interrupt acknowledge register 2
OPCn (overwrite protection control for (PIACKR2) 2-34
mailbox n) 10-23
peripheral interrupt expansion (PIE) controller 2-13
oscillator and PLL, 240xA devices 13-6 block diagram 2-14
frequency input specification 13-6 interrupt
pin names 13-6 acknowledge 2-16
output logic hierarchy 2-15
compare match for outputs PWMx 6-55 request structure 2-15
compare operation, GP timer 6-30 peripheral interrupt registers 2-30
overview peripheral interrupt request descriptions
240xA device graphical overview 1-9 PIRQR0 2-31
peripherals 1-5 PIRQR1 2-33
TMS320 family 1-2 PIRQR2 2-34
peripheral interrupt request register 0
P (PIRQR0) 2-31
peripheral interrupt request register 1
PADATDIR, port A data and direction control (PIRQR1) 2-31
register, I/O pin designation table 5-9 peripheral interrupt request register 2
PADATDIR (port A data and direction control (PIRQR2) 2-31
register) 5-8 peripheral interrupt vector register (PIVR) 2-30
PAR (program address register), definition F-10 peripheral memory map, 2407A 3-9
password match flow (PMF), code security E-8 PFDATDIR, port F data and direction control
register, pin designation table 5-14
PBDATDIR, port B data and direction control
register, I/O pin designation table 5-10 PFDATDIR (port F data and direction control
register) 5-13
PBDATDIR (port B data and direction control
register) 5-9 phantom interrupt vector 2-18
PCDATDIR, port C data and direction control phase-locked loop (PLL) 4-2
register, I/O pin designation table 5-11 operation 4-4
external oscillator 4-4
PCDATDIR (port C data and direction control
loop filter components 4-5
register) 5-10
power and ground connections, figure 4-5
PDDATDIR, port D data and direction control power connections 4-5
register, I/O pin designation table 5-12 reference resonator/crystal, figure 4-4
PDDATDIR (port D data and direction control resonator/crystal oscillator 4-4
register) 5-11 terms applicable to the PLL module 4-3
PEDATDIR, port E data and direction control PIACKR0 (peripheral interrupt acknowledge
register , I/O pin designation table 5-13 register 0) 2-34
Index-13
Index
Index-14
Index
Index-15
Index
Index-16
Index
Index-17
Index
SPI status register (SPISTS) 9-22 C240 SCI vs. LF/LC240xA SCI 8-2
summary of programmable registers on communication format 8-15
the 240xA B-2 receiver signals in communication
system control and status register 1 modes 8-16
(SCSR1) 2-3 RX signals in communication modes,
low-power modes 2-3 figure 8-16
system control and status register 2 transmitter signals in communication
(SCSR2) 2-5 modes 8-17
timer x control register (TxCON), TX signals in communication modes,
x = 1,2,3, or 4 6-33 figure 8-17
transmission control register (TCR) 10-20 multiprocessor and asynchronous
transmit data buffer register (SCITXBUF) 8-31
communication modes 8-7
WD counter register (WDCNTR) 11-8
multiprocessor communication 8-9
WD reset key register (WDKEY) 11-9
address byte 8-9
WD timer control register (WDCR) 11-9
block start signal 8-11
XINT1 control register (XINT1CR) 2-39
sending a block start signal 8-12
XINT2 control register (XINT2CR) 2-40
controlling the SCI TX and RX features 8-10
remote frames 10-14
idle-line mode steps 8-11
remote requests idle-line multiprocessor communication
receiving 10-14 format 8-11
sending 10-15 idle-line multiprocessor mode 8-10
reset 2-38 receipt sequence 8-10
wake-up from low-power modes 4-9 receiver operation 8-13
RFPn (remote frame pending register for recognizing the address byte 8-9
mailbox n) 10-22 sleep bit 8-9
RMLn (receive message lost for mailbox n) 10-22 wake-up temporary (WUT), double-buffered
RMPn (receive message pending for WUT and TXSHF 8-12
mailbox n) 10-23 wake-up temporary (WUT) flag 8-12
ROM, factory masked on-chip ROM 3-3 physical description 8-2
port interrupts 8-18
RTR, CAN data frame 10-9
programmable data format 8-8
RX signals in communication modes, SCI
data frame formats, typical 8-8
(serial communications interface)
programming using SCICCR 8-8
figure 8-17
SCI block diagram 8-4
SCI RX signals in communication modes,
SCI module registers 8-20
figure 8-16
address table 8-20
baud-select LSbyte register
S (SCILBAUD) 8-26
baud-select MSbyte register
sample ISR code 2-25 (SCIHBAUD) 8-26
SCI (serial communications interface) 8-1 emulation data buffer register
address-bit multiprocessor mode 8-13 (SCIRXEMU) 8-31
communication format 8-14 overview 8-6
sending an address 8-13 receiver data buffer register
architecture 8-5 (SCIRXBUF) 8-31
asynchronous communication format 8-15 receiver data buffer registers (SCIRXEMU,
baud rate calculations 8-19 SCIRXBUF) 8-30
asynchronous baud register values for receiver status register (SCIRXST) 8-28
common SCI bit rates 8-19 bit associations 8-30
Index-18
Index
SCI communication control register serial communication interface (SCI), 240xA to 240
(SCICCR) 8-21 family compatibility 12-4
SCI control register 1 (SCICTL1) 8-23
serial communications interface (SCI) 8-1
SCI control register 2 (SCICTL2) 8-27
architecture 8-5
SCI priority control register (SCIPRI) 8-32
asynchronous communication format 8-15
transmit data buffer register
(SCITXBUF) 8-31 baud rate calculations 8-19
SCI physical description asynchronous baud register values for
error detection flags 8-2 common SCI bit rates 8-19
half- or full-duplex operation 8-3 C240 SCI vs. LF/LC240xA SCI 8-2
I/O pins 8-2 communication format 8-15
non-return-to-zero format 8-3 receiver signals in communication
programmable bit rates 8-2 mode 8-16
programmable data word length 8-2 RX signals in communication mode,
programmable number of stop bits 8-2 figure 8-16
receive and transmit functions 8-3 transmitter signals in communication
separate enable bits for TX and RX mode 8-17
interupts 8-3 TX signals in communication mode,
separate error interrupts for multiple error figure 8-17
conditions 8-3 multiprocessor and asynchronous
serial clock, internally generated 8-2 communication modes 8-7
transmitter and receiver operation 8-3 multiprocessor communication 8-9
wake-up multiprocessor modes 8-3 address byte 8-9
address−bit multiprocessor mode 8-13
SCSR1 (system control and status register 1) 2-3
communication format 8-14
low-power modes 2-3
sending an address 8-13
SCSR2 (system control and status register 2) 2-5 block start signal 8-11
sending a block start signal 8-12
sequencer, autoconversion 7-4
controlling the SCI TX and RX features 8-10
basic operation, conversion in
idle-line mode steps 8-11
dual-sequencer mode using SEQ1 7-8
idle-line multiprocessor communication
block diagram of autosequenced ADC in
format 8-11
cascaded mode 7-5
idle-line multiprocessor mode 8-10
block diagram of autosequenced ADC with
receipt sequence 8-10
dual sequencers 7-6
comparison of single and cascaded receiver operation 8-13
operating modes 7-7 recognizing the address byte 8-9
input trigger description 7-13 sleep bit 8-9
interrupt operation during sequenced wake-up temporary (WUT), double-buffered
conversion 7-13 WUT and TXSHF 8-12
figure 7-16 wake-up temporary (WUT) flag 8-12
Sequencer start/stop operation with multiple physical description 8-2
time-sequenced triggers port interrupts 8-18
example of event manager triggers to start the programmable data format 8-8
sequencer 7-11 data frame formats, typical 8-8
example of sequencer start/stop programming using SCICCR 8-8
operation 7-10 SCI block diagram 8-4
sequencer start/stop operation with multiple SCI module registers 8-20
time-sequenced triggers, with multiple address table 8-20
time-sequenced triggers 7-10 baud-select LSbyte register
uninterrupted autosequenced mode 7-8 (SCILBAUD) 8-26
Index-19
Index
Index-20
Index
SPI operation control register (SPICTL) 9-21 SPI serial data register (SPIDAT) 9-2
SPI priority control register (SPIPRI) 9-29 SPI serial receive buffer register
SPI serial data register (SPIDAT) 9-28 (SPIRXBUF) 9-2
SPI serial receive buffer register SPI serial transmit buffer register
(SPIRXBUF) 9-26 (SPITXBUF) 9-2
SPI serial transmit buffer register SPICLK phase and polarity control 9-2
(SPITXBUF) 9-27 static and control logic 9-3
SPI status register (SPISTS) 9-22 SPI module registers
overview 9-5
SOF, CAN data frame 10-9
register addresses 9-6
SOS synch, start-of-sequence sync-up 7-38 SPI baud rate register (SPIBRR) 9-24
SPI configuration control register
SPI (serial peripheral interface) 9-1
(SPICCR) 9-19
block diagram 9-4
character length control bit values 9-20
C240 SPI vs. LF/LC240xA SPI 9-2
SPI emulation buffer register
interrupts 9-10
(SPIRXEMU) 9-25
baud rate and clocking schemes 9-12
SPI example waveforms 9-30
baud rate determination 9-12 CLOCK POLARITY = 0, CLOCK
example of baud rate calculations for PHASE = 0 9-30
SPIBRR = 0, 1, or2 9-13 CLOCK POLARITY = 0, CLOCK
example of baud rate calculations for PHASE = 1 9-31
SPIBRR = 3 to 127 9-12 CLOCK POLARITY = 1, CLOCK
example of maximum baud rate PHASE = 0 9-32
calculation 9-13 CLOCK POLARITY = 1, CLOCK
clocking schemes 9-13 PHASE = 1 9-33
selection guide 9-14 SPISTE behavior in master mode 9-34
SPICLK signal options 9-14 SPISTE behavior in slave mode 9-35
SPICLK-CLKOUT characteristics 9-15 SPI operation control register (SPICTL) 9-21
data format 9-11 SPI priority control register (SPIPRI) 9-29
example transmission of bit from SPI serial data register (SPIDAT) 9-28
SPIRXBUF 9-12
SPI serial receive buffer register
data transfer example 9-16
(SPIRXBUF) 9-26
five bits per character 9-17
SPI serial transmit buffer register
initialization upon reset 9-15
proper SPI initialization using the SPI SW
(SPITXBUF) 9-27
RESET bit 9-16 SPI status register (SPISTS) 9-22
SPI interrupt control bits 9-10 SPIO pins, 240xA devices 13-11
OVERRUN INT ENA bit (SPICTL.4) 9-11
RECEIVER OVERRUN FLAG bit SRR, CAN data frame 10-9
(SPISTS.7) 9-11
suspend mode, CAN (controller area
SPI INT ENA bit (SPICTL.0) 9-10
network) 10-41
SPI INT FLAG bit (SPISTS.6) 9-10
SPI PRIORITY bit (SPIPRI.6) 9-11 system configuration and interrupts 2-1
operation 9-7 240xA architectural summary 2-2
introduction 9-7 figure 2-2
master mode 9-8 configuration registers 2-3
master/slave connection, figure 9-8 device identification number
slave mode 9-9 register (DINR) 2-8
physical description 9-2 system control and status
I/O pins 9-2 register 1 (SCSR1) 2-3
master and slave mode operations 9-2 low-power modes 2-3
memory-mapped control and system control and status
status registers 9-3 register 2 (SCSR2) 2-5
Index-21
Index
Index-22
Index
Index-23
Index
Index-24