Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
EL/EE 405
Department of Electrical Engineering,
Delhi Technological University
September 2018
Course Instructor : Dr. Anup Kumar Mandpura
1
Outline
• Introduction to Digital Signal Controller
• Architecture of TMS320F2407
• System Initialization
• Addressing Modes
• ADC and DAC
• Event Manager
• Applications of TMS320F24x in Filter Design and other Domains.
2
What is Digital Signal Controller?
3
Microprocessor (µP)
• Central Device of a multi chip Micro Computer System
• Two basic architectures: Von Neumann / Harvard
• Von Neumann : Shared memory space between code and data;
Shared memory busses between code and data; Example: Intel’s x86
Pentium Processor family
• Harvard : Two independent memory spaces for code and data; Two
memory bus systems for code and data
• A µP to operate needs additional devices
• To use a µP one has to add memory and additional external devices to
the Microprocessor.
4
Micro Computer
• Micro Computer = Microprocessor(µP) + Memory + Peripherals
• Peripherals include:
– Analogue to Digital Converter (ADC)
– Digital to Analogue Converter (DAC)
– Timer / Counter units
– Pulse Width Modulation ( PWM) Output Lines
5
Micro Computer Contd…
- Network Interface Units:
Serial Communication Interface (SCI) - UART
Serial Peripheral Interface ( SPI)
Inter Integrated Circuit ( I2C) – Bus
Controller Area Network (CAN)
Local Interconnect Network (LIN)
Universal Serial Bus (USB)
Local / Wide Area Networks (LAN, WAN)
Graphical Output Devices
6
Microcontroller (µC)
• A single chip computer
• All computing power AND input/output channels that are required to
design a real time control system are „on chip“
• Guarantee cost efficient and powerful solutions for embedded control
applications
• Backbone for almost every type of modern product
• Over 200 independent families of µC
• Both µP – Architectures (Von Neumann and Harvard) are used inside
Microcontrollers
7
Digital Signal Processor
8
Digital Signal Processor Contd…
9
Typical DSP Algorithms
10
A Digital Signal Controller
• A new type of microcontroller, where the processing power is delivered by a
DSP
• Digital Signal Controller (DSC) is a single chip Microcomputer with a
Digital Signal Processor (DSP) as core unit.
• By combining the computing power of a DSP with memory and peripherals
in one single device we derive the most effective solution for embedded real
time control solutions that require lots of math operations.
• DSC –Example: Texas Instruments C2000 family.
11
Architectural Overview of
TMS320F2407
12
Overview
• In 1982, Texas Instruments introduced the TMS32010, the first fixed-point
DSP in the TMS320 family.
• The F/C240 is a member of the C2000 DSP platform, and is optimized for
control applications.
13
Overview Contd…
15
Potential of DSPs Contd…
• More efficient and quieter operation due to less generation of torque
ripple, resulting in less loss of power, lower vibration, and longer life
• Elimination or reduction of memory lookup tables through real-time
polynomial calculation, thereby reducing system cost
• Use of advanced algorithms that can reduce the number of sensors
required in a system
• Control of power switching inverters, along with control algorithm
processing
• Single-processor control of multi-motor systems
16
TMS320 Device Nomenclature
17
TMS320F/C240x
18
Device Overview
19
Pin Functions
20
Pin Functions
21
Pin Functions
22
Pin Functions
23
Pin Functions
24
Pin Functions
25
Pin Functions
26
Pin Functions
27
Fig. Mapping External Devices to C2xx Core and Peripheral Interface
28
LF2407 Peripheral Set
• Two Event Managers (A and B)
• General Purpose (GP) timers
• PWM generators for digital motor control
• Analog-to-digital converter
• Controller Area Network (CAN) interface
• Serial Peripheral Interface (SPI) – synchronous serial port
• Serial Communications Interface (SCI) – asynchronous serial port
• General-Purpose bi-directional digital I/O (GPIO) pins
• Watchdog Timer (“time-out” DSP reset device for system integrity)
29
Brief Introduction to Peripherals
Event Managers (EVA, EVB)
30
Brief Introduction to Peripherals Contd…
The Analog-to-Digital Converter (ADC)
31
Brief Introduction to Peripherals Contd…
The Control Area Network (CAN) Module
32
Brief Introduction to Peripherals Contd…
Serial Peripheral Interface (SPI) and Serial Communications Interface (SCI)
• The SPI is a high-speed synchronous communication port that is mainly used for
communicating between the DSP and external peripherals or another DSP device.
• Typical uses of the SPI include communication with external shift registers, display
drivers, or ADCs.
• The SCI is an asynchronous communication port that supports asynchronous serial
(UART) digital communication between the CPU and other asynchronous
peripherals that use the standard NRZ (non-return-to-zero) format.
• It is useful in communication between external devices and the DSP.
33
Architecture Summary
• The C24x DSP architecture is based on a modified Harvard architecture,
which supports separate bus structures for program space and data space
• Separate program and data spaces allow simultaneous access to program
instructions and data.
• For example, while data is multiplied, a previous product can be added to
the accumulator, and at the same time, a new address can be generated.
• Such parallelism supports a set of arithmetic, logic, and bit-manipulation
operations that can all be performed in a single machine cycle.
• The C24x also includes control mechanisms to manage interrupts,
repeated operations, and function/subroutine calls.
• Devices within a generation of the TMS320 family have the same CPU
structure but different on-chip memory and peripheral configurations.
34
35
TMS320C2xx core CPU
36
The Components of the C2xx DSP Core
37
The Components of the C2xx DSP Core
Accumulator
• The accumulator stores the output from the CALU and also serves as
another input to the CALU .
• The accumulator is 32 bits wide and is divided into two sections, each
consisting of 16 bits.
• Assembly language instructions are provided for storing the high- and
low-order accumulator words to data memory.
38
C24xx Block Diagram
•
Controller
Program Memory
A(15-0) Mapped
• Memory
Registers
D(15-0)
Data Bus
Peripherals Multiplier
(Event Mgr)
Data
Memory
Peripherals
(Non-Event Mgr) ALU/Shifters
Data Bus
Pulse (QEP)
Non-EV Manager
Watchdog Timer
SPI
SCI
A/D Converter
I /O Pins
CAN
TMS320C2xx Memory
• 544 words × 16 bits of on-chip data/program dual-access RAM
• 16K words × 16 bits of on-chip program ROM or flash EEPROM
• 224K words × 16 bits of maximum addressable memory space
(64K words of program space, 64K words of data space, 64K
words of I/O space, and 32K words of global space)
• External memory interface module with a software wait-state
generator, a 16-bit address bus, and a 16-bit data bus
41
TMS320C2xx Memory Contd…
• Three different allocations of memory : Data, Program, and I/O memory space.
• Data space is used for program calculations, look-up tables, and any other memory used by an
algorithm.
• Data memory can be in the form of the on-chip random access memory (RAM) or external
RAM.
• Program memory is the location of user’s program code.
• Program memory on the LF2407 is either mapped to the off-chip RAM (MP/MC- pin =1) or to
the on-chip flash memory (MP/MC- = 0), depending on the logic value of the MP/MC-pin.
• I/O space is not really memory but a virtual memory address used to output data to peripherals
external to the LF2407
• For example, the digital-to-analog converter (DAC) is accessed with I/O memory.
42
Types of Physical Memory
Random Access Memory (RAM)
• The LF2407 has 544 words of 16 bits each in the on-chip Double Access Random
Access Memory (DARAM)
• These 544 words are partitioned into three blocks: B0, B1, and B2.
• Blocks B1 and B2 are allocated for use only as data memory.
• B0 memory can be configured as program or data memory depending on the value of
the core level “CNF” bit in status register one.
• There are also 2000 16-bit words of Single Access Random Access Memory
(SARAM).
• The main difference between DARAM and SARAM is that DARAM memory can
be accessed twice per clock cycle and SARAM can only be accessed once per cycle.
43
Types of Physical Memory Contd…
Non-volatile Flash Memory
• 32K of on-chip flash memory that can be mapped to program space if the MP/MC-
pin is made logic 0
• The flash memory can be electronically programmed and erased many times to
allow for code development.
• Unlike RAM, the Flash memory does not lose its contents when the LF2407 loses
power.
• It is only necessary to use the Flash memory if the DSP is to be run independently
from a PC and JTAG interface.
• Example, if F2407 in a DSP control solution to an automobile braking system. It
would be some what impractical to have a JTAG/PC interface in a car that is
undergoing performance testing.
44
Multiplier and ALU / Shifters
Program Bus
16
Data Bus
16 16 16
16 TREG (16) MUX
16 MULTIPLIER
PREG (32) 16
SHIFTER (0-16) 32
SHIFTER (-6, 0, 1, 4)
32
32
MUX
32 32
ALU (32)
32
C ACCH (16) ACCL (16)
• 32
SFL (0-7)
16
Data Bus
45
Multiplier
• The multiplier performs 16-bit, 2s-complement multiplication and creates a 32-
bit result.
• C2xx uses the 16-bit temporary register (TREG) and the 32-bit product register
(PREG).
• The TREG always needs to be loaded with one of the numbers that are to be
multiplied.
• The output of the multiply is stored in the PREG, which can later be read by the user
code
46
Scaling Shifters
Three 32-bit shifters that allow for scaling, bit extraction, extended arithmetic, and
overflow-prevention operations.
• Input data-scaling shifter (input shifter): This shifter left-shifts 16-bit input data
by 0 to 16 bits to align the data to the 32-bit input of the CALU
• Output data-scaling shifter (output shifter): This shifter left-shifts data from the
accumulator by 0 to 7 bits before the output is stored to data memory. The content
of the accumulator remains unchanged
• Product-scaling shifter (product shifter): The product shifter shifts the output of
the PREG before that output is sent to the input of the CALU. The product shifter
has four product shift modes (no shift, left shift by one bit, left shift by four bits,
and right shift by six bits).
47
Program Memory Program Bus
16
MUX
16 16
PC
16 16
• • 16
12-15
Address STACK
(8x16)
Program
ROM /
16 FLASH
A(15-0) •
MUX
16 Instruction
16
D(15-0) 16
MUX
16
16
Data Bus
To Data Memory
Data Memory
Data Bus
16 16 Program Bus
From Program Memory AR0(16)
3 AR1(16) 9
7 LSB
AR2(16) From IR
3 DP(9)
ARP(3) AR3(16)
9
AR4(16)
16 16
3 AR5(16)
16 MUX
AR6(16)
16
ARB(3) AR7(16) •
• 16
50
Pipeline Process
Cycle
100 101 102 103 104 105 106
Add F1 D1 R1 E1
Sub F2 D2 R2 E2
Mpy F3 D3 R3 E3
Store F4 D4 R4 E4
C242 4K - 8 5/3 2 2 No No 26
LC/F2402 6 / 8K - 8 5/3 2 2 No No 21
53
C240x PLL Clock Module
XTAL1 /CLKIN
XTAL OSC
Fin PLL 1 / 512 WDCLK
crystal Clock Module Prescaler
Watchdog
3-bit PLL Select
CPU Core Memory CAN
XTAL2
Event Manager SCI SPI
External Memory Interface
CLKOUT ADCCLK
Prescaler ADC
The PLL clock module interfaces to the peripheral bus and provides all of the clocks required for the entire device.
There are four sets of clocks, all running at different frequencies:
• CPUCLK – This is the highest frequency clock provided by the module and is used by the CPU, all memories
and any peripherals tied directly to the CPUs buses, including an external memory interface if used. All other
clocks are derived by dividing this clock down to a lower frequency.
• SYSCLK – This clock is a half or a quarter the rate of CPUCLK. It is used to clock all the peripherals on the TI
peripheral bus.
• WDCLK – This is the low power clock used by the watchdog timer/realtime interrupt module. It has a nominal
frequency of 16 kHz with a 25% duty cycle.
55
Fig. PLL Clock Module Block Diagram 56
Clock Control Register 0 (CKCR0)
@ 702Bh
57
58
59
Low Power Modes
Peripheral /
Low Power CPU Logic Interrupt Watchdog PLL / Typical
Mode Clock Logic Clock Clock OSC Power
Normal Run on on on on ~ 90 mA
IDLE1 off on on on ~ 40 mA
61
62
63
Watchdog Timer
• Resets the C240x if the CPU crashes
1. Watchdog counter runs independent of CPU
2. If counter overflows, reset is triggered
3. CPU must write correct data key sequence to reset the counter before
overflow
• Watchdog must be serviced (or disabled) within ~3.28ms after reset (40
MHz device) in TMS320F2812
• This translates into 131,072 instructions!
Watchdog Timer Module
/64 111
7 - Bit /32 110
/16 101 WDPS (Watch Dog Pre-scale)
Free -
WDCLK • /8 100 WDCR . 2 - 0
Running •
/4 011
Counter /2 010
System • CLR WDCR . 6
001
Reset 000 WDDIS
•
•
WDCNTR . 7 - 0
WDFLAG
8 - Bit Watchdog WDCR . 7
One-Cycle
Counter
CLR Delay
•
WDKEY . 7 - 0
WDCR . 5 - 3 WDCHK 2-0 System
Watchdog Reset
55 + AA Good Key
Reset Key • • 3 Request
Detector Bad Key • • /
Register / Bad WDCR Key
3
1 0 1
Watchdog Period Selection
WDPS FRC C240x timeout
Bits rollover period @ 40 MHz
00x: 1 3.28 ms
010: 2 6.55 ms
011: 4 13.11 ms
100: 8 26.21 ms
101: 16 52.43 ms
110: 32 104.86 ms
111: 64 209.72 ms
15 - 8 7 6 5 4 3 2 1 0
15 - 8 7 6 5 4 3 2 1 0
reserved D7 D6 D5 D4 D3 D2 D1 D0
1 AAh No action
2 AAh No action
3 55h WD counter enabled for reset on next AAh write
4 55h WD counter enabled for reset on next AAh write
5 55h WD counter enabled for reset on next AAh write
6 AAh WD counter is reset
7 AAh No action
8 55h WD counter enabled for reset on next AAh write
9 AAh WD counter is reset
10 55h WD counter enabled for reset on next AAh write
11 23h CPU reset triggered due to improper write value
System Control and Status Register 1
SCSR1 @ 7018h
CLKOUT Pin Source Select
0 = CPU clock
1 = Watchdog Clock
PLL Clock Prescale
15 14 13 12 11 10 9 8
reserved CLKSCR LPM1 LPM0 CLK_PS2 CLK_PS1 CLK_PS0 reserved
7 6 5 4 3 2 1 0
ADC SCI SPI CAN EVB EVA
reserved ILLADR
CLKEN CLKEN CLKEN CLKEN CLKEN CLKEN
15 - 6 5 4 3 2 1 0
WD
reserved XMIF_HI-Z BOOT_EN MP / MC DON PON
OVERRIDE
Microprocessor/Microcontroller mode
XMIF_Hi-Z Control 0 = on-chip program memory
0 = normal mapped (i.e. on-chip Flash)
1 = Hi-Z state 1 = off-chip program memory
mapped (i.e. external memory device)
72
73
74
Low Power Modes
Peripheral /
Low Power CPU Logic Interrupt Watchdog PLL / Typical
Mode Clock Logic Clock Clock OSC Power
Normal Run on on on on ~ 90 mA
IDLE1 off on on on ~ 40 mA
LPM 1 LPM 0
77