TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4...

100
TI TMS320C28x 1-Day Workshop Student Guide Technical Training Organization C28x 1-Day Workshop Revision 2.0 July 2004

Transcript of TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4...

Page 1: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

TI

TMS320C28x 1-Day Workshop

Student Guide

Technical Training Organization

C28x 1-Day Workshop Revision 2.0 July 2004

Page 2: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Important Notice

Important Notice Texas Instruments and its subsidiaries (TI) reserve the right to make changes to their products or to discontinue any product or service without notice, and advise customers to obtain the latest version of relevant information to verify, before placing orders, that information being relied on is current and complete. All products are sold subject to the terms and conditions of sale supplied at the time of order acknowledgment, including those pertaining to warranty, patent infringement, and limitation of liability.

TI warrants performance of its semiconductor products to the specifications applicable at the time of sale in accordance with TI’s standard warranty. Testing and other quality control techniques are utilized to the extent TI deems necessary to support this warranty. Specific testing of all parameters of each device is not necessarily performed, except those mandated by government requirements.

Customers are responsible for their applications using TI components.

In order to minimize risks associated with the customer’s applications, adequate design and operating safeguards must be provided by the customer to minimize inherent or procedural hazards.

TI assumes no liability for applications assistance or customer product design. TI does not warrant or represent that any license, either express or implied, is granted under any patent right, copyright, mask work right, or other intellectual property right of TI covering or relating to any combination, machine, or process in which such semiconductor products or services might be or are used. TI’s publication of information regarding any third party’s products or services does not constitute TI’s approval, warranty or endorsement thereof.

Copyright © 2003 – 2004 Texas Instruments Incorporated

Revision History February 2003 – Revision 1.0

March 2003 – Revision 1.1

July 2004 – Revision 2.0

Mailing Address Texas Instruments Training Technical Organization 7839 Churchill Way M/S 3984 Dallas, Texas 75251-1903

ii C28x 1-Day Workshop

Page 3: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

TMS320C28x 1-Day Workshop

TMS320C28x 1-Day Workshop

TMS320C28xTMS320C28x11--Day WorkshopDay Workshop

Texas InstrumentsTexas InstrumentsTechnical TrainingTechnical Training

Copyright Copyright ©© 2004 Texas Instruments. All rights reserved.2004 Texas Instruments. All rights reserved.Technical TrainingTechnical TrainingOrganizationOrganization

TT TOTO

eZdspeZdsp™™ F2812 Starter KitF2812 Starter Kit

eZdspeZdsp is a trademark of Spectrum Digital, Inc.is a trademark of Spectrum Digital, Inc.

TMS320C28x Workshop AgendaTMS320C28x Workshop Agenda

M1: C28x 1M1: C28x 1--Day Workshop OverviewDay Workshop OverviewM2: Introduction to the TMS320F281xM2: Introduction to the TMS320F281xM3: Development ToolsM3: Development ToolsM4: Control PeripheralsM4: Control PeripheralsLunchLunchM5: DSP/BIOS RealM5: DSP/BIOS Real--Time OSTime OSM6: Flash ProgrammingM6: Flash ProgrammingM7: The Next StepM7: The Next Step……

C28x 1-Day Workshop iii

Page 4: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

TMS320C28x 1-Day Workshop

This page is intentionally blank.

iv C28x 1-Day Workshop

Page 5: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

C28x 1-Day Workshop Overview

Introduction This module will provide a brief introduction to the TMS320C281x 1-day workshop, and explain the general lab exercise flow. The TMS320 family members will be discussed, and various members of the C2000 family will be highlighted. Additionally, the broad application base of the C28x will be explored.

Learning Objectives Learning ObjectivesLearning Objectives

Introductions and Workshop Lab OverviewIntroductions and Workshop Lab Overview

TMS320 Platforms and the C2000TMS320 Platforms and the C2000

Review Broad Application BaseReview Broad Application Base

TMS320C2000 Family MembersTMS320C2000 Family Members

C28x 1-Day Workshop - C28x 1-Day Workshop Overview 1 - 1

Page 6: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Module Topics

Module Topics C28x 1-Day Workshop Overview............................................................................................................. 1-1

Module Topics......................................................................................................................................... 1-2 Workshop Introduction ........................................................................................................................... 1-3

TMS320C28x Device Family............................................................................................................. 1-4

1 - 2 C28x 1-Day Workshop - C28x 1-Day Workshop Overview

Page 7: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Workshop Introduction

Workshop Introduction IntroductionsIntroductions

NameName

CompanyCompany

Project ResponsibilitiesProject Responsibilities

DSP / Microcontroller ExperienceDSP / Microcontroller Experience

TMS320 DSP ExperienceTMS320 DSP Experience

Hardware / Software Hardware / Software -- Assembly / CAssembly / C

InterestsInterests

Workshop Lab OverviewWorkshop Lab Overview

M3: Set up M3: Set up eZdspeZdsp™™ F2812 Starter KitF2812 Starter Kit

M4: Use the Event Manager to M4: Use the Event Manager to Generate and View PWM Generate and View PWM WaveformsWaveforms

M5: DSP/BIOS and Filtering PWM M5: DSP/BIOS and Filtering PWM Waveform using Waveform using IQmathIQmath

M6: Programming an Application into M6: Programming an Application into Flash MemoryFlash Memory

C28x 1-Day Workshop - C28x 1-Day Workshop Overview 1 - 3

Page 8: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Workshop Introduction

TMS320C28x Device Family

C5000C5000

C6000C6000

C2000C2000

Efficient IntegrationEfficient Integrationfor Controlfor Control

Power EfficientPower EfficientPerformancePerformance

High PerformanceHigh Performance‘‘CC’’ EfficiencyEfficiency

Multiple Platforms Provide the Right Multiple Platforms Provide the Right Solutions for Your ApplicationSolutions for Your Application

Con

trol

Per

form

ance

Con

trol

Per

form

ance

HighHigh--Precision Control Precision Control

MultiMulti--Function,Function,Appliance &Appliance &Consumer ControlConsumer Control

150 150 MIPS!MIPS!

HighHigh--endendDerivativesDerivatives

CostCostoptimizedoptimizedversionsversions

C2000 Portfolio Expanding with C2000 Portfolio Expanding with Price/Performance Optimized DerivativesPrice/Performance Optimized Derivatives

24x24xTMTM

up to 40 MIPSup to 40 MIPS

F2810F2810150 MIPS150 MIPS

F2811F2811150 MIPS150 MIPS

F2812F2812150 MIPS150 MIPS C281xC281x

150 MIPS150 MIPS

C280xC280x100 MIPS100 MIPS

ApplicationApplicationspecificspecificversionsversionsR2811R2811

150 MIPS150 MIPS

R2812R2812150 MIPS150 MIPS

F280xF280x100 MIPS100 MIPS

1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview

Page 9: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Workshop Introduction

Optical NetworkingOptical NetworkingControl of laser diodeControl of laser diode

Digital Power SupplyDigital Power SupplyProvides control, sensing, Provides control, sensing, PFC, and other functionsPFC, and other functions

PrinterPrinterPrint head controlPrint head controlPaper path motor controlPaper path motor control

Evaluating Evaluating Other Segments Other Segments egeg. Musical . Musical InstrumentsInstruments

NonNon--traditional traditional Motor ControlMotor ControlMany new coolMany new coolapplications to applications to comecome

Broad C28xBroad C28x™™ Application BaseApplication Base

AutomotiveAutomotive

TIMERTIMER

FlashFlash (words)(words)

ROMROM (words)(words)

RAMRAM (words)(words)

CPUCPU

ADCADC

McBSPMcBSPEXMIFEXMIF

Watch DogWatch DogSPISPI

SCI (UART)SCI (UART)CANCAN

Volts (V)Volts (V)# I/O# I/O

PackagePackage

ResolutionResolution

CAP/QEPCAP/QEP

PWM(CMP)PWM(CMP)

Event ManagerEvent Manager

32bit 32 bit 16 bit 16 bit 32bit 32 bit 16 bit 16 bit 16 bit 16 bit 16 bit 16 bit 16 bit 16 bit 16 bit 16 bit 16 bit 16 bit 16 bit 16 bit 16 bit 16 bit 16 bit 16 bit 16 bit 16 bit 16bit 16bit 16bit16bit

18K 18K 18K18K 2.5K 2.5K 2.5K2.5K 1.0K1.0K 1.0K1.0K 1.0K1.0K 2.5K2.5K 1.5K1.5K 544 1.0K 544544 1.0K 544 544544 544544 544544

32K32K 16K16K 6K6K 8K8K 4K4K

128K128K 64K 32K 64K 32K 32K32K 16K 8K16K 8K 8K8K 8K8K 8K8K 16K16K

6/6 6/6 6/66/6 6/46/4 6/46/4 3/2 3/2 3/23/2 1/01/0 6/46/4 6/46/4 3/2 3/2 1/0 3/21/0 3/2 3/23/2 4/24/2 3/23/2

16 16 1616 1616 1616 88 8 78 7 1616 1616 8 8 7 8 87 8 8 12 812 8

7 7 4 4 7 7 4 4 2 22 2 22 44 44 2 2 22 2 2 22 33 22

1212--bit bit 1212--bitbit 1010--bit bit 1010--bitbit 1010--bitbit 1010--bitbit 1010--bitbit 10 bit10 bit 1010--bit bit 1010--bitbit 1010--bitbit 1010--bitbit 1010--bitbit 1010--bitbit 1010--bitbit

2 2 1 12 2 1 1 1 1 1 1 1 1 1 1 11 1 1 11 11 11 1 1 11

200ns 200ns 200ns200ns 500ns 500ns 500ns500ns 500ns500ns 500ns500ns 500ns500ns 375ns375ns 375ns375ns 425ns425ns 500ns 900ns500ns 900ns 900ns900ns 6.1us6.1us 900ns900ns

1.8 core 1.8core 3.3 1.8 core 1.8core 3.3 3.33.3 3.33.3 3.33.3 3.33.3 3.33.3 3.33.3 3.33.3 3.33.3 5.05.0 5.05.0 5.05.0 5.05.03.3 I/O 3.3 I/O3.3 I/O 3.3 I/O

5656 5656 41 41 4141 2121 2121 13 41 13 41 4141 2121 13 3213 32 2626 2828 2626

176LQFP 128LQFP 144LQPF 100LQPF 64LQFP 64PQFP 176LQFP 128LQFP 144LQPF 100LQPF 64LQFP 64PQFP 32LQFP 100LQFP32LQFP 100LQFP 100LQFP100LQFP 64PQFP64PQFP 32LQFP 144LQFP32LQFP 144LQFP 64PQFP64PQFP 132PQFP132PQFP 64PQFP64PQFP179u*BGA179u*BGA 68PLCC68PLCC 68PLCC68PLCC

F2812 F2810 LF2407A LF2406A LF2403A LF2402AF2812 F2810 LF2407A LF2406A LF2403A LF2402A LF2401ALF2401A LC2406ALC2406A LC2404ALC2404A LC2402A LC2401A LC2402A LC2401A F243 F241F243 F241 F240F240 C242C242

ConvConv timetime# # ofChanofChan 1616 1616 1616 1616 88 88 55 1616 1616 8 58 5 88 88 1616 88

TIMERTIMER

BootROMBootROM (words)(words)

MIPSMIPS 150 150 150150 40 40 4040 4040 4040 4040 4040 4040 4040 4040 20 20 2020 2020 2020

4K4K 4K4K 256 256 256256 256256 256256 256256

TI C2000: IndustryTI C2000: Industry’’s Broadest Product s Broadest Product Portfolio for Embedded ApplicationsPortfolio for Embedded Applications

C28x 1-Day Workshop - C28x 1-Day Workshop Overview 1 - 5

Page 10: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Workshop Introduction

This page is intentionally blank.

1 - 6 C28x 1-Day Workshop - C28x 1-Day Workshop Overview

Page 11: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Introduction to the TMS320F281x

Introduction This module provides an overview of the TMS320F281x architecture. Features of the core, memory, control peripherals, and communication ports will be presented.

Learning Objectives Learning ObjectivesLearning Objectives

TMS320F281x ArchitectureTMS320F281x ArchitectureC28x DSP CoreC28x DSP CoreMemory SubMemory Sub--SystemSystemControl PeripheralsControl PeripheralsCommunication PeripheralsCommunication Peripherals

C28x 1-Day Workshop - Introduction to the TMS320F281x 2 - 1

Page 12: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Module Topics

Module Topics Introduction to the TMS320F281x........................................................................................................... 2-1

Module Topics......................................................................................................................................... 2-2 TMS320F2812/11/10 .............................................................................................................................. 2-3

High Performance DSP Core.............................................................................................................. 2-3 Memory Sub-System .......................................................................................................................... 2-4 Control Peripherals ............................................................................................................................. 2-4 Communication Ports ......................................................................................................................... 2-5 TMS320F2812 Memory Map............................................................................................................. 2-7 Fast Interrupt Manager ....................................................................................................................... 2-7

2 - 2 C28x 1-Day Workshop - Introduction to the TMS320F281x

Page 13: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

TMS320F2812/11/10

TMS320F2812/11/10

Fast program execution out of both RAM and Fast program execution out of both RAM and Flash memoryFlash memory

100100--120 MIPS with Flash Acceleration Technology120 MIPS with Flash Acceleration Technology150 MIPS out of RAM for time150 MIPS out of RAM for time--critical codecritical code

Memory SubMemory Sub--SystemSystem

Event ManagersEvent ManagersUltraUltra--Fast 12Fast 12--bit ADCbit ADC

12.5 MSPS throughput12.5 MSPS throughputDual sample&holds enable simultaneous samplingDual sample&holds enable simultaneous samplingAuto Sequencer, up to 16 conversions w/o CPUAuto Sequencer, up to 16 conversions w/o CPU

Control PeripheralsControl Peripherals

Multiple standard communication ports provide Multiple standard communication ports provide simple interfaces to other componentssimple interfaces to other components

Communications PortsCommunications Ports

150MIPS performance150MIPS performanceSingle cycle 32 x32Single cycle 32 x32--bit MAC (or dual 16 x16 MAC)bit MAC (or dual 16 x16 MAC)Very Fast Interrupt ResponseVery Fast Interrupt ResponseSingle cycle readSingle cycle read--modifiedmodified--writewriteF24x/LF240x Source Code CompatibleF24x/LF240x Source Code Compatible

High Performance DSP (C28xHigh Performance DSP (C28xTMTM Core)Core)

Memory Bus

128Kw Flash+ 1Kw OTP

4Kw Boot ROM

18Kw RAM

Code security

XINTF

32-bitRegister

FileReal-Time

JTAG

32-bitTimers (3)

150 MIPs C28xTM 32-bit DSP

32x32-bitMultiplier

R M WAtomic

ALU

Interrupt Management

Event Mgr A

Event Mgr B

12-Bit ADC

Watchdog

GPIO

McBSP

CAN 2.0B

SCI-UART A

SCI-UART B

SPI

Peripheral Bus

Datasheet available at: http://wwwDatasheet available at: http://www--s.ti.com/sc/ds/tms320f2812.pdf s.ti.com/sc/ds/tms320f2812.pdf

TMS320F2812/11/10TMS320F2812/11/10

High Performance DSP Core

Fast & flexible interrupt management Fast & flexible interrupt management significantly reduce interrupt latencysignificantly reduce interrupt latency

SingleSingle--cycle 32cycle 32--bit multiplier makes bit multiplier makes computationally intensive control computationally intensive control algorithms more efficientalgorithms more efficient

C28xC28xTMTM DSP CoreDSP Core

Three 32Three 32--bit timers support multiple bit timers support multiple control loops / time basescontrol loops / time bases

Single cycle readSingle cycle read--modifiedmodified--write in any write in any memory location and 32memory location and 32--bit registers bit registers improve control algorithm efficiencyimprove control algorithm efficiency

RealReal--time JTAG debug shortens time JTAG debug shortens development cycledevelopment cycle

C28xTM 32-bit DSP

Interrupt Management

32-bitRegister

FileReal-TimeJTAG

32-bitTimers (3)

32x32 bitMultiplier

R M WAtomic

ALU

C/C++ Efficient 32C/C++ Efficient 32--bit DSP Corebit DSP Core

Code compatible with the C24x familyCode compatible with the C24x family

C28x 1-Day Workshop - Introduction to the TMS320F281x 2 - 3

Page 14: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

TMS320F2812/11/10

Memory Sub-System

Quarter of a Megabyte of onQuarter of a Megabyte of on--chip chip Flash MemoryFlash Memory

128128--bit security protects software bit security protects software investmentinvestment

Fast program execution out of bothFast program execution out of bothRAM and Flash memoryRAM and Flash memory

100100--120 MIPS with Flash Acceleration Technology120 MIPS with Flash Acceleration Technology150 MIPS out of RAM for time150 MIPS out of RAM for time--critical codecritical code

External memory interface (XINTF) External memory interface (XINTF) supports systems with larger memory supports systems with larger memory models (up to 1MW address reach)models (up to 1MW address reach)

Memory SubMemory Sub--SystemSystem

Up to 128K x 16 FlashUp to 128K x 16 Flash(8 x 4K and 6 x 16K Sectors)(8 x 4K and 6 x 16K Sectors)

Memory Bus

128Kw Flash+ 2Kw OTP

4Kw Boot ROM

18Kw RAM

Code security

XINTF

32-bitRegister

FileReal-Time

JTAG

32-bitTimers (3)

C28xTM 32-bit DSP

32x32-bitMultiplier

R M WAtomic

ALU

Interrupt Management

Event Mgr A

Event Mgr B

12-Bit ADC

Watchdog

GPIO

McBSP

CAN 2.0B

SCI-UART A

SCI-UART B

SPI

Peripheral Bus

Flash MemoryFlash Memory

Control Peripherals

8 ADC Inputs

Control PeripheralsControl Peripherals

Fast & Flexible Fast & Flexible 1212--bit 16bit 16--Channel ADCChannel ADC

12.5 MSPS throughput (80ns pipeline 12.5 MSPS throughput (80ns pipeline conversion, 200ns single conversion) conversion, 200ns single conversion) Dual sample/hold enable simultaneous Dual sample/hold enable simultaneous sampling or sequencing sampling modessampling or sequencing sampling modesAnalog input: 0V to 3VAnalog input: 0V to 3V16 channel, multiplexed inputs16 channel, multiplexed inputsAuto Sequencer supports up to 16 Auto Sequencer supports up to 16 conversions without CPU interventionconversions without CPU interventionSequencer can be operated as two Sequencer can be operated as two independent 8independent 8--state sequencers or as state sequencers or as one large 16one large 16--state sequencerstate sequencerSixteen result registers (individually Sixteen result registers (individually addressable) to store conversion valuesaddressable) to store conversion values

