17
LAB EXERCISE 50Hz SPWM USE BOOT ROM USING TMS320F2812 DSP

50hz Spwm Use Boot Rom Using Tms320f2812 Dsp

Embed Size (px)

DESCRIPTION

da

Citation preview

Page 1: 50hz Spwm Use Boot Rom Using Tms320f2812 Dsp

LAB EXERCISE

50Hz SPWM USE BOOT ROM USING TMS320F2812 DSP

Page 2: 50hz Spwm Use Boot Rom Using Tms320f2812 Dsp

Join the Technical Community Today! http://www.pantechsolutions.net

50Hz SINE PWM USE BOOT ROM USING TMS320F2812 DSP

Aim

To Generate the 50 Hz SINE PWM using boot rom sine table

in TMS320F2812 KIT.

Requirements CCS v3.3 TMS320F2812 KIT USB Cable 5V Adapter Theory Pulse Width Modulation(PWM), is a commonly used

technique for controlling power to inertial electrical devices,

made practical by modern electronic power switches.

In TMS320F2812 kit, The F2812 processor core have an Event

Manager to generate the PWMs. The Core has a 2 Event manager,

EVA & EVB. Up to eight PWM waveforms (outputs) can be

generated simultaneously by each event manager. So, totally 16

PWMs get at F2812 processor Which is more than enough to

control a five phase device control. EV have certain Registers to

perform.

Page 3: 50hz Spwm Use Boot Rom Using Tms320f2812 Dsp

Join the Technical Community Today! http://www.pantechsolutions.net

There are two GP timers in each EV module. The GP timer x (x = 1

or 2 for EVA, x = 3 or 4 for EVB) includes:

A 16-bit timer, up-/down-counter, TxCNT, for reads or writes

A 16-bit timer-compare register, TxCMPR (double-buffered

with shadow register), for reads or writes

A 16-bit timer-period register, TxPR (double-buffered with

shadow register), for reads or writes

A 16-bit timer-control register,TxCON, for reads or writes

These four registers are very important and needed to generate

the pwm., some more register(GPTCONA, DBTCONA, COMCONA,

ACTRA, CMPR1, CMPR2, CMPR3, CAPCONA) are available to

Control the PWM.

Example: Calculating the period value for 1 Khz pwm

Where,

Page 4: 50hz Spwm Use Boot Rom Using Tms320f2812 Dsp

Join the Technical Community Today! http://www.pantechsolutions.net

SYSCLKOUT = 125 Mhz

HISPCP – 2

TPS – 1 (Load the TPS Value in T1con register).

TIPWM – 1000 (1 khZ).

T1PR = F424; for 1 Khz period value.

T1CMPR = 7A12.(50 % Duty Cycle)

SPWM

Sinusoidal pulse width modulation is a method of pulse width

modulation used in inverters. An inverter produces an AC output

voltage from a DC input by using switching circuits to simulate a

sine wave by producing one or more square pulses of voltage per

half cycle. If the widths of the pulses are adjusted as a means of

regulating the output voltage, the output is said to be pulse width

modulated.

With sinusoidal or sine weighted pulse width modulation, several

pulses are produced per half cycle. The pulses near the edges of

the half cycle are always narrower than the pulses near the center

of the half cycle such that the pulse widths are proportional to the

corresponding amplitude of a sine wave at that portion of the

Page 5: 50hz Spwm Use Boot Rom Using Tms320f2812 Dsp

Join the Technical Community Today! http://www.pantechsolutions.net

cycle. To change the effective output voltage, the widths of all

pulses are increased or decreased while maintaining the

sinusoidal proportionality. With pulse width modulation, only the

widths (on-time) of the pulses are modulated. The amplitudes

(voltage) during the "on-time" is constant unless a multi-step

circuit is used. The line-to neutral voltage of a 3-phase inverter

has two voltage levels.

Page 6: 50hz Spwm Use Boot Rom Using Tms320f2812 Dsp

Join the Technical Community Today! http://www.pantechsolutions.net

Boot ROM Table

From Address 0x3F F000 to 0x3F F3FF we find 512 values for

sin(x). The numbers are stored as 32 Bit – numbers in “Q30”-

notation. With 512 entries we have an angle step of 0.703°