ResultRegisters

16 words

AnalogMUX

Prescaler

S/HA

12-bitADC

Module8 ADC Inputs

AnalogMUX

S/HB

SYSCLK

Start of Conversion Auto Sequencer

ADC

1212--bit Analogbit Analog--toto--Digital ConverterDigital Converter

2 - 4 C28x 1-Day Workshop - Introduction to the TMS320F281x

Page 15: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

TMS320F2812/11/10

1616 PWMsPWMs

6 Complimentary Pairs + 4 6 Complimentary Pairs + 4 Independent + Trip Inputs + Independent + Trip Inputs + Programmable DeadProgrammable Dead--BandsBands

10 1610 16--bit Compares,bit Compares,4 General Purpose Timers4 General Purpose Timers

6.67nS max PWM Resolution6.67nS max PWM Resolution

2 2 QuadratureQuadrature Encoder Interface Encoder Interface with Index Inputwith Index Input

6 Capture Inputs With 6 Capture Inputs With Programmable ResolutionProgrammable Resolution

Control Peripherals (EVA + EVB)Control Peripherals (EVA + EVB)GP Timer 1

(Counter & Period)

GP Timer 2(Counter & Period)

CaptureMUX

ClockSelect

GP Compare 1 OutputLogic

T1PWM/T1CMP

OutputLogic

T2PWM/T2CMPGP Compare 2PWM

Trip EnableController

5 PWMTRIPs/PDPINTs

6 PWMsFull Compare Dead

BandLogic

OutputLogic

TMRCLK

TIMERDIRTMRDIR

TIMERCLK

3 CAP/QEP

Event Manager (1 Module)

QEP & MUX

InputLogic

Two Event ManagersTwo Event Managers

Communication Ports

Communications PortsCommunications Ports

FullFull--duplex communicationduplex communication

1616--level, 32level, 32--bit transmit/receive bit transmit/receive FIFOsFIFOs

8, 12, 16, 20, 24, and 328, 12, 16, 20, 24, and 32--bit databit data

88--bit data, option of LSB or MSB bit data, option of LSB or MSB transmitted firsttransmitted first

128 channels for reception and 128 channels for reception and transmissiontransmission

Direct interface to SPI & IIS devicesDirect interface to SPI & IIS devices

Multi ChannelSelection

Logic

DR

DXTransmitChannel

Registers

Receive Channel

Registers

Interrupt &Events

Interrupt Select Logic

32-bitReadFIFO

ModeSelect

XMIT/ReceiveFIFO Control

Regs

Perip

hera

l Bus

FIFO Interface McBSP ModuleMcBSP

MultiMulti--Channel Buffered Serial PortChannel Buffered Serial Port

32-bitWriteFIFO

C28x 1-Day Workshop - Introduction to the TMS320F281x 2 - 5

Page 16: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

TMS320F2812/11/10

Communications PortsCommunications Ports

Mailbox RAM(512 bytes)

32-MessageMailbox

Message eController

Enhanced eCAN Controller 32

DataAddressControls

32

32

32

Memory Management

Unit

CPU Interface,Receive Control

UnitTimer

Management Unit

eCAN Control Registers

eCAN Protocol Kernel

CommunicationBuffers*

3.3-V CAN TransceiverCAN Bus

* The communication buffers are transparent to the user and are not accessible by user code

Enhanced Controller Area NetworkEnhanced Controller Area Network

2.0B compliant 2.0B compliant

32 Mailboxes32 Mailboxes

32 Local receive masks32 Local receive masks

32 Interrupt masks32 Interrupt masks

LowLow--power modepower mode

Programmable wakeProgrammable wake--up on bus up on bus activityactivity

Automatic reply to a remote message Automatic reply to a remote message requestrequest

TimeTime--stamping of messagesstamping of messages

SCISCI--UART (2 modules)UART (2 modules)Two wake up multiprocessor Two wake up multiprocessor modes idlemodes idle--line and address bitline and address bit

Half or full duplex operationHalf or full duplex operation

1616--level transmit / receive FIFO level transmit / receive FIFO bufferbuffer

AutoAuto--baudbaud--detect Hardware Logicdetect Hardware Logic

SPISPIDelayed transmit controlDelayed transmit control

16 level transmit / receive FIFO16 level transmit / receive FIFO

SCITXD

BCIRXD

SystemControl Block

SCIAENCLK

Perip

hera

lBus

SCITXINT

SCIRXINT

SCI

Reg

iste

rs

Low SpeedPrescaler

LSPCLK

CPUSYSCLKOUT

Interrupt Handling Module

SPICLK

SPISTE

SystemControl Block

SPIAENCLK

Perip

hera

lBus

SPITXINT

SPIRXINT

SPI

Reg

iste

rs

Low SpeedPrescaler

LSPCLK

CPUSYSCLKOUT

Interrupt Handling Module

SPISIMO

SPICOMI

GPIOMUX

GPIOMUX

SCI/CPU Interface

SPI/CPU Interface

Communication PortsCommunication Ports

SCI (UART) and SPISCI (UART) and SPI

2 - 6 C28x 1-Day Workshop - Introduction to the TMS320F281x

Page 17: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

TMS320F2812/11/10

TMS320F2812 Memory Map

TMS320F2812 Memory MapTMS320F2812 Memory MapMO SARAM (1K)MO SARAM (1K)

M1 SARAM (1K)M1 SARAM (1K)

LO SARAM (4K)LO SARAM (4K)L1 SARAM (4K)L1 SARAM (4K)

HO SARAM (8K)HO SARAM (8K)

Boot ROM (4K)Boot ROM (4K)MP/MC=0MP/MC=0

BROM vector (32)BROM vector (32)MP/MC=0 ENPIE=0MP/MC=0 ENPIE=0

OTP (1K)OTP (1K)

FLASH (128K)FLASH (128K)

reserved

reserved

reservedPF 0 (2K)PF 0 (2K)

reserved

reservedPF 1 (4K)PF 1 (4K)reservedPF 2 (4K)PF 2 (4K)

reservedPIE vectorPIE vector

(256)(256)ENPIE=1ENPIE=1 XINT Zone 0 (8K)

XINT Zone 1 (8K)

XINT Zone 2 (0.5M)XINT Zone 6 (0.5M)

XINT Zone 7 (16K)MP/MC=1

XINT Vector-RAM (32)MP/MC=1 ENPIE=0

reserved

reserved

reserved

Data | ProgramData | Program0x00 00000x00 0000

0x00 04000x00 0400

0x00 08000x00 08000x00 0D000x00 0D00

0x00 10000x00 10000x00 60000x00 60000x00 70000x00 70000x00 80000x00 8000

0x00 90000x00 9000

0x00 A0000x00 A0000x3D 78000x3D 7800

0x3D 80000x3D 8000

0x3F 80000x3F 8000

0x3F A0000x3F A0000x3F F0000x3F F000

0x3F FFC00x3F FFC0

0x3F C0000x3F C000

0x18 00000x18 00000x10 00000x10 00000x08 00000x08 0000

0x00 40000x00 40000x00 20000x00 2000

Data | ProgramData | Program

128128--Bit PasswordBit Password

CSM: LO, L1CSM: LO, L1OTP, FLASHOTP, FLASH

reserved0x3D 7C000x3D 7C00

Fast Interrupt Manager

C28x Fast Interrupt Response ManagerC28x Fast Interrupt Response Manager

96 dedicated PIE 96 dedicated PIE vectorsvectorsNo software decision No software decision making requiredmaking requiredDirect access to RAM Direct access to RAM vectorsvectorsAuto flags updateAuto flags updateConcurrent auto Concurrent auto context savecontext save

28x CPU Interrupt logic28x CPU Interrupt logic

28x28xCPUCPUINTMINTMIFRIFR IERIER96 96

Perip

hera

l Int

erru

pts

12x

8 =

96Pe

riphe

ral I

nter

rupt

s 1

2x8

= 96

12 interrupts12 interrupts

INT1 to INT1 to INT12INT12

PPeripheraleripheralIInterruptnterrupt

EExpansionxpansion

PIEPIE module module For 96 For 96

interruptsinterrupts

Multiplier (T, PH, PL)Multiplier (T, PH, PL)Accumulator (AH, AL)Accumulator (AH, AL)Status Status RegReg (ST0, ST1)(ST0, ST1)Program CounterProgram CounterAux. Register 0 & 1Aux. Register 0 & 1Interrupt Enable Interrupt Enable RegRegData Page PointerData Page Pointer

Auto Context SaveAuto Context Save

Minimum interrupt latency of 14 Minimum interrupt latency of 14 –– 16 cycles16 cycles(approximately 100ns at 150MHz)(approximately 100ns at 150MHz)

C28x 1-Day Workshop - Introduction to the TMS320F281x 2 - 7

Page 18: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

TMS320F2812/11/10

This page is intentionally blank.

2 - 8 C28x 1-Day Workshop - Introduction to the TMS320F281x

Page 19: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Development Tools

Introduction This module will discuss the various development tools that are available for the design process. These development tools will include the Code Composer Studio (CCS) integrated development environment (IDE), the F28xx Peripheral Register Header Files, and the IQmath Library. The Periperal Register Header files simplify the programming of the many peripherals on the C28x family of devices. The IQmath library can seamlessly port floating-point algorithms into fixed-point code. Additionally, the setup and operation of the TMS320F2812 eZdsp™ kit will be explained.

Learning Objectives Learning ObjectivesLearning Objectives

Explore Code Composer Studio Explore Code Composer Studio Development EnvironmentDevelopment EnvironmentUnderstanding the usage of the F28xx Understanding the usage of the F28xx Peripheral Register Header FilesPeripheral Register Header FilesDescribe the use of the Describe the use of the IQmathIQmath Library Library Explain Explain eZdspeZdsp™™ F2812 Features and F2812 Features and HardwareHardwareReview Review eZdspeZdsp™™ and PC Connectionsand PC Connections

C28x 1-Day Workshop - Development Tools 3 - 1

Page 20: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Module Topics

Module Topics Development Tools .................................................................................................................................... 3-1

Module Topics......................................................................................................................................... 3-2 Code Composer Studio Development Environment ................................................................................ 3-3

CCS Project ........................................................................................................................................ 3-4 Build Options...................................................................................................................................... 3-5

F28xx Peripheral Register Header Files ................................................................................................ 3-6 IQmath Library ....................................................................................................................................... 3-8 eZdsp™ F2812.......................................................................................................................................3-10

eZdsp™ F2812 Hardware..................................................................................................................3-10 Bootloader Options............................................................................................................................3-11 Connecting the eZdsp™ to PC ..........................................................................................................3-11

Lab 3: eZdsp™ F2812 ...........................................................................................................................3-12

3 - 2 C28x 1-Day Workshop - Development Tools

Page 21: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Code Composer Studio Development Environment

Code Composer Studio Development Environment Code Composer StudioCode Composer Studio

Code Composer Studio includes:Code Composer Studio includes:Integrated Edit/Debug GUIIntegrated Edit/Debug GUICode Generation ToolsCode Generation ToolsDSP/BIOSDSP/BIOS

AsmAsm LinkLink

EditEdit

DebugDebug

CompileCompile Probe InProbe In

Probe OutProbe OutGraphsGraphsProfilingProfiling

SIMSIM

eZdspeZdsp™™

EVMEVM

Third Third PartyParty

XDSXDS

DSPDSPBoardBoard

DSP/BIOSDSP/BIOSConfigConfigToolTool

DSP/BIOSDSP/BIOSLibrariesLibraries

lnk.cmdlnk.cmdBuildBuild

Code Composer StudioCode Composer StudioHelpHelp CPU CPU

WindowWindow

Memory windowMemory windowGraph Graph windowwindow

Project Manager:Project Manager:Source & object filesSource & object filesFile dependenciesFile dependenciesCompiler, Assembler Compiler, Assembler

& Linker build options& Linker build options

Status Status windowwindow

Full C/C++ & Assembly Full C/C++ & Assembly Debugging:Debugging:

C & ASM SourceC & ASM SourceMixed modeMixed modeDisassembly (patch)Disassembly (patch)Set Break PointsSet Break PointsSet probe PointsSet probe Points

Watch windowWatch windowEditor:Editor:

Structure ExpansionStructure Expansion

Menus or IconsMenus or Icons

C28x 1-Day Workshop - Development Tools 3 - 3

Page 22: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Code Composer Studio Development Environment

Code Composer Studio: IDECode Composer Studio: IDE

IntegratesIntegrates: edit, code generation, : edit, code generation,

and debugand debug

SingleSingle--click accessclick access using buttonsusing buttons

Powerful Powerful graphing/profilinggraphing/profiling toolstools

Automated tasks using Automated tasks using GEL scriptsGEL scripts

BuiltBuilt--in access to in access to BIOSBIOS functionsfunctions

Support TI or 3Support TI or 3rdrd party party plugplug--insins

CCS Project

The CCS ProjectThe CCS Project

Source files (by reference)Source files (by reference)Source (C, assembly)Source (C, assembly)LibrariesLibrariesDSP/BIOS configurationDSP/BIOS configurationLinker command filesLinker command files

Project settings:Project settings:Build Options (compiler and Build Options (compiler and assembler)assembler)Build configurationsBuild configurationsDSP/BIOSDSP/BIOSLinkerLinker

Project (.Project (.pjtpjt) files contain:) files contain:

3 - 4 C28x 1-Day Workshop - Development Tools

Page 23: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Code Composer Studio Development Environment

Build Options

Build Options GUI Build Options GUI -- CompilerCompiler

GUI has 8 pages of categories for code GUI has 8 pages of categories for code generation toolsgeneration toolsControls many aspects of the build process, Controls many aspects of the build process, such as:such as:

Optimization levelOptimization levelTarget deviceTarget deviceCompiler/assembly/link optionsCompiler/assembly/link options

Build Options GUI Build Options GUI -- LinkerLinker

GUI has 2 categories GUI has 2 categories for linkingfor linkingSpecifies various link Specifies various link optionsoptions““..\\DebugDebug\\”” indicates indicates on subfolder level on subfolder level below project (.below project (.pjtpjt) ) locationlocation

C28x 1-Day Workshop - Development Tools 3 - 5

Page 24: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

F28xx Peripheral Register Header Files

F28xx Peripheral Register Header Files DSP281x Header File PackageDSP281x Header File Package

(http://(http://www.ti.comwww.ti.com, literature # SPRC097), literature # SPRC097)

Simplifies program of peripherals and Simplifies program of peripherals and other functionsother functionsTakes care of register definitions and Takes care of register definitions and addressesaddressesHeader file package consists of:Header file package consists of:

\\DSP281x_headersDSP281x_headers\\include include .h files.h files\\DSP281x_commonDSP281x_common\\src src .c source files.c source files\\DSP281x_headersDSP281x_headers\\cmd cmd linker command fileslinker command files\\DSP281x_headersDSP281x_headers\\gel gel .gel files for CCS.gel files for CCS\\DSP281x_examples DSP281x_examples example programsexample programs\\doc doc documentationdocumentation

TI has done all of the work for you!TI has done all of the work for you!

Structure Naming ConventionsStructure Naming Conventions

The DSP281x header files define:The DSP281x header files define:All of the peripheral structuresAll of the peripheral structuresAll of the register namesAll of the register namesAll of the bit field namesAll of the bit field namesAll of the register addressesAll of the register addresses

PeripheralName.RegisterName.allPeripheralName.RegisterName.all // Access full 16 or 32// Access full 16 or 32--bit registerbit register

PeripheralName.RegisterName.half.LSWPeripheralName.RegisterName.half.LSW // Access low 16// Access low 16--bits of 32bits of 32--bit registerbit register

PeripheralName.RegisterName.half.MSWPeripheralName.RegisterName.half.MSW // Access high 16// Access high 16--bits of 32bits of 32--bit registerbit register

PeripheralName.RegisterName.bit.FieldNamePeripheralName.RegisterName.bit.FieldName // Access specified bit fields of register// Access specified bit fields of register

Notes: [1] Notes: [1] ““PeripheralNamePeripheralName”” are assigned by TI and found in the DSP281x header files. are assigned by TI and found in the DSP281x header files. They are a combination of capital and smalThey are a combination of capital and small letters (i.e. CpuTimer0Regs).l letters (i.e. CpuTimer0Regs).

[2] [2] ““RegisterNameRegisterName”” are the same names as used in the data sheet. are the same names as used in the data sheet. They are always in capital letters (i.e. TThey are always in capital letters (i.e. TCR, TIM, TPR,..).CR, TIM, TPR,..).

[3] [3] ““FieldNameFieldName”” are the same names as used in the data sheet.are the same names as used in the data sheet.They are always in capital letters (i.e. PThey are always in capital letters (i.e. POL, TOG, TSS,..). OL, TOG, TSS,..).

3 - 6 C28x 1-Day Workshop - Development Tools

Page 25: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

F28xx Peripheral Register Header Files

The CCS Watch Window using StructuresThe CCS Watch Window using Structures

Code Maestro to the Rescue!Code Maestro to the Rescue!

C28x 1-Day Workshop - Development Tools 3 - 7

Page 26: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

IQmath Library

IQmath Library

Porting TimePorting Time

Perf

orm

ance

Perf

orm

ance

FastFast

SlowSlow

Traditional FixedTraditional Fixed--Point Point ““QQ”” Math ApproachMath Approach

““IQmathIQmath””ApproachApproach

Control algorithms Control algorithms typically start in a typically start in a FloatingFloating--Point formatPoint format

The conversion of such The conversion of such algorithms, to run on a algorithms, to run on a fixedfixed--point machine, is point machine, is a laborious and timea laborious and time--consuming taskconsuming task

The 32The 32--bit math bit math capabilities of the capabilities of the C28xC28xTMTM core enable a core enable a new C/C++ approach, new C/C++ approach, which makes this task which makes this task easier and much faster easier and much faster –– optimized to take optimized to take advantage of C28xadvantage of C28xTMTM

architecturearchitecture

FloatingFloating--PointPointAlgorithmAlgorithm

ShortShort LongLong

IQmath Library: Floating Point IQmath Library: Floating Point ““Ease of UseEase of Use”” on a Fixed Point Machine on a Fixed Point Machine

IQ Fractional RepresentationIQ Fractional Representation

S IIIIIIII fffffffffffffffffffffff031

32 bit mantissa

-2I + 2I-1 + … + 21 + 20 . 2-1 + 2-2 + … + 2-Q

3 - 8 C28x 1-Day Workshop - Development Tools

Page 27: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

IQmath Library

IQmathIQmath

and then spend many hours and then spend many hours converting to a fixed point algorithm converting to a fixed point algorithm which is not easy to readwhich is not easy to read

float Y, M, X, B;float Y, M, X, B;

Y = M * X + B;Y = M * X + B;

intint Y, M, X, B; //Q1 to Q15Y, M, X, B; //Q1 to Q15Y = ((M * X) + B << Q) >> Q);Y = ((M * X) + B << Q) >> Q);

(Using (Using IQmathIQmath in C):in C):__iqiq Y, M, X, B; //Q1 to Q30Y, M, X, B; //Q1 to Q30

Y = _Y = _IQmpy(MIQmpy(M, X) + B;, X) + B;

(Using (Using IQmathIQmath in C++):in C++):iqiq Y, M, X, B; //Q1 to Q30Y, M, X, B; //Q1 to Q30

Y = M * X + B;Y = M * X + B;

Users typically start with a floating Users typically start with a floating point algorithm,..point algorithm,..

IQmathIQmath reduces this effort dramatically andreduces this effort dramatically andthe code is easier to read (looks the code is easier to read (looks ““naturalnatural””))

Increased numerical resolution of algorithms from 16Increased numerical resolution of algorithms from 16--bits to 32/64bits to 32/64--bitsbitsReduced time to implement/port/debug math algorithms in C/C++Reduced time to implement/port/debug math algorithms in C/C++

TypicalTypical

IQmathIQmathA mathematical approach and a set of supporting A mathematical approach and a set of supporting

math libraries that enable the following:math libraries that enable the following:

IQmathIQmath Approach SummaryApproach Summary

Seamless portability of code between fixed and floatingSeamless portability of code between fixed and floating--point devicespoint devices

User selects target math type in User selects target math type in ““IQmathLib.hIQmathLib.h”” filefile#if MATH_TYPE == IQ_MATH#if MATH_TYPE == IQ_MATH#if MATH_TYPE == FLOAT_MATH#if MATH_TYPE == FLOAT_MATH

One source code set for simulation vs. target deviceOne source code set for simulation vs. target deviceNumerical resolution adjustability based on application Numerical resolution adjustability based on application requirementrequirement

Set in Set in ““IQmathLib.hIQmathLib.h”” filefile#define GLOBAL_Q 18#define GLOBAL_Q 18

Explicitly specify Q valueExplicitly specify Q value_iq20 X, Y, Z;_iq20 X, Y, Z;

Numerical accuracy without sacrificing time and cyclesNumerical accuracy without sacrificing time and cyclesRapid conversion/porting and implementation of algorithmsRapid conversion/porting and implementation of algorithms

IQmathIQmath library is freeware library is freeware -- available from TI DSP websiteavailable from TI DSP websitehttp://http://www.dspvillage.ti.comwww.dspvillage.ti.com (follow C2000 DSP links)(follow C2000 DSP links)

““IQmathIQmath”” + fixed+ fixed--point processor with 32point processor with 32--bit capabilities =bit capabilities =

C28x 1-Day Workshop - Development Tools 3 - 9

Page 28: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

eZdsp™ F2812

eZdsp™ F2812 eZdspeZdsp™™ F2812 FeaturesF2812 Features

TMS320F2812 Digital Signal ProcessorTMS320F2812 Digital Signal Processor150 MIPS Operating Speed150 MIPS Operating Speed18K Words On18K Words On--chip RAMchip RAM128K Words On128K Words On--chip Flash Memorychip Flash Memory64K Words Off64K Words Off--chip SRAM Memorychip SRAM Memory30 MHz Clock30 MHz ClockExpansion ConnectorsExpansion ConnectorsOnOn--board IEEE 1149.1 JTAG Controllerboard IEEE 1149.1 JTAG ControllerTI F28xx CCS Tools DriverTI F28xx CCS Tools Driver

eZdsp™ F2812 Hardware

eZdspeZdsp™™ F2812 HardwareF2812 Hardware

Parallel Port/Parallel Port/JTAGJTAG

ControllerControllerInterface (P3)Interface (P3)

I/O Interface (P4/P8/P7)I/O Interface (P4/P8/P7)ANALOGANALOGInterface (P5/P9)Interface (P5/P9)

SRAMSRAM64K x 1664K x 16

JTAG Interface (P1)JTAG Interface (P1) EXPANSIONEXPANSIONData & Address (P2)Data & Address (P2)

PowerPowerConnector (P6)Connector (P6)

+5V+5V TMS320F2812 TMS320F2812 -- DSPDSP

BootloaderBootloaderGPIO PinsGPIO Pins

3 - 10 C28x 1-Day Workshop - Development Tools

Page 29: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

eZdsp™ F2812

Bootloader Options

BootloaderBootloader OptionsOptions

GPIO pinsGPIO pinsF4 F12 F3 F2F4 F12 F3 F21 x x x jump to 1 x x x jump to FLASHFLASH address 0x3F 7FF6 *address 0x3F 7FF6 *0 0 1 0 jump to 0 0 1 0 jump to H0 SARAMH0 SARAM address 0x3F 8000 *address 0x3F 8000 *0 0 0 1 jump to 0 0 0 1 jump to OTPOTP address 0x3D 7800 *address 0x3D 7800 *0 1 x x 0 1 x x bootloadbootload external EEPROM to onexternal EEPROM to on--chip memory via chip memory via SPISPI portport0 0 1 1 0 0 1 1 bootloadbootload code to oncode to on--chip memory via chip memory via SCISCI--AA portport0 0 0 0 0 0 0 0 bootloadbootload code to oncode to on--chip memory via chip memory via GPIO port BGPIO port B (parallel)(parallel)

Boot determined by state of GPIO pinsBoot determined by state of GPIO pins

ExecutionExecution BootloadingBootloadingEntry PointEntry Point RoutinesRoutines

FLASHFLASH SPISPIH0 SARAMH0 SARAM SCISCI--AA

OTPOTP Parallel loadParallel load

Connecting the eZdsp™ to PC

Connecting the Connecting the eZdspeZdsp™™ to your PCto your PC

Code Composer Studio Code Composer Studio –– eZdspeZdsp™™ F2812 ConfigurationF2812 Configuration

eZdspeZdsp™™ F2812F2812

25 Conductor Cable25 Conductor Cable

To wall outletTo wall outlet

PowerPowerSupplySupply

25 pin male25 pin maleDD--sub connectorsub connector(Plugs into parallel(Plugs into parallelport on PC)port on PC)

25 pin male25 pin maleDD--sub connectorsub connector

25 pin female25 pin femaleDD--sub connectorsub connector

C28x 1-Day Workshop - Development Tools 3 - 11

Page 30: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Lab 3: eZdsp™ F2812

Lab 3: eZdsp™ F2812 Lab 3: Lab 3: eZdspeZdsp™™ F2812 KitF2812 Kit

Setup the Setup the eZdspeZdsp™™ F2812 kit using F2812 kit using the quick start guidethe quick start guide

Install Code Composer Studio with Install Code Composer Studio with driversdriversConnect Connect eZdspeZdsp™™ hardware to PChardware to PCConfigure and setup CCS softwareConfigure and setup CCS softwareStart CCS by clicking on iconStart CCS by clicking on icon

Review Appendix A and onReview Appendix A and on--line line help/documentationhelp/documentation

3 - 12 C28x 1-Day Workshop - Development Tools

Page 31: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Control Peripherals

Introduction This module explains the operation of the analog-to-digital converter (ADC) and Event Manager. The ADC system consists of a 12-bit analog-to-digital converter with 16 analog input channels. The analog input channels have a range from 0 to 3 volts. Two input analog multiplexers are used, each supporting 8 analog input channels. Each multiplexer has its own dedicated sample and hold circuit. Therefore, sequential, as well as simultaneous sampling is supported. Also, the ADC system features programmable auto sequence conversions with 16 results registers. Start of conversion (SOC) can be performed by an external trigger, software, or an Event Manager event. The Event Manager system generates PWM waveforms using the timers and compare units. Also, the capture units and the quadrature encoder pulse circuit will be discussed. All devices of the F281x family have two event managers, EVA and EVB. These two event managers are identical to each other in terms of functionality. Register mapping and bit definitions are also identical, with the exception of naming conventions and register addresses. Therefore, for simplicity, only the functionality of EVA will be explained.

Learning Objectives

Learning ObjectivesLearning Objectives

Explain the operation of the AnalogExplain the operation of the Analog--toto--Digital ConverterDigital ConverterPulse Width Modulation (PWM) ReviewPulse Width Modulation (PWM) ReviewGenerate PWM with the Event Manager:Generate PWM with the Event Manager:

GeneralGeneral--Purpose TimerPurpose TimerCompare UnitsCompare Units

Explain other Event Manager functions:Explain other Event Manager functions:Capture UnitsCapture UnitsQuadratureQuadrature Encoder Pulse (QEP) CircuitEncoder Pulse (QEP) Circuit

Note:Note: Two identical Event Manager (EVA and EVB) modulesTwo identical Event Manager (EVA and EVB) modulesare available. For simplicity, only EVA will be explaare available. For simplicity, only EVA will be explained.ined.

C28x 1-Day Workshop - Control Peripherals 4 - 1

Page 32: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Module Topics

Module Topics Control Peripherals................................................................................................................................... 4-1

Module Topics......................................................................................................................................... 4-2 Analog-to-Digital Converter................................................................................................................... 4-3 Event Manager........................................................................................................................................ 4-5

PWM Waveforms ............................................................................................................................... 4-5 General Purpose Timers ..................................................................................................................... 4-7 Compare Units.................................................................................................................................... 4-8 Capture Units.....................................................................................................................................4-11 Quadrature Encoder Pulse .................................................................................................................4-13

Lab 4: Control Peripherals....................................................................................................................4-15

4 - 2 C28x 1-Day Workshop - Control Peripherals

Page 33: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Analog-to-Digital Converter

Analog-to-Digital Converter ADC ModuleADC Module

1212--bit resolution ADC corebit resolution ADC coreSixteen analog inputs (range of 0 to 3V)Sixteen analog inputs (range of 0 to 3V)Two analog input multiplexersTwo analog input multiplexers

Up to 8 analog input channels eachUp to 8 analog input channels eachTwo sample/hold units (for each input Two sample/hold units (for each input muxmux))Sequential and simultaneous sampling modesSequential and simultaneous sampling modesAutosequencingAutosequencing capability capability -- up to 16 up to 16 autoconversionsautoconversions

Two independent 8Two independent 8--state sequencersstate sequencers““DualDual--sequencer modesequencer mode””““Cascaded modeCascaded mode””

Sixteen individually addressable result registersSixteen individually addressable result registersMultiple trigger sources for startMultiple trigger sources for start--ofof--conversionconversion

External trigger, S/W, and Event Manager eventsExternal trigger, S/W, and Event Manager events

ADC Module Block Diagram ADC Module Block Diagram (Cascaded Mode)(Cascaded Mode)

1212--bit A/Dbit A/DConverterConverter

ResultResultSelectSelect

Result MUXResult MUXRESULT0RESULT0

. . .

. . .

RESULT1RESULT1RESULT2RESULT2

RESULT15RESULT15

CHSEL00 CHSEL00 (state 0)(state 0)CHSEL01 CHSEL01 (state 1)(state 1)CHSEL02 CHSEL02 (state 2)(state 2)CHSEL03 CHSEL03 (state 3)(state 3)

CHSEL15 CHSEL15 (state 15)(state 15)

......

MAX_CONV1MAX_CONV1

AutosequencerAutosequencer

Start SequenceStart SequenceTriggerTrigger

SOCSOC EOCEOC

SoftwareSoftwareEVAEVAEVBEVB

Ext Pin (ADCSOC)Ext Pin (ADCSOC)

Analog MUXAnalog MUX

MUXMUXAA

ADCINA0ADCINA0ADCINA1ADCINA1

ADCINA7ADCINA7

......

MUXMUXBB

ADCINB0ADCINB0ADCINB1ADCINB1

ADCINB7ADCINB7

......

S/HS/HAA

S/HS/HMUXMUX

S/HS/HBB

C28x 1-Day Workshop - Control Peripherals 4 - 3

Page 34: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Analog-to-Digital Converter

ADC Module Block Diagram ADC Module Block Diagram (Dual(Dual--Sequencer mode)Sequencer mode)

1212--bit A/Dbit A/DConverterConverter

SoftwareSoftwareEVAEVA

Ext PinExt Pin(ADCSOC)(ADCSOC)

ResultResultSelectSelect

Result MUXResult MUXRESULT0RESULT0

. . .

. . .

RESULT1RESULT1

RESULT7RESULT7

ResultResultSelectSelect

RESULT8RESULT8

. . .

. . .

RESULT9RESULT9

RESULT15RESULT15

CHSEL00 CHSEL00 (state 0)(state 0)CHSEL01 CHSEL01 (state 1)(state 1)CHSEL02 CHSEL02 (state 2)(state 2)

CHSEL07 CHSEL07 (state 7)(state 7)......

MAX_CONV1MAX_CONV1

AutosequencerAutosequencer

Start SequenceStart SequenceTriggerTrigger

SOC1/SOC1/EOC1EOC1

SEQ1SEQ1

CHSEL08 CHSEL08 (state 8)(state 8)CHSEL09 CHSEL09 (state 9)(state 9)CHSEL10 CHSEL10 (state 10)(state 10)

CHSEL15 CHSEL15 (state 15)(state 15)

......MAX_CONV2MAX_CONV2

AutosequencerAutosequencer

Start SequenceStart SequenceTriggerTrigger

SEQ2SEQ2

SequencerSequencerArbiterArbiter

SOC2/SOC2/EOC2EOC2

SoftwareSoftwareEVBEVB

Analog MUXAnalog MUX

MUXMUXAA

ADCINA0ADCINA0ADCINA1ADCINA1

ADCINA7ADCINA7

......

MUXMUXBB

ADCINB0ADCINB0ADCINB1ADCINB1

ADCINB7ADCINB7

......

S/HS/HAA

S/HS/HMUXMUX

S/HS/HBB

ADC Control Registers ADC Control Registers (file: (file: Adc.cAdc.c))

ADCTRL1ADCTRL1Module ResetModule ResetContinuous Run / Stop EOSContinuous Run / Stop EOSSequencer Mode (cascaded / dual)Sequencer Mode (cascaded / dual)Acquisition Time Acquisition Time PrescalePrescale (S/H)(S/H)

ADCTRL2ADCTRL2EV SOC; Start Conversion (s/w trigger); EV SOC mask bitEV SOC; Start Conversion (s/w trigger); EV SOC mask bitReset SEQReset SEQInterrupt Enable; Interrupt Mode: every EOS / every other EOSInterrupt Enable; Interrupt Mode: every EOS / every other EOS

ADCTRL3ADCTRL3ADC Clock ADC Clock PrescalePrescaleSampling Mode (sequential / simultaneous)Sampling Mode (sequential / simultaneous)

ADCMAXCONVADCMAXCONVMaximum number of Maximum number of autoconversionsautoconversions

ADCCHSELSEQxADCCHSELSEQx {x=1{x=1--4}4}Channel select sequencingChannel select sequencing

ADCRESULTxADCRESULTx {x=0{x=0--15}15}

4 - 4 C28x 1-Day Workshop - Control Peripherals

Page 35: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Event Manager

Event Manager Event Manager Block Diagram Event Manager Block Diagram (EVA)(EVA)

PWM CircuitsPWM CircuitsPWM CircuitsPWM CircuitsPWM CircuitsPWM Circuits

Output LogicOutput LogicOutput LogicOutput LogicOutput LogicOutput Logic

GP Timer 1 CompareGP Timer 1 CompareGP Timer 1GP Timer 1

GP Timer 2 CompareGP Timer 2 CompareGP Timer 2GP Timer 2

Compare Unit 1Compare Unit 1Compare Unit 2Compare Unit 2Compare Unit 3Compare Unit 3

Capture UnitsCapture Units

MUXMUXQEPQEP

CircuitCircuit

Output LogicOutput Logic

Output LogicOutput Logic

EV Control Registers / LogicEV Control Registers / Logic

ResetReset PIEPIETCLKINA / TDIRATCLKINA / TDIRA// 22ADC StartADC Start

Dat

a B

usD

ata

Bus

••

CLKCLKDIRDIR

••••

T1CMP/T1PWMT1CMP/T1PWM

T2CMP/T2PWMT2CMP/T2PWM

PWM1PWM1PWM2PWM2PWM3PWM3PWM4PWM4PWM5PWM5PWM6PWM6

CAP1/QEP1CAP1/QEP1CAP2/QEP2CAP2/QEP2CAP3/QEPI1CAP3/QEPI1••

PWM Waveforms

TTtt

PWM representationPWM representation PAM representationPAM representationTT

tt

ttOriginal SignalOriginal Signal

PWM Signal RepresentationPWM Signal Representation

same areas (energy)same areas (energy)

C28x 1-Day Workshop - Control Peripherals 4 - 5

Page 36: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Event Manager

Asymmetric PWM WaveformAsymmetric PWM Waveform

CounterCounter

PeriodPeriod

CompareCompare

TTpwmpwm / / TTcmpcmp PinPin(active high)(active high) Caused by Period matchCaused by Period match

(toggle output in (toggle output in AsymAsym mode only)mode only)

Caused by Compare matchCaused by Compare match

TTPWMPWM

Symmetric PWM WaveformSymmetric PWM Waveform

CounterCounter

CompareCompare

PeriodPeriod

TTPWMPWM

TTPWMPWM /T/TCMPCMP PinPin(active high)(active high)

InterruptsInterrupts

PeriodPeriodCompareCompareCounterCounter

General Purpose TimerGeneral Purpose Timer

TTPWMPWM/T/TCMPCMP PinPinCompareCompareCompareCompareCompareCompare

Full Compare UnitsFull Compare UnitsPWM1PWM1PWM2PWM2PWM3PWM3PWM4PWM4PWM5PWM5PWM6PWM6

4 - 6 C28x 1-Day Workshop - Control Peripherals

Page 37: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Event Manager

General Purpose Timers

GeneralGeneral--Purpose Timers Purpose Timers (EVA)(EVA)

PWM CircuitsPWM CircuitsPWM CircuitsPWM CircuitsPWM CircuitsPWM Circuits

Output LogicOutput LogicOutput LogicOutput LogicOutput LogicOutput Logic

GP Timer 1 CompareGP Timer 1 CompareGP Timer 1GP Timer 1

GP Timer 2 CompareGP Timer 2 CompareGP Timer 2GP Timer 2

Compare Unit 1Compare Unit 1Compare Unit 2Compare Unit 2Compare Unit 3Compare Unit 3

Capture UnitsCapture Units

MUXMUXQEPQEP

CircuitCircuit

Output LogicOutput Logic

Output LogicOutput Logic

EV Control Registers / LogicEV Control Registers / Logic

ResetReset PIEPIETCLKINA / TDIRATCLKINA / TDIRA// 22ADC StartADC Start

Dat

a B

usD

ata

Bus

••

CLKCLKDIRDIR

••••

T1CMP/T1PWMT1CMP/T1PWM

T2CMP/T2PWMT2CMP/T2PWM

PWM1PWM1PWM2PWM2PWM3PWM3PWM4PWM4PWM5PWM5PWM6PWM6

CAP1/QEP1CAP1/QEP1CAP2/QEP2CAP2/QEP2CAP3/QEPI1CAP3/QEPI1••

GeneralGeneral--Purpose Timer Block Diagram Purpose Timer Block Diagram (EVA)(EVA)

16 16 -- Bit TimerBit TimerCounterCounter

TxCMPRTxCMPR . 15 . 15 -- 00

GPTCONAGPTCONATxCNTTxCNT . 15 . 15 -- 00

CompareCompareLogicLogic

ClockClockPrescalerPrescaler

OutputOutputLogicLogic

TPS 2TPS 2--00TxCONTxCON . 10 . 10 -- 88

PeriodPeriodRegisterRegister

ShadowedShadowed

CompareCompareRegisterRegister

ShadowedShadowed

TxPRTxPR . 15 . 15 -- 00

ExternalExternal

InternalInternal(HSPCLK)(HSPCLK)

TCLKS 1TCLKS 1--00TxCONTxCON . 5 . 5 -- 44

TxCMPTxCMP //TxPWMTxPWM

Note: x = 1 or 2Note: x = 1 or 2

QEPQEP

MMUUXX

C28x 1-Day Workshop - Control Peripherals 4 - 7

Page 38: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Event Manager

GP Timer Control Registers GP Timer Control Registers (EVA)(EVA) (file: (file: Ev.cEv.c))

GPTCONAGPTCONAGP Timer Status (counting up / down)GP Timer Status (counting up / down)ADC Start by Timer (underflow / period / compare)ADC Start by Timer (underflow / period / compare)Output Pin Condition (forced low / high, active low / high)Output Pin Condition (forced low / high, active low / high)Output EnableOutput Enable

T1CON / T2CONT1CON / T2CONCount Mode (stop/hold, continuousCount Mode (stop/hold, continuous--up/down, up/down,

continuouscontinuous--up, directionalup, directional--up/down)up/down)Timer Clock Timer Clock PrescalePrescale; Timer Clock Source; Timer Enable; Timer Clock Source; Timer EnableCompare Register Reload Condition (underflow, period, Compare Register Reload Condition (underflow, period,

immediately)immediately)Timer Compare EnableTimer Compare Enable

EXTCONAEXTCONAIndependent Compare Output Enable Mode (C24x/C28x)Independent Compare Output Enable Mode (C24x/C28x)

Compare Units

Compare Units Compare Units (EVA)(EVA)

PWM CircuitsPWM CircuitsPWM CircuitsPWM CircuitsPWM CircuitsPWM Circuits

Output LogicOutput LogicOutput LogicOutput LogicOutput LogicOutput Logic

GP Timer 1 CompareGP Timer 1 CompareGP Timer 1GP Timer 1

GP Timer 2 CompareGP Timer 2 CompareGP Timer 2GP Timer 2

Compare Unit 1Compare Unit 1Compare Unit 2Compare Unit 2Compare Unit 3Compare Unit 3

Capture UnitsCapture Units

MUXMUXQEPQEP

CircuitCircuit

Output LogicOutput Logic

Output LogicOutput Logic

EV Control Registers / LogicEV Control Registers / Logic

ResetReset PIEPIETCLKINA / TDIRATCLKINA / TDIRA// 22ADC StartADC Start

Dat

a B

usD

ata

Bus

••

CLKCLKDIRDIR

••••

T1CMP/T1PWMT1CMP/T1PWM

T2CMP/T2PWMT2CMP/T2PWM

PWM1PWM1PWM2PWM2PWM3PWM3PWM4PWM4PWM5PWM5PWM6PWM6

CAP1/QEP1CAP1/QEP1CAP2/QEP2CAP2/QEP2CAP3/QEPI1CAP3/QEPI1••

4 - 8 C28x 1-Day Workshop - Control Peripherals

Page 39: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Event Manager

Compare Units Block Diagram Compare Units Block Diagram (EVA)(EVA)

GP Timer 1GP Timer 1CounterCounter

ACTRA . 11 ACTRA . 11 -- 00

T1CNT . 15 T1CNT . 15 -- 00

CompareCompareLogicLogic

OutputOutputLogicLogic

FCOMPOEFCOMPOECOMCONA . 9COMCONA . 9

Dead BandDead BandUnitsUnits

ShadowedShadowed

CompareCompareAction ControlAction Control

RegisterRegister

ShadowedShadowed

CMPRxCMPRx . 15 . 15 -- 00

PWMyPWMy, y+1, y+1

CompareCompareRegisterRegister

DBTCONA . 11 DBTCONA . 11 -- 22

Note: x = 1, 2, 3; y = 1, 3, 5Note: x = 1, 2, 3; y = 1, 3, 5

Motivation for DeadMotivation for Dead--BandBand

to motor phase

supply rail

Gate Signals areComplementary PWM

♦ Transistor gates turn on faster than they shut off♦ Short circuit if both gates are on at same time!

C28x 1-Day Workshop - Control Peripherals 4 - 9

Page 40: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Event Manager

DeadDead--Band Functionality Band Functionality (EVA)(EVA)

PHx

DT

dead time

Clock

DTPHx

Asymmetric PWM Example

DTPHx_4-bit period

Prescaler

4-bitCounter

ENA

reset

HSPCLK

comparator

DTPHx

DTPHx_

PHx

DT

edgedetect

DBTCONA . 4 - 2

DBTCONA . 11 - 8

Compare Control Registers Compare Control Registers (EVA)(EVA) (file: (file: Ev.cEv.c))

COMCONACOMCONACompare Enable; Compare Output EnableCompare Enable; Compare Output EnableCompare Reload Condition (underflow, period, immediately)Compare Reload Condition (underflow, period, immediately)Action Control Register Reload Condition (underflow, Action Control Register Reload Condition (underflow,

period, immediately)period, immediately)PDPINT StatusPDPINT Status

EXTCONAEXTCONAIndependent Compare Output Enable Mode (C24x/C28x)Independent Compare Output Enable Mode (C24x/C28x)

ACTRAACTRAPin Action on Compare (forced low / high, active low / high)Pin Action on Compare (forced low / high, active low / high)

DBTCONADBTCONADeadDead--Band Timer EnableBand Timer EnableDeadDead--Band Timer Band Timer PrescalerPrescaler; Dead; Dead--Band Timer PeriodBand Timer Period

4 - 10 C28x 1-Day Workshop - Control Peripherals

Page 41: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Event Manager

Capture Units

Capture Units Capture Units (EVA)(EVA)

PWM CircuitsPWM CircuitsPWM CircuitsPWM CircuitsPWM CircuitsPWM Circuits

Output LogicOutput LogicOutput LogicOutput LogicOutput LogicOutput Logic

GP Timer 1 CompareGP Timer 1 CompareGP Timer 1GP Timer 1

GP Timer 2 CompareGP Timer 2 CompareGP Timer 2GP Timer 2

Compare Unit 1Compare Unit 1Compare Unit 2Compare Unit 2Compare Unit 3Compare Unit 3

Capture UnitsCapture Units

MUXMUXQEPQEP

CircuitCircuit

Output LogicOutput Logic

Output LogicOutput Logic

EV Control Registers / LogicEV Control Registers / Logic

ResetReset PIEPIETCLKINA / TDIRATCLKINA / TDIRA// 22ADC StartADC Start

Dat

a B

usD

ata

Bus

••

CLKCLKDIRDIR

••••

T1CMP/T1PWMT1CMP/T1PWM

T2CMP/T2PWMT2CMP/T2PWM

PWM1PWM1PWM2PWM2PWM3PWM3PWM4PWM4PWM5PWM5PWM6PWM6

CAP1CAP1/QEP1/QEP1CAP2CAP2/QEP2/QEP2CAP3CAP3/QEPI1/QEPI1••

Capture UnitsCapture Units

Capture units timestamp transitions on Capture units timestamp transitions on capture input pinscapture input pinsThree capture units (per event manager) Three capture units (per event manager) --each associated with a capture input pineach associated with a capture input pin

TimerTimer

TimestampTimestampValuesValues

TriggerTrigger ..

C28x 1-Day Workshop - Control Peripherals 4 - 11

Page 42: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Event Manager

Capture Units Block Diagram Capture Units Block Diagram (EVA)(EVA)

Can latch on:Can latch on:•• rising edgerising edge•• falling edgefalling edge•• bothboth

TTL SignalTTL Signalmin. valid width:min. valid width:2 CPUCLK lo2 CPUCLK lo2 CPUCLK hi2 CPUCLK hi

GP Timer 1GP Timer 1CounterCounter

T1CNT . 15 T1CNT . 15 -- 00

EdgeEdgeDetectDetect

CAP3TOADCCAP3TOADC

CAP1,2,3CAP1,2,3

MUXMUX

GP Timer 2GP Timer 2CounterCounter

T2CNT . 15 T2CNT . 15 -- 00

CAPCONA . 10 CAPCONA . 10 -- 99EnableEnable

CAPCONA . 14 CAPCONA . 14 --1212

22--Level DeepLevel DeepFIFOFIFO

// 33

..CAPCONA . 8CAPCONA . 8

Edge SelectEdge SelectCAPCONA . 7 CAPCONA . 7 -- 22

CAPCONA . 15CAPCONA . 15CAPRESETCAPRESET

ADC StartADC Start(CAP 3)(CAP 3)

CAPFIFOA . 13 CAPFIFOA . 13 -- 88CAPxFIFOCAPxFIFO StatusStatus

RSRS

Capture Control Registers Capture Control Registers (EVA)(EVA) (file: (file: Ev.cEv.c))

CAPCONACAPCONACapture ResetCapture ResetCapture Unit Enable for Compare; Enable for QEPCapture Unit Enable for Compare; Enable for QEPEdge Detection (rising, falling, both edges)Edge Detection (rising, falling, both edges)Timer Select (Timer 1 / 2)Timer Select (Timer 1 / 2)ADC Start on CAP3INT flagADC Start on CAP3INT flag

CAPFIFOACAPFIFOAFIFO Status (empty, one entry, two entries, three entries FIFO Status (empty, one entry, two entries, three entries

attempted and first entry lost)attempted and first entry lost)

EXTCONAEXTCONAQEP Index Enable, Qualification Mode (C24x/C28x)QEP Index Enable, Qualification Mode (C24x/C28x)

4 - 12 C28x 1-Day Workshop - Control Peripherals

Page 43: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Event Manager

Quadrature Encoder Pulse

QuadratureQuadrature Encoder Pulse Encoder Pulse (EVA)(EVA)

PWM CircuitsPWM CircuitsPWM CircuitsPWM CircuitsPWM CircuitsPWM Circuits

Output LogicOutput LogicOutput LogicOutput LogicOutput LogicOutput Logic

GP Timer 1 CompareGP Timer 1 CompareGP Timer 1GP Timer 1

GP Timer 2 CompareGP Timer 2 CompareGP Timer 2GP Timer 2

Compare Unit 1Compare Unit 1Compare Unit 2Compare Unit 2Compare Unit 3Compare Unit 3

Capture UnitsCapture Units

MUXMUXQEPQEP

CircuitCircuit

Output LogicOutput Logic

Output LogicOutput Logic

EV Control Registers / LogicEV Control Registers / Logic

ResetReset PIEPIETCLKINA / TDIRATCLKINA / TDIRA// 22ADC StartADC Start

Dat

a B

usD

ata

Bus

••

CLKCLKDIRDIR

••••

T1CMP/T1PWMT1CMP/T1PWM

T2CMP/T2PWMT2CMP/T2PWM

PWM1PWM1PWM2PWM2PWM3PWM3PWM4PWM4PWM5PWM5PWM6PWM6

CAP1/CAP1/QEP1QEP1CAP2/CAP2/QEP2QEP2CAP3/CAP3/QEPI1QEPI1••

What is an Incremental What is an Incremental QuadratureQuadratureEncoder?Encoder?

A digital (angular) position sensorA digital (angular) position sensor

slots spaced slots spaced θθ deg. apartdeg. apart

photo sensors spaced photo sensors spaced θθ/4 deg. apart/4 deg. apart

light source (LED)light source (LED)

shaft rotationshaft rotation

Ch. ACh. A

Ch. BCh. B

QuadratureQuadrature Output from Photo SensorsOutput from Photo Sensors

θθ

θθ/4/4

Incremental Optical EncoderIncremental Optical Encoder

C28x 1-Day Workshop - Control Peripherals 4 - 13

Page 44: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Event Manager

How is Position Determined from How is Position Determined from QuadratureQuadrature Signals?Signals?

Ch. ACh. A

Ch. BCh. B

(00)(00) (11)(11)(10)(10) (01)(01)

(A,B) =(A,B) =

0000

0101

1111

1010

QuadratureQuadratureDecoderDecoder

State MachineState Machine

incrementincrementcountercounter

decrementdecrementcountercounter

Position resolution is Position resolution is θθ/4 degrees./4 degrees.

Incremental Encoder Connections (EVA)Incremental Encoder Connections (EVA)

GluelessGlueless interface interface between DSP and between DSP and QEP sensorQEP sensorIndex connection Index connection resets counter to resets counter to zerozero

Ch. ACh. A

Ch. BCh. BCAP1/QEP1CAP1/QEP1

CAP2/QEP2CAP2/QEP2

QEPQEPdecoderdecoder

logiclogic

GP Timer 2GP Timer 2

CLKCLK DIRDIR

....

IndexIndex

CA

P3/Q

EPI

CA

P3/Q

EPI

QEPIEQEPIE

QEPIQUALQEPIQUAL

4 - 14 C28x 1-Day Workshop - Control Peripherals

Page 45: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Lab 4: Control Peripherals

Lab 4: Control Peripherals Objective

The objective of this lab is to demonstrate the techniques discussed in this module and become familiar with the operation of the on-chip analog-to-digital converter and Event Manager. General-Purpose Timer 1 and Compare 1 will be setup to generate a 2 kHz, 25% duty cycle symmetric PWM waveform. The waveform will then be sampled with the on-chip analog-to-digital converter and displayed using the graphing feature of Code Composer Studio. The ADC has been setup to sample a single input channel at a 50 kHz sampling rate and store the conversion result in a buffer in the DSP memory. This buffer operates in a circular fashion, such that new conversion data continuously overwrites older results in the buffer.

Recall that there are two timebases associated with Event Manager “EVA”. The timer and its associated control registers are configured to produce a PWM waveform on the eZdsp™:

General Purpose Timer #1 – PWM Generation

• Used as a timebase for Compare 1 generation of PWM waveform

General Purpose Timer #2 – ADC Conversion Trigger

• Used as a timebase for triggering ADC samples (period match trigger SOC)

Lab 4: Control PeripheralsLab 4: Control Peripherals

ADCADCRESULT0RESULT0

......

datadatamemorymemory

poin

ter

rew

ind

poin

ter

rew

ind

CPU copiesCPU copiesresult toresult tobuffer duringbuffer duringADC ISRADC ISR

GP Timer 2GP Timer 2

GP Timer 2 triggersGP Timer 2 triggersADC SOC every ADC SOC every 20 20 µµs (50kHz)s (50kHz)

connectorconnectorwirewire

Compare 1Compare 1PWM CircuitsPWM CircuitsOutput LogicOutput Logic

GP Timer 1GP Timer 1

Event ManagerEvent Manager

ADCADC--INA0INA0

View ADC View ADC buffer PWM buffer PWM SamplesSamples

Code ComposerCode ComposerStudioStudio

The software in this exercise configures the Event Manager and the ADC. It is entirely interrupt driven. The ADC end-of-conversion interrupt will be used to prompt the CPU to copy the results of the ADC conversion into a results buffer in memory. This buffer pointer will be managed in a circular fashion, such that new conversion results will continuously overwrite older conversion

C28x 1-Day Workshop - Control Peripherals 4 - 15

Page 46: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Lab 4: Control Peripherals

results in the buffer. The ADC interrupt service routine (ISR) will also toggle LED DS2 on the eZdsp™ as a visual indication that the ISR is running.

Notes • General Purpose Timer 1 is used to generate a 2 kHz PWM waveform • Program performs conversion on ADC channel A0 (ADCINA0 pin) • General Purpose Timer 2 is used to auto-trigger the conversions at a 50 kHz sampling rate • Data is continuously stored in a circular buffer • Data is displayed using the graphing feature of Code Composer Studio • ADC ISR will also toggle the eZdsp™ LED DS2 as a visual indication that it is running

Procedure

Project File 1. A project named Lab4.pjt has been created for this lab. Open the project by clicking

on Project Open… and look in C:\C28x1DAY\LABS\LAB4. All Build Options have been configured. The files used in this lab are:

Main_4.c Labcfg.cmdLab.cdb DSP281x_Headers_BIOS.cmdUser_4.cmd CodeStartBranch.asmSysCtrl.c Gpio.cDSP281x_GlobalVariableDefs.c PieCtrl_4_5.cDefaultIsr_4.c Adc.cEv.c

Setup of Shared I/O, General-Purpose Timer1 and Compare1

Note: DO NOT make any changes to Gpio.c and Ev.c – ONLY INSPECT

2. Open and inspect Gpio.c by double clicking on the filename in the project window. Notice that the shared I/O pins in Group A have been set for the PWM1 function. Next, open and inspect Ev.c and see that the General-Purpose Timer 1 and Compare 1 has been setup to implement the PWM waveform as described in the objective for this lab. Notice the values used in the following registers: T1CON, T1CNT, T1PR, DBTCONA (set deadband units off), CMPR1, ACTRA, COMCONA. (Note that the last step for the timer setup enables Timer 1). See the global variable names and values that have been set using #define in the beginning of Ev.c file. Notice that GPTCONA has been initialized earlier in the code during Timer 2 setup. Close the inspected files.

Build and Load 3. Code Composer Studio can automatically load the output file after a successful build. On

the menu bar click: Option Customize… and select the “Program Load Options” tab, check “Load Program After Build”, then click OK.

4 - 16 C28x 1-Day Workshop - Control Peripherals

Page 47: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Lab 4: Control Peripherals

4. Click the “Build” button and watch the tools run in the build window. The output file should automatically load.

5. Under Debug on the menu bar click “Reset CPU”.

6. Under Debug on the menu bar click “Go Main”. You should now be at the start of Main().

Run the Code – PWM Waveform 7. Open Main_4.c by double clicking on the filename in the project window. In

Main_4.c place the cursor in the “main loop” section, right click on the mouse key and select Run To Cursor.

8. Open a memory window to view some of the contents of the ADC results buffer. To open a memory window click: View Memory on the menu bar. The address label for the ADC results buffer is AdcBuf.

Note: For the next set of steps “VREFLO” must be connected to “GND”. Using a connector wire provided, connect “VREFLO” (pin # P9-18) to “GND” (pin # P9-17). Exercise care when connecting any wires, as the power to the eZdsp™ is on, and we do not want to damage the eZdsp™! Details of pin assignments can be found in Appendix A.

9. Using another connector wire provided, connect the PWM1 (pin # P8-9) to ADCIN0 (pin # P9-2) on the eZdsp™. Again, exercise care when connecting any wires, as the power to the eZdsp™ is on, and we do not want to damage the eZdsp™!

10. Run your code for a few seconds by using the <F5> key, or using the Run button on the vertical toolbar, or using Debug Run on the menu bar. After a few seconds halt your code by using Shift <F5>, or the Halt button on the vertical toolbar. Verify that the ADC result buffer contains the updated values.

11. Open and setup a graph to plot a 50-point window of the ADC results buffer. Click: View Graph Time/Frequency… and set the following values:

Start Address AdcBuf

Acquisition Buffer Size 50

Display Data Size 50

DSP Data Type 16-bit unsigned integer

Sampling Rate (Hz) 50000

Time Display Unit µs

Select OK to save the graph options.

C28x 1-Day Workshop - Control Peripherals 4 - 17

Page 48: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Lab 4: Control Peripherals

12. The graphical display should show the generated 2 kHz, 25% duty cycle symmetric PWM waveform. The period of a 2 kHz signal is 500 µs. You can confirm this by measuring the period of the waveform using the graph (you may want to enlarge the graph window using the mouse). The measurement is best done with the mouse. The lower left-hand corner of the graph window will display the X and Y-axis values. Subtract the X-axis values taken over a complete waveform period (you can use the PC calculator program found in Microsoft Windows to do this).

Frequency Domain Graphing Feature of Code Composer Studio 13. Code Composer Studio also has the ability to make frequency domain plots. It does this

by using the PC to perform a Fast Fourier Transform (FFT) of the DSP data. Let's make a frequency domain plot of the contents in the ADC results buffer (i.e. the PWM waveform).

Click: View Graph Time/Frequency… and set the following values:

Display Type FFT Magnitude

Start Address AdcBuf

Acquisition Buffer Size 50

FFT Framesize 50

DSP Data Type 16-bit unsigned integer

Sampling Rate (Hz) 50000

Select OK to save the graph options.

14. On the plot window, left-click the mouse to move the vertical marker line and observe the frequencies of the different magnitude peaks. Do the peaks occur at the expected frequencies?

Using Real-time Emulation Real-time emulation is a special emulation feature that allows the windows within Code Composer Studio to be updated at up to a 10 Hz rate while the DSP is running. This not only allows graphs and watch windows to update, but also allows the user to change values in watch or memory windows, and have those changes affect the DSP behavior. This is very useful when tuning control law parameters on-the-fly, for example.

15. Reset the DSP, and enable real-time mode by selecting:

Debug Real-time Mode

4 - 18 C28x 1-Day Workshop - Control Peripherals

Page 49: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Lab 4: Control Peripherals

16. A message box will appear. Select YES to enable debug events. This will set bit 1 (DGBM bit) of status register 1 (ST1) to a “0”. The DGBM is the debug enable mask bit. When the DGBM bit is set to “0”, memory and register values can be passed to the host processor for updating the debugger windows.

17. The memory and graph windows displaying AdcBuf should still be open. The connector wire between PWM1 (pin # P8-9) and ADCINA0 (pin # P9-2) should still be connected. In real-time mode, we would like to have our window continuously refresh. Click:

View Real-time Refresh Options…

and check “Global Continuous Refresh”. Alternately, we could have right clicked on each window individually and selected “Continuous Refresh”.

Note: “Global Continuous Refresh” causes all open windows to refresh at the refresh rate. This can be problematic when a large number of windows are open, as bandwidth over the emulation link is limited. Updating too many windows can cause the refresh frequency to bog down. In that case, either close some windows, or disable global refresh and selectively enable “Continuous Refresh” for individual windows of interest instead.

18. Run the code and watch the windows update in real-time mode. Are the values updating as expected?

19. Fully halting the DSP when in real-time mode is a two-step process. First, halt the processor with Debug Halt. Then uncheck the “Real-time mode” to take the DSP out of real-time mode.

Optional Exercise You might want to experiment with this code by changing some of the values or just modify the code. Try generating another waveform of a different frequency and duty cycle. Also, try to generate complementary pair PWM outputs. Next, try to generate additional simultaneous waveforms by using Compare 1, Compare 2, and Compare 3. Hint: don’t forget to setup the proper shared I/O pins, etc. (This optional exercise requires some further working knowledge of the event manager. Additionally, it may require more time than is allocated for this lab. Therefore, the student may want to try this after the class).

End of Exercise

C28x 1-Day Workshop - Control Peripherals 4 - 19

Page 50: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Lab 4: Control Peripherals

This page is intentionally blank.

4 - 20 C28x 1-Day Workshop - Control Peripherals

Page 51: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

DSP/BIOS Real-Time OS

Introduction This module discusses the basic features of using the DSP/BIOS real-time operating system. The configuration tool, scheduling threads, and real-time analysis tools will be explained.

Learning Objectives Learning ObjectivesLearning Objectives

Introduction to DSP/BIOSIntroduction to DSP/BIOS

DSP/BIOS Configuration ToolDSP/BIOS Configuration Tool

Scheduling DSP/BIOS ThreadsScheduling DSP/BIOS Threads

RealReal--Time Analysis ToolsTime Analysis Tools

DSP/BIOS API Modules and SummaryDSP/BIOS API Modules and Summary

C28x 1-Day Workshop - DSP/BIOS Real-Time OS 5 - 1

Page 52: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Module Topics

Module Topics DSP/BIOS Real-Time OS ......................................................................................................................... 5-1

Module Topics......................................................................................................................................... 5-2 Introduction to DSP/BIOS ...................................................................................................................... 5-3 DSP/BIOS Configuration Tool................................................................................................................ 5-4 Scheduling DSP/BIOS Threads............................................................................................................... 5-6 Real-Time Analysis Tools.......................................................................................................................5-10 DSP/BIOS API Modules and Summary..................................................................................................5-11 Lab 5: DSP/BIOS...................................................................................................................................5-12

5 - 2 C28x 1-Day Workshop - DSP/BIOS Real-Time OS

Page 53: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Introduction to DSP/BIOS

Introduction to DSP/BIOS Introduction to DSP/BIOSIntroduction to DSP/BIOS

A fullA full--featured, scalable realfeatured, scalable real--time kerneltime kernelSystem configuration toolsSystem configuration toolsPreemptive multiPreemptive multi--threading schedulerthreading schedulerRealReal--time analysis toolstime analysis tools

Helps manage complex system resourcesHelps manage complex system resourcesIntegrated with Code Composer Studio IDEIntegrated with Code Composer Studio IDE

Requires no runtime license feesRequires no runtime license feesFully supported by TI and is a key component of Fully supported by TI and is a key component of TITI’’sseXpressDSPeXpressDSP™™ realreal--time software technologytime software technology

Uses minimal MIPS and memory (2Uses minimal MIPS and memory (2--8Kw)8Kw)

What is DSP/BIOS?What is DSP/BIOS?

Why use DSP/BIOS?Why use DSP/BIOS?

DSP/BIOS TerminologyDSP/BIOS Terminology

threadthread a path of program executiona path of program executionschedulerscheduler a program that managesa program that manages threadsthreadspreemptionpreemption the act of a higher priority thread the act of a higher priority thread

interrupting a lower priority thread interrupting a lower priority thread postpost an event signal that often makes a an event signal that often makes a

thread thread ““readyready””pendpend When a thread waits for an event postWhen a thread waits for an event postsemaphoresemaphore a data object that tracks event a data object that tracks event

occurrences (used by post and occurrences (used by post and pendpend))

C28x 1-Day Workshop - DSP/BIOS Real-Time OS 5 - 3

Page 54: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

DSP/BIOS Configuration Tool

DSP/BIOS Configuration Tool DSP/BIOS Configuration Tool DSP/BIOS Configuration Tool (file .(file .cdbcdb))

System Setup ToolsSystem Setup ToolsHandles memory configuration Handles memory configuration (builds .(builds .cmdcmd file), runfile), run--time support time support libraries, interrupt vectors, system libraries, interrupt vectors, system setup and reset, etc.setup and reset, etc.RealReal--Time Analysis ToolsTime Analysis ToolsAllows application to run Allows application to run uninterrupted while displaying uninterrupted while displaying debug datadebug dataRealReal--Time SchedulerTime SchedulerPreemptive tread manager kernelPreemptive tread manager kernelRealReal--Time I/OTime I/OAllows two way communication Allows two way communication between threads or between between threads or between target and PC hosttarget and PC host

Memory Section ManagerMemory Section Manager

MEM manager MEM manager allows you to allows you to create memory create memory area and place area and place sectionssectionsTo create a new To create a new memory area:memory area:

RightRight--click on click on MEM and MEM and select Insert select Insert memorymemoryFill in base, Fill in base, length, spacelength, space

5 - 4 C28x 1-Day Workshop - DSP/BIOS Real-Time OS

Page 55: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

DSP/BIOS Configuration Tool

Memory Section Manager PropertiesMemory Section Manager Properties

To place a To place a section into a section into a memory area:memory area:

RightRight--click on click on MEM and MEM and select select PropertiesPropertiesSelect the Select the appropriate appropriate tab (e.g. tab (e.g. Compiler)Compiler)Select the Select the memory for memory for each sectioneach section

Hardware InterruptsHardware Interrupts

C28x 1-Day Workshop - DSP/BIOS Real-Time OS 5 - 5

Page 56: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Scheduling DSP/BIOS Threads

Scheduling DSP/BIOS Threads Learning ObjectivesLearning Objectives

Introduction to DSP/BIOSIntroduction to DSP/BIOS

DSP/BIOS Configuration ToolDSP/BIOS Configuration Tool

Scheduling DSP/BIOS ThreadsScheduling DSP/BIOS Threads

RealReal--Time Analysis ToolsTime Analysis Tools

DSP/BIOS API Modules and SummaryDSP/BIOS API Modules and Summary

DSP/BIOS Thread TypesDSP/BIOS Thread Types

Prio

rity

Prio

rity

Use SWI to perform HWI 'Use SWI to perform HWI 'followfollow--upup' activity' activitySWI's are 'SWI's are 'postedposted' by software' by softwareMultiple SWIs at each of 15 priority levelsMultiple SWIs at each of 15 priority levels

Use TSK to run different programs concurrently Use TSK to run different programs concurrently under separate contextsunder separate contextsTSK's enabled by posting 'TSK's enabled by posting 'semaphoresemaphore‘‘ (a signal)(a signal)

Multiple IDL functions Multiple IDL functions Runs as an infinite loop, like traditional while loopRuns as an infinite loop, like traditional while loopAll BIOS data transfers to host occur hereAll BIOS data transfers to host occur here

Used to implement 'urgent' part of realUsed to implement 'urgent' part of real--time eventtime eventTriggered by hardware interruptTriggered by hardware interruptHWI priorities set by hardwareHWI priorities set by hardware

SWISWISoftware InterruptsSoftware Interrupts

HWIHWIHardware InterruptsHardware Interrupts

TSKTSKTasksTasks

IDLIDLBackgroundBackground

5 - 6 C28x 1-Day Workshop - DSP/BIOS Real-Time OS

Page 57: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Scheduling DSP/BIOS Threads

Enabling BIOS Enabling BIOS –– Return from main()Return from main()

mainmain{ { ……// // return to BIOSreturn to BIOS}}

DSP BIOSDSP BIOS

Function 2Function 2

Function 1Function 1

Must delete the endless while() loopMust delete the endless while() loopmain() returns to BIOS IDLE thread,main() returns to BIOS IDLE thread,allowing BIOS to schedule events, allowing BIOS to schedule events, transfer info to host, etc.transfer info to host, etc.An endless while() loop in main() An endless while() loop in main() will not allow BIOS to activatewill not allow BIOS to activate

interruptinterrupt void void MyHwi(voidMyHwi(void)){{}}

HWI Dispatcher Performs Save/RestoreHWI Dispatcher Performs Save/RestoreFor nonFor non--BIOS code, we use the BIOS code, we use the interruptinterrupt keyword to declare an ISRkeyword to declare an ISR

tells the compiler to perform context save/restoretells the compiler to perform context save/restore

For DSP/BIOS code, the dispatcher will perform the save/restoreFor DSP/BIOS code, the dispatcher will perform the save/restoreRemove the Remove the interruptinterrupt keyword from the keyword from the MyHwiMyHwi()()Check the Check the ““Use DispatcherUse Dispatcher”” box when you configure the interrupt box when you configure the interrupt vector in the DSP/BIOS vector in the DSP/BIOS configconfig toolstools

C28x 1-Day Workshop - DSP/BIOS Real-Time OS 5 - 7

Page 58: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Scheduling DSP/BIOS Threads

Using Software Interrupts Using Software Interrupts -- SWISWI

mainmain{ { ……// return to O/S;// return to O/S;}}

DSP/BIOSDSP/BIOS

Make each algorithm an Make each algorithm an independentindependentsoftware interruptsoftware interruptSWI scheduling is handled by DSP/BIOSSWI scheduling is handled by DSP/BIOS

HWI function triggered by hardwareHWI function triggered by hardwareSWI function triggered by softwareSWI function triggered by softwaree.g. a call to SWI_post()e.g. a call to SWI_post()

Why use a SWI?Why use a SWI?No limitation on number of No limitation on number of SWIsSWIs, and , and priorities for priorities for SWIsSWIs are userare user--defineddefinedSWI can be scheduled by hardware or SWI can be scheduled by hardware or software event(s)software event(s)Defer processing from HWI to SWIDefer processing from HWI to SWI

Function 2Function 2

Function 1Function 1

SWI PropertiesSWI Properties

5 - 8 C28x 1-Day Workshop - DSP/BIOS Real-Time OS

Page 59: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Scheduling DSP/BIOS Threads

Managing SWI PriorityManaging SWI Priority

Drag and Drop SWIs to change priorityEqual priority SWIs run in the order that they are posted

Drag and Drop SWIs to change Drag and Drop SWIs to change prioritypriorityEqual priority SWIs run in the Equal priority SWIs run in the order that they are postedorder that they are posted

Priority Based Thread SchedulingPriority Based Thread SchedulingHWI 2HWI 2

HWI 1HWI 1

SWI 3SWI 3

SWI 2SWI 2

SWI 1SWI 1

MAINMAIN

IDLEIDLEint1int1

rtnrtn

post2post2 rtnrtn

int2int2

post3post3 rtnrtn

post1post1 rtnrtn

rtnrtn

rtnrtn

User sets the priority...BIOS does the schedulingUser sets the priority...BIOS does the scheduling

(highest)(highest)

(lowest)(lowest)

SWI_post(&swi2);SWI_post(&swi2);

C28x 1-Day Workshop - DSP/BIOS Real-Time OS 5 - 9

Page 60: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Real-Time Analysis Tools

Real-Time Analysis Tools BuiltBuilt--in Realin Real--Time Analysis ToolsTime Analysis Tools

Gather data on target (3Gather data on target (3--10 CPU cycles)10 CPU cycles)Send data during BIOS IDL (100s of cycles)Send data during BIOS IDL (100s of cycles)Format data on host (1000s of cycles)Format data on host (1000s of cycles)Data gathering does NOT stop target CPUData gathering does NOT stop target CPU

Execution GraphExecution Graph

Shows amount of CPU Shows amount of CPU horsepower being horsepower being consumedconsumed

CPU Load GraphCPU Load Graph

Software logic analyzerSoftware logic analyzerDebug event timingDebug event timingand priorityand priority

BuiltBuilt--in Realin Real--Time Analysis ToolsTime Analysis Tools

Profile routines w/oProfile routines w/ohalting the CPUhalting the CPU

Statistics ViewStatistics View

Send debug Send debug msgsmsgs to hostto hostDoesnDoesn’’t halt the DSPt halt the DSPDeterministic, low DSPDeterministic, low DSPcycle countcycle countMore efficient thanMore efficient thantraditional traditional printfprintf()()

Message LOGMessage LOG

LOG_printf(&traceLOG_printf(&trace, ", "AdcSwi_countAdcSwi_count = %u", = %u", AdcSwi_countAdcSwi_count++);++);

5 - 10 C28x 1-Day Workshop - DSP/BIOS Real-Time OS

Page 61: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

DSP/BIOS API Modules and Summary

DSP/BIOS API Modules and Summary DSP/BIOS DSP/BIOS -- API ModulesAPI Modules

Instrumentation/RealInstrumentation/Real--Time Analysis Time Analysis

LOGLOG Message log managerMessage log managerSTSSTS Statistics accumulator manager Statistics accumulator manager TRCTRC Trace manager Trace manager RTDXRTDX RealReal--Time Data Time Data eXchangeeXchange manager manager

Thread Types Thread Types

HWIHWI Hardware interrupt manager Hardware interrupt manager SWISWI Software interrupt manager Software interrupt manager TSKTSK MultiMulti--tasking manager tasking manager IDLIDL Idle function & process loop manager Idle function & process loop manager

Clock and Periodic Functions Clock and Periodic Functions

CLKCLK System clock manager System clock manager PRDPRD Periodic function manager Periodic function manager

TSK Communication/SynchronizationTSK Communication/Synchronization

SEMSEM Semaphores manager Semaphores manager MBXMBX Mailboxes manager Mailboxes manager LCKLCK Resource lock manager Resource lock manager

DeviceDevice--Independent Input/Output Independent Input/Output

PIPPIP Data pipe manager Data pipe manager HSTHST Host input/output manager Host input/output manager SIOSIO Stream I/O manager Stream I/O manager DEVDEV Device driver interface Device driver interface

Memory and LowMemory and Low--Level PrimitivesLevel Primitives

MEMMEM Memory manager Memory manager SYSSYS System services manager System services manager QUEQUE Queue manager Queue manager ATMATM Atomic functions Atomic functions GBLGBL Global setting manager Global setting manager

Summary and Benefits of DSP/BIOSSummary and Benefits of DSP/BIOSFast time to marketFast time to market

no need to develop or maintain a no need to develop or maintain a ““homehome--brewbrew”” kernelkernelEfficient debugging of realEfficient debugging of real--time applicationstime applications

RealReal--Time AnalysisTime AnalysisCreate robust applicationsCreate robust applications

industry proven kernel technologyindustry proven kernel technologyReduce cost of software maintenanceReduce cost of software maintenance

code reuse and standardized softwarecode reuse and standardized softwareStandardized APIsStandardized APIs

enable rapid migration across C28x TMS320 enable rapid migration across C28x TMS320 DSPsDSPsSmall footprint (2Small footprint (2--8Kw)8Kw)

easily fits in limited memory spaceeasily fits in limited memory spaceSet of library functions (scalable)Set of library functions (scalable)

use only what is needed to minimize code and data sizeuse only what is needed to minimize code and data sizeFull featured kernel (extensible)Full featured kernel (extensible)

allows additional OS functions in futureallows additional OS functions in future

C28x 1-Day Workshop - DSP/BIOS Real-Time OS 5 - 11

Page 62: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Lab 5: DSP/BIOS

Lab 5: DSP/BIOS Objective

The objective of this lab is to demonstrate the techniques discussed in this module and to become familiar with DSP/BIOS. In the previous lab, General-Purpose Timer 1 and Compare 1 from Event Manager A (EVA) were setup to generate a 2 kHz, 25% duty cycle symmetric PWM waveform. The waveform was then sampled with the on-chip analog-to-digital converter. In this lab the sampled waveform will be passed through an IQmath FIR filter and displayed using the graphing feature of Code Composer Studio. In this lab exercise, we are going to change the ADCINT_ISR HWI to a SWI. Then, we will replace the LED blink routine with a Periodic Function. Also, some features of the real-time analysis tools will be demonstrated.

Lab 5: DSP/BIOSLab 5: DSP/BIOS

ADCINT_ISR posts a SWIADCINT_ISR posts a SWILED blink routine LED blink routine performed with a performed with a Periodic SWIPeriodic SWI

CPU copiesCPU copiesresult toresult tobuffer duringbuffer duringADC ISRADC ISR

ADCADCRESULT0RESULT0

GP Timer 2GP Timer 2

GP Timer 2 triggersGP Timer 2 triggersADC SOC everyADC SOC every

20 20 µµs (50 kHz)s (50 kHz)

connectorconnectorwirewire

Compare 1Compare 1PWM CircuitsPWM CircuitsOutput LogicOutput Logic

GP Timer 1GP Timer 1

Event ManagerEvent ManagerADCINA0ADCINA0

......

datadatamemorymemory

poin

ter r

ewi n

dpo

inte

r rew

i nd

Display Display using CCSusing CCS

IQmathIQmathFIR FilterFIR Filter

Procedure

Project File 1. A project named Lab5.pjt has been created for this lab. Open the project by clicking

on Project Open… and look in C:\C28x1DAY\LABS\LAB5. All Build Options have been configured. The files used in this lab are:

Note: Due to a bug in CCS and DSP/BIOS, the configuration file name (.cdb) and the project output (.out) and map (.map) names must be the same. Therefore, in this module the Build Options output and map file names will be lab.out and map.out, respectively.

5 - 12 C28x 1-Day Workshop - DSP/BIOS Real-Time OS

Page 63: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Lab 5: DSP/BIOS

Main_5.c Labcfg.cmdLab.cdb DSP281x_Headers_BIOS.cmdUser_5.cmd CodeStartBranch.asmSysCtrl.c Gpio.cDSP281x_GlobalVariableDefs.c PieCtrl_4_5.cDefaultIsr_5_6.c Adc.cEv.c Filter.c

Include IQmathLib.h 2. Open Lab.h which is located in the include folder in the project window. Uncomment

the line that includes the IQmathLib.h header file. Next, in the Function Prototypes section, uncomment the function prototype for IQssfir(), the IQ math single-sample FIR filter function. Save the changes.

Add a SWI to main.c

Note: DO NOT make any changes to Main_5.c and DefaultISR_5_6.c – ONLY INSPECT

3. Open Main_5.c and notice that at the end of main() two new functions will be used in this module – AdcSwi() and LedBlink().

4. Open DefaultIsr_5_6.c, and notice that the interrupt key word for the ADCINT_ISR is not used. The interrupt keyword is not used when a HWI is under DSP/BIOS control. A HWI is under DSP/BIOS control when it uses any DSP/BIOS functionality, such as posting a SWI, or calling any DSP/BIOS function or macro.

5. In Main_5.c notice that the (in-line assembly) code used to enable global interrupts is not used. DSP/BIOS will enable global interrupts after main().

6. Again, in Main_5.c notice that the while() loop (the endless loop) is not used. When using DSP/BIOS, you must return from main(). In all DSP/BIOS programs, the main() function should contain all one-time user-defined initialization functions. DSP/BIOS will then take-over control of the software execution.

Post a SWI 7. In DefaultIsr_5_6.c the following SWI_post has been added to the

ADCINT_ISR(), just after the structure used to acknowledge the PIE group:

SWI_post(&ADC_swi); // post a SWI

This post a SWI that will execute the ADC_swi() code you examined a few steps back in the lab. In other words, the ADC interrupt still executes the same code as before. However, some of that code is now in a posted SWI that DSP/BIOS will execute according to the specified scheduling priorities.

C28x 1-Day Workshop - DSP/BIOS Real-Time OS 5 - 13

Page 64: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Lab 5: DSP/BIOS

Add the SWI to the CDB File 8. Open the Lab.cdb file by left clicking on the plus sign (+) to the left of DSP/BIOS

Config and double clicking on the Lab.cdb file. In the configuration file Lab.cdb we need to add and setup the AdcSwi() SWI. Click on the plus sign (+) to the left of Scheduling and again on the plus sign (+) to the left of SWI – Software Interrupt Manager.

9. Right click on SWI – Software Interrupt Manager and select Insert SWI. SWI0 will be added. Right-click on it, and rename it to ADC_swi. This is just an arbitrary name. We want to differentiate the AdcSwi() function itself (which is nothing but an ordinary C function) from the DSP/BIOS SWI object which we are calling ADC_swi.

10. Select the Properties for ADC_swi and type _AdcSwi (with a leading underscore) in the function field. Click OK. This tells DSP/BIOS that it should run the function AdcSwi() when it executes the ADC_swi SWI.

11. We need to have the PIE for the ADC interrupt use the dispatcher. The dispatcher will automatically perform the context save and restore, and allow the DSP/BIOS scheduler to have insight into the ISR. The ADC interrupt is located at PIE_INT1_6.

Click on the plus sign (+) to the left of HWI – Hardware Interrupt Service Routine Manager. Click the plus sign (+) to the left of PIE INTERRUPTS. Locate the interrupt location for the ADC: PIE_INT1_6. Right click, select Properties, and select the Dispatcher tab.

Now check the “Use Dispatcher” box and select OK. Close the configuration file and click YES to save changes.

Build, Load, and Reset 12. Click the “Build” button to rebuild and load the project.

13. Reset the DSP.

Run the Code – AdcSwi() 14. We will be running our code in real-time mode, and need to have our window

continuously refresh. Enable Real-time Mode and be sure that the Global Continuous Refresh option has been checked.

Note: For the next step, check to be sure that the jumper wire connecting “VREFLO” (pin # P9-18) to “GND” (pin # P9-17) and the wire connecting PWM1 (pin # P8-9) to ADCIN0 (pin # P9-2) are still in place on the eZdsp™.

15. Run the code in real-time mode watch the window update. Verify that the ADC result buffer contains updated values.

5 - 14 C28x 1-Day Workshop - DSP/BIOS Real-Time OS

Page 65: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Lab 5: DSP/BIOS

16. Open and setup a dual time graph to plot a 50-point window of the filtered and unfiltered ADC results buffer. Click: View Graph Time/Frequency… and set the following values:

Display Type Dual Time

Start Address – upper display AdcBufFiltered

Start Address – lower display AdcBuf

Acquisition Buffer Size 50

Display Data Size 50

DSP Data Type 32-bit signed integer

Q-value 24

Sampling Rate (Hz) 50000

Time Display Unit µs

Select OK to save the graph options.

17. The graphical display should show the generated IQmath FIR filtered 2 kHz, 25% duty cycle symmetric PWM waveform in the upper display and the unfiltered waveform generated in the previous lab exercise in the lower display. Notice the shape and phase differences between the waveform plots (the filtered curve has rounded edges, and lags the unfiltered plot by several samples). The amplitudes of both plots should run from 0 to 3.0. The results should be the same as the previous lab, but we are using a SWI rather than a HWI.

18. Open and setup two (2) frequency domain plots – one for the filtered and another for the unfiltered ADC results buffer. Click: View Graph Time/Frequency… and set the following values:

C28x 1-Day Workshop - DSP/BIOS Real-Time OS 5 - 15

Page 66: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Lab 5: DSP/BIOS

GRAPH #1 GRAPH #2

Display Type FFT Magnitude FFT Magnitude

Start Address AdcBuf AdcBufFiltered

Acquisition Buffer Size 50 50

Display Data Size 50 50

DSP Data Type 32-bit signed integer 32-bit signed integer

Q-value 24 24

Sampling Rate (Hz) 50000 50000

Time Display Unit µs µs

Select OK to save the graph options.

19. The graphical displays should show the frequency components of the filtered and unfiltered 2 kHz, 25% duty cycle symmetric PWM waveforms. Notice that the higher frequency components are reduced using the Low-Pass IQmath FIR filter in the filtered graph as compared to the unfiltered graph.

20. Fully halt the DSP (real-time mode) by using Debug Halt and then unchecking the “Real-time mode”.

Add a Periodic Function Recall that an instruction was used in the ADCINT_ISR to toggle the LED on the eZdsp™. This instruction has been moved into a periodic function that will toggle the LED at the same rate.

21. Open Main_5.c and notice the instruction used to toggle the LED to the LedBlink() function:

GpioDataRegs.GPFTOGGLE.bit.GPIOF14 = 1; // Toggle the pin

22. In the configuration file Lab.cdb we need to add and setup the LedBlink_PRD. Open Lab.cdb and click on the plus sign (+) to the left of Scheduling. Right click on PRD – Periodic Function Manger and select Insert PRD. PRD0 will be added. Right-click on it and rename it to LedBlink_PRD.

23. Select the Properties for LedBlink_PRD and type _LedBlink (with a leading underscore) in the function field. This tells DSP/BIOS to run the LedBlink() function when it executesd the LedBlilnk_PRD periodic function object.

Next, in the period (ticks) field type 500. The default DSP/BIOS system timer increments every 1 millisecond, so what we are doing is telling the DSP/BIOS scheduler to schedule the LedBlink() function to execute every 500 milliseconds. A PRD object is

5 - 16 C28x 1-Day Workshop - DSP/BIOS Real-Time OS

Page 67: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Lab 5: DSP/BIOS

just a special type of SWI which gets scheduled periodically and runs in the context of the SWI level at a specified SWI priority. Click OK. Close the configuration file and click YES to save changes.

Build and Load 24. Click the “Build” button to rebuild and load the project.

25. Reset the DSP.

Run the Code – LedBlink 26. Run the code and check to see if the LED on the eZdsp™ is blinking. When done, halt

the code. If you would like, experiment with different period (tick) values and notice that the blink rate changes.

DSP/BIOS – Real-time Analysis The DSP/BIOS analysis tools complement the CCS environment by enabling real-time program analysis of a DSP/BIOS application. You can visually monitor a DSP application as it runs with essentially no impact on the application’s real-time performance. In CCS, the DSP/BIOS analysis tools are found on the DSP/BIOS menu. Unlike traditional debugging, which is external to the executing program, DSP/BIOS program analysis requires that the target program be instrumented with analysis code. By using DSP/BIOS APIs and objects, developers automatically instrument the target for capturing and uploading real-time information to CCS using these tools.

27. Open the CPU load graph. On the menu bar click:

DSP/BIOS CPU Load Graph

The CPU load graph displays the percentage of available CPU computing horsepower that the application is consuming. The CPU may be running ISRs, software interrupts, periodic functions, performing I/O with the host, or running any user routine. When the CPU is not executing user code, it will be idle (in the DSP/BIOS idle thread). You will notice that we are consuming about 50% of the CPU with our lab code.

28. Next, open the execution graph. On the menu bar click:

DSP/BIOS Execution Graph

The execution graph is a special graph used to display information about different threads in the system and when they occur relative to the other events. This graph is not based on time, but the activity of events (i.e. when an event happens, such as a SWI or periodic function begins execution). You can enable or disable logging for each of the object types using the RTA Control Panel (DSP/BIOS RTA Control Panel). Note that the execution graph simply records DSP/BIOS CLK events along with other system events (the DSP/BIOS clock periodically triggers the DSP/BIOS scheduler). As a result, the time scale on the execution graph is not linear.

C28x 1-Day Workshop - DSP/BIOS Real-Time OS 5 - 17

Page 68: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Lab 5: DSP/BIOS

29. Halt the DSP.

30. In the next few steps the Log Event Manager will be setup to capture an event in real-time while the program executes. We will be using Log_printf() to write to a log buffer. The LOG_printf() function is a very efficient means of sending a message from the code to the CCS display. Unlike an ordinary C-language printf(), which can consume several hundred DSP cycles to format the data on the DSP before transmission to the CCS host PC, a log_printf() transmits the raw data to the host. The host then formats the data and displays it in CCS. This consumes only 10’s of cycles rather than 100’s of cycles.

In Main_5.c just after the static local variable declaration in AdcSwi(), uncomment the following code used with LOG_printf:

static Uint32 AdcSwi_count=0; // used for LOG_printf

/*** Using LOG_printf() to write to a log buffer ***/

LOG_printf(&trace, "AdcSwi_count = %u", AdcSwi_count++);

31. In the configuration file Lab.cdb we need to add and setup the trace buffer. Open Lab.cdb and click on the plus sign (+) to the left of Instrumentation and again on the plus sign (+) to the left of LOG – Event Log Manager.

32. Right click on LOG – Event Log Manager and select Insert LOG. LOG0 will be added. Right-click on it and rename it to trace.

33. Select the Properties for trace and set the logtype to circular and the datatype to printf. Click OK.

34. Since the configuration file was modified, we need to rebuild the project. Click the “Build” button.

35. Reset the DSP.

36. Open the Message Log by clicking:

DSP/BIOS Message Log

The message log dialog box is displaying the number of times (count value) that AdcSwi() has executed.

37. Run the DSP.

38. Observe the operation of the various windows that are open, and the information that they are conveying in real-time.

5 - 18 C28x 1-Day Workshop - DSP/BIOS Real-Time OS

Page 69: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Lab 5: DSP/BIOS

Note: In this module only the basic features of DSP/BIOS and the real-time analysis tools have been used. For more information and details, please refer to the DSP/BIOS user’s manuals and other DSP/BIOS related training.

End of Exercise

C28x 1-Day Workshop - DSP/BIOS Real-Time OS 5 - 19

Page 70: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Lab 5: DSP/BIOS

This page is intentionally blank.

5 - 20 C28x 1-Day Workshop - DSP/BIOS Real-Time OS

Page 71: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Flash Programming

Introduction This module will explain the details to program the flash memory using the Code Composer Studio plug-in. Other programming utilities will be discussed. Additionally, the code security module and CSM passwords will be covered.

Learning Objectives Learning ObjectivesLearning Objectives

Explain concepts and steps required to Explain concepts and steps required to program the flash memoryprogram the flash memoryDiscuss flash programming utilitiesDiscuss flash programming utilitiesShow flash programming CCS plugShow flash programming CCS plug--in in Explain code security module and Explain code security module and CSM passwordsCSM passwords

C28x 1-Day Workshop - Flash Programming 6 - 1

Page 72: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Module Topics

Module Topics Flash Programming................................................................................................................................... 6-1

Module Topics......................................................................................................................................... 6-2 Flash Programming Basics..................................................................................................................... 6-3 Programming Utilities and CCS Plug-in ................................................................................................ 6-4 Code Security Module and Passwords.................................................................................................... 6-5 Lab 6: Flash Programming..................................................................................................................... 6-6

6 - 2 C28x 1-Day Workshop - Flash Programming

Page 73: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Flash Programming Basics

Flash Programming Basics

F28x DSPF28x DSP

FLASHFLASH CPUCPU

RAMRAM

Flash Programming BasicsFlash Programming BasicsThe DSP CPU itself performs the flash programmingThe DSP CPU itself performs the flash programmingThe CPU executes Flash utility code from RAM that reads the The CPU executes Flash utility code from RAM that reads the Flash data and writes it into the FlashFlash data and writes it into the FlashWe need to get the We need to get the Flash utility codeFlash utility code and the and the Flash dataFlash data into RAMinto RAM

JTAGJTAGEmulatorEmulator

SPISPI

GPIOGPIO

SCISCIRS232RS232

RO

MR

OM

Boo

tload

erB

ootlo

ader

Flash Flash utility utility codecode

Flash Flash DataData

Flash Programming BasicsFlash Programming BasicsSequence of steps for Flash programming:Sequence of steps for Flash programming:

Minimum Minimum EraseErase size is a sector (8Kw or 16Kw)size is a sector (8Kw or 16Kw)Minimum Minimum ProgramProgram size is a bit!size is a bit!Important not to lose power during erase step: Important not to lose power during erase step: If CSM passwords happen to be all zeros, the If CSM passwords happen to be all zeros, the CSM will be permanently locked!CSM will be permanently locked!Chance of this happening is quite small! (Erase Chance of this happening is quite small! (Erase step is performed sector by sector)step is performed sector by sector)

1. Erase1. Erase -- Set all bits to zero, then to oneSet all bits to zero, then to one2.2. ProgramProgram -- Program selected bits with zeroProgram selected bits with zero3.3. VerifyVerify -- Verify flash contentsVerify flash contents

AlgorithmAlgorithm FunctionFunction

C28x 1-Day Workshop - Flash Programming 6 - 3

Page 74: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Programming Utilities and CCS Plug-in

Programming Utilities and CCS Plug-in Flash Programming UtilitiesFlash Programming Utilities

Code Composer Studio PlugCode Composer Studio Plug--in (uses JTAG) in (uses JTAG) **Serial Flash loader from TI (uses SCI boot) Serial Flash loader from TI (uses SCI boot) **Gang Programmers (use GPIO boot)Gang Programmers (use GPIO boot)

BP Micro programmerBP Micro programmerData I/O programmerData I/O programmer

Build your own custom utilityBuild your own custom utilityUse a different ROM bootloader method than SCIUse a different ROM bootloader method than SCIEmbed flash programming into your applicationEmbed flash programming into your applicationFlash API algorithms provided by TIFlash API algorithms provided by TI

** Available from TI web at www.ti.comAvailable from TI web at www.ti.com

Code Composer Studio Flash PlugCode Composer Studio Flash Plug--InIn

6 - 4 C28x 1-Day Workshop - Flash Programming

Page 75: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Code Security Module and Passwords

Code Security Module and Passwords Code Security Module (CSM)Code Security Module (CSM)

Data reads and writes from restricted memory Data reads and writes from restricted memory are only allowed for code running from are only allowed for code running from restricted memoryrestricted memoryAll other data read/write accesses are blocked:All other data read/write accesses are blocked:JTAG emulator/debugger, ROM bootloader, code running in JTAG emulator/debugger, ROM bootloader, code running in external memory or unrestricted internal memoryexternal memory or unrestricted internal memory

Access to the following onAccess to the following on--chip memory is chip memory is restricted:restricted:

LO SARAM (4K)LO SARAM (4K)L1 SARAM (4K)L1 SARAM (4K)

OTP (1K)OTP (1K)

FLASH (128K)FLASH (128K)

reserved

0x00 80000x00 8000

0x00 90000x00 9000

0x3D 78000x3D 7800

0x3D 80000x3D 8000reserved

0x00 A0000x00 A000

0x3D 7C000x3D 7C00

CSM PasswordCSM Password

128128--bit user defined password is stored in Flashbit user defined password is stored in Flash128128--bits = 2bits = 2128128 = 3.4 x 10= 3.4 x 103838 possible passwordspossible passwordsTo try 1 password every 2 cycles at 150 MHz, it To try 1 password every 2 cycles at 150 MHz, it would take at least 1.4 x 10would take at least 1.4 x 102323 years to try all years to try all possible combinations!possible combinations!

0x3F 7FF8 0x3F 7FF8 -- 0x3F 7FFF0x3F 7FFF

CSM PasswordCSM PasswordLocations (PWL)Locations (PWL)

LO SARAM (4K)LO SARAM (4K)L1 SARAM (4K)L1 SARAM (4K)

OTP (1K)OTP (1K)

FLASH (128K)FLASH (128K)

reserved

0x00 80000x00 8000

0x00 90000x00 9000

0x3D 78000x3D 7800

0x3D 80000x3D 8000reserved

128128--Bit PasswordBit Password

0x00 A0000x00 A000

0x3D 7C000x3D 7C00

C28x 1-Day Workshop - Flash Programming 6 - 5

Page 76: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Lab 6: Flash Programming

Lab 6: Flash Programming Objective

The objective of this lab is to demonstrate the techniques discussed in this module and program the on-chip flash memory. The TMS320F2812 device has been designed for standalone operation in an embedded system. Using the on-chip flash eliminates the need for external non-volatile memory or a host processor from which to bootload. In this lab, the steps required to properly configure the software for execution from internal flash memory will be covered.

Lab 6: Flash ProgrammingLab 6: Flash Programming

System Programmed into Flash System Programmed into Flash MemoryMemoryUsing of CCS Flash PlugUsing of CCS Flash Plug--ininDO NOT PROGRAM PASSWORDSDO NOT PROGRAM PASSWORDS

CPU copiesCPU copiesresult toresult tobuffer duringbuffer duringADC ISRADC ISR

ADCADCRESULT0RESULT0

GP Timer 2GP Timer 2

GP Timer 2 triggersGP Timer 2 triggersADC SOC everyADC SOC every

20 20 µµs (50 kHz)s (50 kHz)

connectorconnectorwirewire

Compare 1Compare 1PWM CircuitsPWM CircuitsOutput LogicOutput Logic

GP Timer 1GP Timer 1

Event ManagerEvent ManagerADCINA0ADCINA0

......

datadatamemorymemory

poin

ter r

ewin

dpo

inte

r rew

ind

Display Display using CCSusing CCS

IQmathIQmathFIR FilterFIR Filter

Procedure

Project File 1. A project named Lab6.pjt has been created for this lab. Open the project by clicking

on Project Open… and look in C:\C28x1DAY\LABS\LAB6. All Build Options have been configured. The files used in this lab are:

Note: Due to a bug in CCS and DSP/BIOS, the configuration file name (.cdb) and the project output (.out) and map (.map) names must be the same. Therefore, in this module the Build Options output and map file names will be lab.out and map.out, respectively.

6 - 6 C28x 1-Day Workshop - Flash Programming

Page 77: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Lab 6: Flash Programming

Main_6.c Labcfg.cmdLab.cdb DSP281x_Headers_BIOS.cmdUser_6.cmd CodeStartBranch.asmSysCtrl.c Gpio.cDSP281x_GlobalVariableDefs.c PieCtrl_6.cDefaultIsr_5_6.c Adc.cEv.c Filter.c

Link Initialized Sections to Flash Initialized sections, such as code and constants, must contain valid values at device power-up. For a stand-alone embedded system with the F2812 device, these initialized sections must be linked to the on-chip flash memory. Note that a stand-alone embedded system must operate without an emulator or debugger in use, and no host processor is used to perform bootloading.

Each initialized section actually has two addresses associated with it. First, it has a LOAD address which is the address to which it gets loaded at load time (or at flash programming time). Second, it has a RUN address which is the address from which the section is accessed at runtime. The linker assigns both addresses to the section. Most initialized sections can have the same LOAD and RUN address in the flash. However, some initialized sections need to be loaded to flash, but then run from RAM. This is required, for example, if the contents of the section needs to be modified at runtime by the code.

2. The RUN address of the following sections needs to run from flash. The memory section manager in the DSP/BIOS configuration tool (Lab.cdb) has been set to link the following sections to on-chip flash memory:

DSP/BIOS Data tab DSP/BIOS Code tab Compiler Sections tab

.gblinit .bios .text

.sysinit .switch

.hwi .cinit

.rtdx_text .pinit

.econst / .const

.data

3. The LOAD address of the following sections needs to load to flash. Again the memory section manager in the DSP/BIOS configuration tool (Lab.cdb) has been set to specify the load addresses. To view these setting, select the Load Address tab. Notice that the “Specify Separate Load Addresses” box has been checked and all the entries are set to the flash memory block.

C28x 1-Day Workshop - Flash Programming 6 - 7

Page 78: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Lab 6: Flash Programming

Copying .hwi_vec Section from Flash to RAM The DSP/BIOS .hwi_vec section contains the interrupt vectors. This section must be loaded to flash (load address) but run from RAM (run address). The code that performs this copy is located in InitPieCtrl(). The DSP/BIOS configuration tool generates global symbols that can be accessed by code in order to determine the load address, run address, and length of the .hwi_vec section. The C-compiler runtime support library contains a memory copy function called memcpy() which will be used to perform the copy.

4. Open and inspect InitPieCtrl() (in PieCtrl_6.c file). Notice the memcpy() function and the symbols used to initialize (copy) the .hwi_vec section.

Copying the .trcdata Section from Flash to RAM The DSP/BIOS .trcdata section is used by CCS and DSP/BIOS for certain real-time debugging features. This section must be loaded to flash (load address) but run from RAM (run address). The DSP/BIOS configuration tool generates global symbols that can be accessed by code in order to determine the load address, run address, and length of the .trcdata section. The memory copy function memcpy() will again be used to perform the copy.

The copying of .trcdata must be performed prior to main(). This is because DSP/BIOS modifies the contents of .trcdata during DSP/BIOS initialization, which also occurs prior to main(). The DSP/BIOS configuration tool provides a user initialization function which will be used to perform the .trcdata section copy prior to both main() and DSP/BIOS initialization.

5. Open the DSP/BIOS configuration file (Lab.cdb) and select the Properties for the Global Settings. Notice the box “Call User Init Function” has been checked and the UserInit() function name with a leading underscore _UserInit is entered. This will cause the function UserInit() to execute prior to main().

6. Open and inspect the file Main_6.c. Notice that the function UserInit() is used to copy the .trcdata section from its load address to its run address before main().

Initializing the Flash Control Registers The initialization code for the flash control registers cannot execute from the flash memory (since it is changing the flash configuration!). Therefore, the initialization function for the flash control registers must be copied from flash (load address) to RAM (run address) at runtime. The memory copy function memcpy() will again be used to perform the copy. The initialization code for the flash control registers InitFlash() is located in the Flash.c file.

7. Open and inspect Flash.c. The C compiler CODE_SECTION pragma is used to place the InitFlash() function into a linkable section named “secureRamFuncs”.

8. Since the DSP/BIOS configuration tool does not know about user defined sections, the “secureRamFuncs” section will be linked using the user linker command file User_6.cmd. Open and inspect User_6.cmd. The “secureRamFuncs” will load to flash (load address) but will run from L1SARAM (run address). Also notice that the linker has been asked to generate symbols for the load start, load end, and run start addresses.

6 - 8 C28x 1-Day Workshop - Flash Programming

Page 79: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Lab 6: Flash Programming

While not a requirement from a DSP hardware perspective (since the C28x DSP has a unified memory architecture), Code Composer Studio generally prefers code to be linked to program space (and data to be linked to data space). Therefore, notice that for the L1SARAM memory we are linking “secureRamFuncs” to, we are specifiying “PAGE = 0”(which is program space).

9. Open and inspect Main_6.c. Notice that the memory copy function memcpy() is being used to copy the section “secureRamFuncs, which contains the initialization function for the flash control registers.

10. The following line of code in main() is used to call the InitFlash() function. Since there are no passed parameters or return values the code is just:

InitFlash();

at the required spot in main().

Code Security Module and Passwords The CSM module provides protection against unwanted copying (i.e. pirating!) of your code from flash, OTP memory, and the L0 and L1 RAM blocks. The CSM uses a 128-bit password made up of 8 individual 16-bit words. They are located in flash at addresses 0x3F7FF8 to 0x3F7FFF. During this lab, dummy passwords of 0xFFFF will be used – therefore only dummy reads of the password locations are needed to unsecure the CSM. DO NOT PROGRAM ANY REAL PASSWORDS INTO THE DEVICE. After development, real passwords are typically placed in the password locations to protect your code. We will not be using real passwords in the workshop.

The CSM module also requires programming values of 0x0000 into flash addresses 0x3F7F80 through 0x3F7FF5 in order to properly secure the CSM. Both tasks will be accomplished using a simple assembly language program Passwords.asm.

11. Open and inspect Passwords.asm. This file specifies the desired password values (DO NOT CHANGE THE VALUES FROM 0xFFFF) and places them in an initialized section named “passwords”. It also creates an initialized section named “csm_rsvd” which contains all 0x0000 values for locations 0x3F7F80 to 0x3F7FF5 (length of 0x76).

12. Open User_6.cmd and notice that the initialized sections for “passwords” and “csm_rsvd” are linked to memories named PASSWORDS and CSM_RSVD, respectively. The DSP/BIOS configuration tool (Lab.cdb) defines memory blocks for PASSWORDS and CSM_RSVD.

Executing from Flash after Reset The F2812 device contains a ROM bootloader that will transfer code execution to the flash after reset. When the boot mode selection pins are set for “Jump to Flash” mode, the bootloader will branch to the instruction located at address 0x3F7FF6 in the flash. An instruction that branches to the beginning of your program needs to be placed at this address. Note that the CSM

C28x 1-Day Workshop - Flash Programming 6 - 9

Page 80: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Lab 6: Flash Programming

passwords begin at address 0x3F7FF8. There are exactly two words available to hold this branch instruction, and not coincidentally, a long branch instruction “LB” in assembly code occupies exactly two words. Generally, the branch instruction will branch to the start of the C-environment initialization routine located in the C-compiler runtime support library. The entry symbol for this routine is _c_int00. Recall that C code cannot be executed until this setup routine is run. Therefore, assembly code must be used for the branch. We are using the assembly code file named CodeStartBranch.asm.

13. Open and inspect CodeStartBranch.asm. This file creates an initialized section named “codestart” that contains a long branch to the C-environment setup routine. This section has been placed in memory using the DSP/BIOS configuration tool and the memory space is named BEGIN_FLASH.

14. In the earlier lab exercises, the section “codestart” was directed to the memory named BEGIN_H0. Open and inspect User_6.cmd and notice that the section “codestart” will now be directed to BEGIN_FLASH.

15. The eZdsp™ board needs to be configured for “Jump to Flash” bootmode. Move jumper JP7 to position 1-2 to accomplish this. This jumper controls the pullup/down resistor on the GPIOF4 pin, which is one of the pins sampled by the bootloader to determine the bootmode. GPIOF4 alone is sufficient to configure “Jump to Flash” bootmode (see the TMS320F28x DSP Boot ROM Reference Guide, and also the eZdsp F2812 Technical Reference, for more information).

Build – Lab.out 16. At this point we need to build the project, but not have CCS automatically load it since

CCS cannot load code into the flash! (the flash must be programmed). On the menu bar click: Option Customize… and select the “Program Load Options” tab. Uncheck “Load Program After Build”, then click OK.

17. Click the “Build” button to generate the Lab.out file to be used with the CCS Flash Plug-in.

CCS Flash Plug-in 18. Open the Flash Plug-in tool by clicking :

Tools F28xx On-Chip Flash Programmer

19. Notice that the eZdsp™ board uses a 30 MHz oscillator (located on the board near LEDs DS1 and DS2). Confirm the “Clock Configuration” in the upper left corner has the OSCCLK set to 30 MHz and the PLLCR value is set to 10. Recall that the PLL is divided by two, which gives a SYSCLKOUT of 150 MHz.

20. Confirm that all boxes are checked in the “Erase Sector Selection” area of the plug-in window. We want to erase all the flash sectors.

21. We will not be using the plug-in to program the “Code Security Password”. Do not modify the Code Security Password fields.

6 - 10 C28x 1-Day Workshop - Flash Programming

Page 81: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Lab 6: Flash Programming

22. In the “Operation” block, notice that the “COFF file to Program/Verify” field automatically defaults to the current .out file. Check to be sure that “Erase, Program, Verify” is selected. We will be using the default wait states, as shown on the slide in this module.

23. Click “Execute Operation” to program the flash memory. Watch the programming status update in the plug-in window.

24. After successfully programming the flash memory, close the programmer window.

Running the Code – Using CCS 25. In order to effectively debug with CCS, we need to load the symbolic debug information

(e.g., symbol and label addresses, source file links, etc.) so that CCS knows where everything is in your code. Click:

File Load Symbols Load Symbols Only…

and select Lab.out in the Debug folder.

26. Reset the DSP. The program counter should now be at 0x3FFC00, which is the start of the bootloader in the Boot ROM.

27. Single-Step through the bootloader code until you arrive at the beginning of the codestart section in the CodeStartBranch.asm file. (Be patient, it will take about 55 single-steps). Notice that we have placed some code in CodeStartBranch.asm to give an option to first disable the watchdog, if selected.

28. Step a few more times until you reach the start of the C-compiler initialization routine at the symbol _c_int00.

29. Now do Debug Go Main. The code should stop at the beginning of your main() routine. If you got to that point succesfully, it confirms that the flash has been programmed properly, and that the bootloader is properly configured for jump to flash mode, and that the codestart section has been linked to the proper address.

30. You can now RUN the DSP, and you should observe the LED on the board blinking. Try resetting the DSP and hitting RUN (without doing all the stepping and the Go Main procedure). The LED should be blinking again.

Running the Code – Stand-alone Operation (No Emulator) 31. Close Code Composer Studio.

32. Disconnect the emulator from the eZdsp™ board.

33. Remove the power from the board.

C28x 1-Day Workshop - Flash Programming 6 - 11

Page 82: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Lab 6: Flash Programming

34. Re-connect the power to the board.

35. The LED should be blinking, showing that the code is now running from flash memory.

End of Exercise

Lab 6 Reference: BIOS Startup Sequence from Flash Memory

BIOS Startup Sequence from Flash MemoryBIOS Startup Sequence from Flash Memory

H0 SARAM (8K)H0 SARAM (8K)

0x3F 7FF60x3F 7FF6

0x3D 80000x3D 8000

0x3F 80000x3F 8000

0x3F F0000x3F F000

0x3F FFC00x3F FFC0

Boot ROM (4K)Boot ROM (4K)

BROM vector (32)BROM vector (32)0x3F FC000x3F FC00

Boot CodeBoot Code

RESETRESET

0x3F FC000x3F FC00{SCAN GPIO}

FLASH (128K)FLASH (128K)

Passwords (8)_c_int00_c_int00

LBLB

BIOS code Sections

“rts2800_ml.lib”

“user” code sections

_c_int00_c_int00 BIOS_resetBIOS_reset( )( )BIOS_initBIOS_init( )( )main ( )main ( )BIOS_startBIOS_start( )( )

IDL_runIDL_run( )( )

main ( )main ( ){ {

…………return;return;

}}22

33

44

55

66

77

11

6 - 12 C28x 1-Day Workshop - Flash Programming

Page 83: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

The Next Step…

Introduction This module provides an overview to the recommended next steps for developing your design. Also, a list of where to find more information will be covered.

Learning Objectives

Third Party Third Party NetworkNetwork

Comprehensive Tools and Support Set Comprehensive Tools and Support Set Standard in Ease of Use for DevelopersStandard in Ease of Use for Developers

Numerous data converter and power management Numerous data converter and power management products designed for motor controlproducts designed for motor control

HighHigh--PerformancePerformance

Analog Analog

ToolsTools F2812 F2812 eZdspeZdspTMTM developerdeveloper’’s kit from Spectrum Digitals kit from Spectrum DigitalCode Composer Code Composer StudioStudioTMTM IDE for C2000IDE for C2000TMTM

TrainingTrainingand Supportand Support

Control developers seminarControl developers seminarDMC workshopDMC workshopOneOne--day technical introduction to C28xday technical introduction to C28xTMTM

MultiMulti--day get started developing C28xday get started developing C28xTMTM workshopworkshop

Application specific librariesApplication specific librariesMath functionsMath functionsCommunications driversCommunications driversPrePre--bundled system solutionsbundled system solutions

SoftwareSoftware

Development boards and emulation toolsDevelopment boards and emulation toolsLarge consultant networkLarge consultant networkIncreasing range of application softwareIncreasing range of application software

C28x 1-Day Workshop - The Next Step... 7 - 1

Page 84: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Module Topics

Module Topics The Next Step…......................................................................................................................................... 7-1

Module Topics......................................................................................................................................... 7-2 Development Support.............................................................................................................................. 7-3

7 - 2 C28x 1-Day Workshop - The Next Step...

Page 85: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Development Support

Development Support

The F2812 The F2812 eZdspeZdsp™™ integrates the integrates the essential key features to allow essential key features to allow users to understand the users to understand the TMS320F2812 characteristicsTMS320F2812 characteristics

Start Today!Start Today!Hardware FeaturesHardware Features

TMS320F2812 Digital Signal ProcessorTMS320F2812 Digital Signal Processor18 18 KwordsKwords RAMRAM128 128 KwordsKwords on chip Flash ROMon chip Flash ROM64 64 KwordsKwords on board RAMon board RAMExpansion connectorsExpansion connectorsOnboard embedded IEEE 1149.1 JTAG Onboard embedded IEEE 1149.1 JTAG controllercontroller5 Volt only operation with supplied adapter5 Volt only operation with supplied adapterOnboard IEEE 1149.q JTAG emulationOnboard IEEE 1149.q JTAG emulation

Software Software Includes Includes TITI’’ss C28xx Code Composer StudioC28xx Code Composer Studio

Studio Debug ToolsStudio Debug ToolsIncludes Flash programming utilities from Includes Flash programming utilities from Spectrum DigitalSpectrum Digital

SocketedSocketed Version AvailableVersion Available

Recommended Next Step:Recommended Next Step:F2812 F2812 eZdspeZdsp™™

You now have theYou now have theF2812 F2812 eZdspeZdsp™™, so, so……

Recommended Next Step:Recommended Next Step:MultiMulti--day Training Courseday Training Course

TMS320C28x Workshop OutlineTMS320C28x Workshop Outline-- Architectural Overview Architectural Overview -- Programming Development Environment Programming Development Environment -- Peripheral Register Header Files Peripheral Register Header Files -- Reset and Interrupts Reset and Interrupts -- System Initialization System Initialization -- AnalogAnalog--toto--Digital Converter Digital Converter -- Event Manager Event Manager -- Numerical Concepts and Numerical Concepts and IQmathIQmath-- Using DSP/BIOS Using DSP/BIOS -- System Design System Design -- Communications Communications -- Support ResourcesSupport Resources

InIn--depth depth TMS320F2812 TMS320F2812

Design and Design and Peripheral TrainingPeripheral Training

C28x 1-Day Workshop - The Next Step... 7 - 3

Page 86: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Development Support

C28x Signal Processing LibrariesC28x Signal Processing LibrariesSignal Processing LibrariesSignal Processing Libraries Literature #Literature #ACI3_3: Simulated Indirect FOC of ACI MotorACI3_3: Simulated Indirect FOC of ACI Motor SPRC077SPRC077ACI3_4: Real Direct FOC of ACI MotorACI3_4: Real Direct FOC of ACI Motor SPRC079SPRC079ACI3_4: Simulated Direct FOC of ACI MotorACI3_4: Simulated Direct FOC of ACI Motor SPRC078SPRC078ACI3_1: ThreeACI3_1: Three--Phase ACI Control with Constant V/Hz SPRC130Phase ACI Control with Constant V/Hz SPRC130PMSM3_1: ThreePMSM3_1: Three--Phase Phase SensoredSensored FOC SPRC129FOC SPRC129PMSM3_2: ThreePMSM3_2: Three--Phase Phase SensorlessSensorless FOC SPRC128FOC SPRC128Digital Motor Control LibraryDigital Motor Control Library SPRC080SPRC080DSP Fast Fourier Transform (FFT) LibraryDSP Fast Fourier Transform (FFT) Library SPRC081SPRC081DSP Filter LibraryDSP Filter Library SPRC082SPRC082DSP FixedDSP Fixed--Point Math LibraryPoint Math Library SPRC085SPRC085DSP IQ Math LibraryDSP IQ Math Library SPRC087SPRC087DSP Signal Generator LibraryDSP Signal Generator Library SPRC083SPRC083DSP Software Test Bench (STB) LibraryDSP Software Test Bench (STB) Library SPRC084SPRC084C281x C/C++ Header Files and Peripheral ExamplesC281x C/C++ Header Files and Peripheral Examples SPRC097SPRC097

Available from TI DSP Website Available from TI DSP Website ⇒⇒ http://www.dspvillage.ti.comhttp://www.dspvillage.ti.com

DrivetecDrivetec, Inc., Inc.Spectrum Spectrum DigitalDigital

SCHMIDHAUSER AG SCHMIDHAUSER AG

Large Third Party NetworkLarge Third Party Network

7 - 4 C28x 1-Day Workshop - The Next Step...

Page 87: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Development Support

MemoryMemoryFlash: 16Kw Flash: 16Kw –– 64Kw 64Kw (execute at 85 MIPS)(execute at 85 MIPS)RAM: 6Kw RAM: 6Kw ---- 18Kw18Kw

PeripheralsPeripheralsUp to 4Up to 4--channels SPIchannels SPIUp to 2 Up to 2 SCIsSCIs (UART)(UART)II22CCUp to 2 CAN portsUp to 2 CAN ports

Event ManagerEvent ManagerIncreased number of timersIncreased number of timersFlexible PWM channelsFlexible PWM channelsFull Spec TBD (below is preliminary and Full Spec TBD (below is preliminary and may changemay change

Dedicated CAP/QEP Dedicated CAP/QEP –– position DMCposition DMCOne Timer for 6 PWM One Timer for 6 PWM -- synchronizedsynchronized

TMS320F2808TM

32-bitRegister

FileReal-Time

JTAG

32-bitTimers (3)

C28xTM 32-bit DSP

32x32-bitMultiplier

R M WAtomic

ALU

Interrupt Management

Memory Bus

64Kw Flash Boot ROM

10Kw RAM

Code security

Enhanced Event Mgr

ADC

Watchdog

GPIO

4 x SPI

DualCAN

2 x SCI

I²C

Peripheral Bus

64Kw Flash 18Kw RAM Enhanced

Event Mgr

4 x SPI

DualCAN

2 x SCI

I²C ADCADCHigh speed throughput (6.25 MSPS)High speed throughput (6.25 MSPS)Simultaneous sampling or sequencing Simultaneous sampling or sequencing sampling modessampling modes12 bit 1612 bit 16--channel, multiplexed inputschannel, multiplexed inputs

ADC

High Performance CPU CoreHigh Performance CPU Core100 MIPS Performance100 MIPS PerformanceSingle Cycle 32x32 MAC (or dual 16x16)Single Cycle 32x32 MAC (or dual 16x16)Single Cycle ReadSingle Cycle Read--ModifyModify--WriteWriteFast Interrupt ResponseFast Interrupt ResponseF24x/LF240xA Source Code CompatibleF24x/LF240xA Source Code Compatible

New TMS320F280x Devices!New TMS320F280x Devices!

F2806F2806 F2808F2808F2801F2801

1212--bit ADC, bit ADC, 16 channels16 channels

1212--bit ADC, bit ADC, 16 channels16 channels

1212--bit ADC, bit ADC, 16 channels16 channels

Dual CANDual CANCANCANCANCANII22C C II22C C II22C C

2 2 SCIsSCIs (UART)(UART)2 2 SCIsSCIs (UART)(UART)1 SCI (UART)1 SCI (UART)44--channel SPIchannel SPI44--channel SPIchannel SPI22--channel SPIchannel SPI

100100--pin LQFP pin LQFP 100100--pin pin µµ*BGA*BGA

100100--pin LQFP pin LQFP 100100--pin pin µµ*BGA*BGA

100100--pin LQFP pin LQFP 100100--pi pi µµ*BGA*BGA

Code security Code security modulemodule

Code security Code security modulemodule

Code security Code security modulemodule

4Kw ROM4Kw ROM4Kw ROM4Kw ROM4Kw ROM4Kw ROM18Kw RAM18Kw RAM10Kw RAM10Kw RAM6Kw RAM6Kw RAM

64Kw 64Kw Dual FlashDual Flash32Kw Flash32Kw Flash16Kw Flash16Kw Flash

100 MIPS100 MIPS100 MIPS100 MIPS100 MIPS100 MIPSF2808F2808F2806F2806F2801F2801

Options to Meet DeveloperOptions to Meet Developer’’s Needss Needs……

C28x 1-Day Workshop - The Next Step... 7 - 5

Page 88: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Development Support

FLASHClock

DigitalPeripheral

RISCCPU16-bit

MAB 16

MDB 16

RAM

AnalogPeripheral

. . .

. . .ACLK

SMCLK

JTA

G/D

ebug

UltraUltra--low Powerlow Power0.1uA power down0.1uA power down0.8uA standby mode0.8uA standby mode250uA / 1MIPS @ 3V250uA / 1MIPS @ 3V< 6us clock start< 6us clock start--upup< 50nA port leakage< 50nA port leakageZeroZero--power BORpower BOR

HighHigh--PerformancePerformanceModern 16Modern 16--bit RISCbit RISCSCoC integrationSCoC integration

Analog IntegrationAnalog IntegrationSVS, Comparator, BOR, SVS, Comparator, BOR, ADC, DAC, Temp SensorADC, DAC, Temp Sensor

Need a MicroNeed a Micro--Controller, Consider the Controller, Consider the MSP430!MSP430!

Customers Are Using C2000Customers Are Using C2000TMTM

Products For Products For ……

Active suspensionActive suspensionAir conditionersAir conditionersAircraft A/CAircraft A/CBonding machinesBonding machinesBuilding automationBuilding automationCamerasCamerasCar A/CCar A/CCD and DVD drivesCD and DVD drivesCheck readersCheck readersCNC controlCNC controlCompressorsCompressorsCopiersCopiersDoor openersDoor openersElevator motor controlElevator motor controlEncodersEncodersFan controlFan controlFood mixersFood mixersFork liftsFork liftsFuel pumpsFuel pumpsGolf trainersGolf trainersHair removersHair removers

…… and and many many

moremore

Heart/lung machinesHeart/lung machinesHuman transportersHuman transportersIndustrial drivesIndustrial drivesInvertersInvertersLawn mowersLawn mowersMagnetic bearingsMagnetic bearingsMass flow controlMass flow controlMedical pumpsMedical pumpsMissile controlMissile controlPlottersPlottersPostal sortersPostal sortersPower assisted steeringPower assisted steeringPower drillsPower drillsPower generatorsPower generatorsPrintersPrintersRefrigeratorsRefrigeratorsRobot controlRobot controlSewing machinesSewing machinesShip propulsion controlShip propulsion controlStepper motor controlStepper motor controlTextile machinesTextile machinesToy trainsToy trainsTreadmillsTreadmills

Vacuum cleanersVacuum cleanersVibration controlVibration controlWafer testersWafer testersWashing machinesWashing machinesWindmill controlWindmill control

Battery chargingBattery chargingFrequency convertersFrequency convertersFuel cell controlFuel cell controlServer power controlServer power controlSolar energy controlSolar energy controlUninterrUninterr. power supplies. power supplies

TEC controlTEC controlOptical switch controlOptical switch controlTunable laser controlTunable laser control

Adaptive cruise controlAdaptive cruise controlAirbag controlAirbag controlAntitheft systemsAntitheft systems

Blood analyzersBlood analyzersData encryption systems Data encryption systems EE--metersmetersGas sensorsGas sensorsGPS systemsGPS systemsIgnition controlIgnition controlInduction ovensInduction ovensPark assist systemsPark assist systemsPower line modemsPower line modemsRadar controlRadar controlReactor monitoringReactor monitoringRF ID systemsRF ID systemsSpectrum analyzersSpectrum analyzersTelecom switchesTelecom switchesTire pressure sensingTire pressure sensingUltrasound scannersUltrasound scannersWelding equipmentWelding equipmentWireless modemsWireless modems

Motor ControlMotor Control

Digital PowerDigital Power

Optical NetworkingOptical Networking

OthersOthers

7 - 6 C28x 1-Day Workshop - The Next Step...

Page 89: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Development Support

For More InformationFor More Information……

Phone:Phone: 972972--644644--55805580Email:Email: [email protected]@ti.com

Information and support for Information and support for allall TI Semiconductor products/toolsTI Semiconductor products/toolsSubmit Submit suggestionssuggestions and errata for tools, silicon and documentsand errata for tools, silicon and documents

USA USA -- Product Information Center ( PIC )Product Information Center ( PIC )

Website:Website: www.ti.comwww.ti.comwww.dspvillage.ti.comwww.dspvillage.ti.com

FTP:FTP: ftp://ftp.ti.com/pub/tms320bbsftp://ftp.ti.com/pub/tms320bbs

FAQ:FAQ: http://wwwhttp://www--k.ext.ti.com/sc/technical_support/knowledgebase.htm k.ext.ti.com/sc/technical_support/knowledgebase.htm Device informationDevice information my.TImy.TIApplication notesApplication notes News and eventsNews and eventsTechnical documentationTechnical documentation TrainingTraining

InternetInternet

Software Registration/Upgrades:Software Registration/Upgrades: 972972--293293--50505050Hardware Repair/Upgrades:Hardware Repair/Upgrades: 281281--274274--22852285Enroll in Technical Training:Enroll in Technical Training: www.ti.com/sc/trainingwww.ti.com/sc/training

(choose (choose MultiMulti--Day WorkshopsDay Workshops))

Other ResourcesOther Resources

Web:Web: http://wwwhttp://www--k.ext.ti.com/sc/technical_support/pic/euro.htmk.ext.ti.com/sc/technical_support/pic/euro.htm

Phone:Phone: LanguageLanguage NumberNumberBelgium (English)Belgium (English) +32 (0) 27 45 55 32+32 (0) 27 45 55 32FranceFrance +33 (0) 1 30 70 11 64+33 (0) 1 30 70 11 64GermanyGermany +49 (0) 8161 80 33 11+49 (0) 8161 80 33 11Israel (English)Israel (English) 1800 949 01071800 949 0107 (free phone)(free phone)ItalyItaly 800 79 11 37800 79 11 37 (free phone)(free phone)Netherlands (English)Netherlands (English) +31 (0) 546 87 95 45+31 (0) 546 87 95 45SpainSpain +34 902 35 40 28+34 902 35 40 28Sweden (English)Sweden (English) +46 (0) 8587 555 22+46 (0) 8587 555 22United KingdomUnited Kingdom +44 (0) 1604 66 33 99+44 (0) 1604 66 33 99Finland (English)Finland (English) +358 (0) 9 25 17 39 48+358 (0) 9 25 17 39 48

Fax:Fax: All LanguagesAll Languages +49 (0) 8161 80 2045+49 (0) 8161 80 2045

Email:Email: [email protected]@ti.com

Literature RequestsLiterature RequestsSW registration/upgrades, HW repair/upgradesSW registration/upgrades, HW repair/upgradesInformation and support for Information and support for allall TI Semiconductor products/toolsTI Semiconductor products/toolsSubmit Submit suggestionssuggestions and errata for tools, silicon and documentsand errata for tools, silicon and documents

European Product Information Center (EPIC)European Product Information Center (EPIC)

C28x 1-Day Workshop - The Next Step... 7 - 7

Page 90: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Development Support

This page is intentionally blank.

7 - 8 C28x 1-Day Workshop - The Next Step...

Page 91: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Appendix A – eZdsp™ F2812

C28x 1-Day Workshop - Appendix A - eZdsp F2812 A - 1

Page 92: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Appendix

Module Topics Appendix ....................................................................................................................................................A-1

Module Topics......................................................................................................................................... A-2 eZdsp™ F2812 ........................................................................................................................................ A-3

eZdsp™ F2812 Connector / Header and Pin Diagram........................................................................A-3 P2 – Expansion Interface....................................................................................................................A-4 P4 / P8 / P7 – I/O Interface.................................................................................................................A-5 P5 / P9 – Analog Interface..................................................................................................................A-7 eZdsp™ F2812 Jumper Diagram........................................................................................................A-8 JP1 – XMP/MCn Select......................................................................................................................A-8 JP2 – Flash Programming Voltage Select...........................................................................................A-8 JP7 / JP8 / JP11 / JP12 – Boot Mode Select .......................................................................................A-9 JP9 – PLL Disable ..............................................................................................................................A-9 DS1 / DS2 - LEDs ..............................................................................................................................A-9 TP1 / TP2 – Test Points....................................................................................................................A-10

A - 2 C28x 1-Day Workshop - Appendix A - eZdsp F2812

Page 93: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Appendix

eZdsp™ F2812

eZdsp™ F2812 Connector / Header and Pin Diagram

C28x 1-Day Workshop - Appendix A - eZdsp F2812 A - 3

Page 94: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Appendix

P2 – Expansion Interface

A - 4 C28x 1-Day Workshop - Appendix A - eZdsp F2812

Page 95: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Appendix

P4 / P8 / P7 – I/O Interface

C28x 1-Day Workshop - Appendix A - eZdsp F2812 A - 5

Page 96: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Appendix

A - 6 C28x 1-Day Workshop - Appendix A - eZdsp F2812

Page 97: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Appendix

P5 / P9 – Analog Interface

C28x 1-Day Workshop - Appendix A - eZdsp F2812 A - 7

Page 98: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Appendix

eZdsp™ F2812 Jumper Diagram

JP1 – XMP/MCn Select

JP2 – Flash Programming Voltage Select

A - 8 C28x 1-Day Workshop - Appendix A - eZdsp F2812

Page 99: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Appendix

JP7 / JP8 / JP11 / JP12 – Boot Mode Select

JP9 – PLL Disable

DS1 / DS2 - LEDs

C28x 1-Day Workshop - Appendix A - eZdsp F2812 A - 9

Page 100: TMS320C28x 1-Day Workshop - pudn.comread.pudn.com/.../583916/c28x1day_workshop_281x.pdf · 1 - 4 C28x 1-Day Workshop - C28x 1-Day Workshop Overview . Workshop Introduction OOpptical

Appendix

TP1 / TP2 – Test Points

A - 10 C28x 1-Day Workshop - Appendix A - eZdsp F2812