(360°/512) for a unit circle.

The following table shows the contents of the sine wave area

of the Boot ROM:

Page 7: 50hz Spwm Use Boot Rom Using Tms320f2812 Dsp

Join the Technical Community Today! http://www.pantechsolutions.net

Procedure Note: Once you install the Code Composer Studio v 3.3 software, the two icons will display in desktop

I. Setup Code Composer Studio v3.3 II. Code Composer Studio

1. Open Setup Code Composer Studio v3.3. 2. In System Configuration, select the board then Remove all

yes. a. In family, select C28xx. b. In platform, select xds100 usb emulator. c. In Endianness, select little. d. Select F2812 XDS100 USB Emulator add save & quit no.

Note: The above two steps only for first time to setup the processor in CCS. 3. Open Code Composer Studio v3.3. 4. Project New.

a. Project name: type the project name. b. Location: Browse, select the project location . c. Project Type: Executable(.out) d. Target: TMS320C28XX. Finish.

Page 8: 50hz Spwm Use Boot Rom Using Tms320f2812 Dsp

Join the Technical Community Today! http://www.pantechsolutions.net

5. File New Source file. a. Type the program in untitled window.

6. File Save.

a. Browse our project location then type our project name.c ( .c extension is must) save.

7. Paste the following two cmd files in our project folder. a. F2812_EzDSP_RAM_lnk.cmd b. DSP281x_Headers_nonBIOS.cmd c. DSP281x_GlobalVariableDefs.c d. DSP281x_DefaultIsr.c e. DSP281x_PieCtrl.c f. DSP281x_PieVect.c

8. Project Add files to project.

a. In file of type : All files b. Ctrl + Select the following files

projectname.c

DSP281x_GlobalVariableDefs.c

DSP281x_DefaultIsr.c

DSP281x_PieCtrl.c

DSP281x_PieVect.c

F2812_EzDSP_RAM_lnk.cmd

DSP281x_Headers_nonBIOS.cmd open.

Page 9: 50hz Spwm Use Boot Rom Using Tms320f2812 Dsp

Join the Technical Community Today! http://www.pantechsolutions.net

9. Project Build Option. a. In compiler tab, select Preprocessor

Include search path(-i):

C:\tidcs\c28\DSP281x\v120\DSP281x_headers\include

b. In linker tab, select libraries Search path(-i): C:\CCStudio_v3.3\C2000\cgtools\lib Incl libraries(-l): rts2800_ml.lib.

c. In linker tab, select Basic Stack Size(-stack): 0x400 ok.

10. Project Build (or) Rebuild all. 11. Connections for TMS320F2812 KIT:

a. Connect 5v adpter to TMS320F2812 kit. b. Connect usb cable to TMS320F2812 kit from pc. c. Power on the TMS320F2812 kit.

12. Debug connect. 13. File Load Program Browse and select the

projectname.out file open

14. Debug Go main. 15. Debug Run. 16. See the output at CRO by connecting probe positive terminal

to (Port A) PWM pins & negative terminal to Ground. 17. Debug Halt.

Page 10: 50hz Spwm Use Boot Rom Using Tms320f2812 Dsp

Join the Technical Community Today! http://www.pantechsolutions.net

Program #include "DSP281x_Device.h"

#include "IQmathLib.h"

#pragma DATA_SECTION(sine_table,"IQmathTables");

_iq30 sine_table[512];

void InitSystem(void);

void InitPieCtrl();

void InitPieVectTable();

interrupt void T1_Compare_isr(void);

void main()

{

InitSystem();

EALLOW;

GpioMuxRegs.GPAMUX.all = 0x0040;

EDIS;

Page 11: 50hz Spwm Use Boot Rom Using Tms320f2812 Dsp

Join the Technical Community Today! http://www.pantechsolutions.net

InitPieCtrl();

InitPieVectTable();

EALLOW;

PieVectTable.T1CINT = &T1_Compare_isr;

EDIS;

PieCtrlRegs.PIEIER2.bit.INTx5 = 1; //

enable PIE GP Timer 1 compare interrupt

IER = 2;

EINT;

ERTM;

EvaRegs.T1CNT = 0x0000;

EvaRegs.T1PR = 0x1312; //

period value for 12.8khz carrier pwm freq

EvaRegs.T1CMPR = 0x0989; //

50% duty cycle

Page 12: 50hz Spwm Use Boot Rom Using Tms320f2812 Dsp

Join the Technical Community Today! http://www.pantechsolutions.net

EvaRegs.GPTCONA.bit.TCMPOE = 1;

// Drive T1/T2 PWM by compare logic

EvaRegs.GPTCONA.bit.T1PIN = 1; //

Polarity of GP Timer 1 Compare = Active low

EvaRegs.EVAIMRA.bit.T1CINT = 0; //

enable GP Timer 1 compare interrupt

EvaRegs.T1CON.all = 0x1042; //

Enable GP Timer

for(;;);

}

void InitSystem()

{

EALLOW;

SysCtrlRegs.WDCR= 0x0068; //

Setup the watchdog

//

0x0068 to disable the Watchdog , Prescaler = 1

Page 13: 50hz Spwm Use Boot Rom Using Tms320f2812 Dsp

Join the Technical Community Today! http://www.pantechsolutions.net

//

0x00AF to NOT disable the Watchdog, Prescaler = 64

SysCtrlRegs.SCSR = 0; //

Watchdog generates a RESET

SysCtrlRegs.PLLCR.bit.DIV = 10; // Setup

the Clock PLL to multiply by 5

SysCtrlRegs.HISPCP.all = 0x1; // Setup

Highspeed Clock Prescaler to divide by 2

SysCtrlRegs.LOSPCP.all = 0x2; // Setup

Lowspeed CLock Prescaler to divide by 4

// Peripheral clock enables set for the selected peripherals.

SysCtrlRegs.PCLKCR.bit.EVAENCLK=1;

SysCtrlRegs.PCLKCR.bit.EVBENCLK=0;

SysCtrlRegs.PCLKCR.bit.SCIAENCLK=0;

SysCtrlRegs.PCLKCR.bit.SCIBENCLK=0;

SysCtrlRegs.PCLKCR.bit.MCBSPENCLK=0;

SysCtrlRegs.PCLKCR.bit.SPIENCLK=0;

SysCtrlRegs.PCLKCR.bit.ECANENCLK=0;

Page 14: 50hz Spwm Use Boot Rom Using Tms320f2812 Dsp

Join the Technical Community Today! http://www.pantechsolutions.net

SysCtrlRegs.PCLKCR.bit.ADCENCLK=0;

EDIS;

}

void T1_Compare_isr(void)

{

static int index=0;

EvaRegs.T1CMPR = EvaRegs.T1PR -

_IQsat(_IQ30mpy(sine_table[index]+_IQ30(0.9999),EvaRegs.T1PR

/2),EvaRegs.T1PR,0);

index +=1;

if (index >511) index = 0;

EvaRegs.EVAIFRA.bit.T1CINT = 1; //

Reset T1 Compare Interrupt Flag

PieCtrlRegs.PIEACK.all = PIEACK_GROUP2; //

Acknowledge this interrupt to receive more interrupts from group

2

}

Page 15: 50hz Spwm Use Boot Rom Using Tms320f2812 Dsp

Join the Technical Community Today! http://www.pantechsolutions.net

Result

Thus, the 50Hz SPWM was generated using Boot Rom Table in TMS320F2812 Kit.

Page 16: 50hz Spwm Use Boot Rom Using Tms320f2812 Dsp

Join the Technical Community Today! http://www.pantechsolutions.net

Pantech solutions creates information packed technical

documents like this one every month. And our website is a

rich and trusted resource used by a vibrant online community

of more than 1,00,000 members from organization of all

shapes and sizes.

Did you enjoy the read?

Page 17: 50hz Spwm Use Boot Rom Using Tms320f2812 Dsp

Join the Technical Community Today! http://www.pantechsolutions.net

What do we sell?

Our products range from Various Microcontroller

development boards, DSP Boards, FPGA/CPLD boards,

Communication Kits, Power electronics, Basic electronics,

Robotics, Sensors, Electronic components and much more . Our

goal is to make finding the parts and information you need

easier and affordable so you can create awesome projects and

training from Basic to Cutting edge technology.