Front Cover - Mtech Lab FINAL - MANUALSOFT
Front Cover - Mtech Lab FINAL - MANUALSOFT
Front Cover - Mtech Lab FINAL - MANUALSOFT
Lab Record
Subject code
Reg. No.
for
the
Practical
Examination
held
on
Date:
Staff In-charge
Internal Examiner
Ex.
No
Date
External Examiner
Page
No
Signature
2
3
4
5
8
9
10
11
12
13
14
PROGRAM STARTUP
Create and Configure Project:
A project stores all the information needed to build an individual program or library.
Creating a Project:
The following procedure allows you to create single or multiple new projects (multiple projects can be open
simultaneously). Each projects filename must be unique.
The information for a project is stored in a single project file (*.pjt).
Step 1: In lab it is installed Code Composer Studio in C:\CCStudio_3.1, create a folder called (project
name) in the C:\CCStudio_3.1\myprojects folder.
Step 2: From the Project menu, choose New. The Project Creation wizard window displays.
Step 3: In the Project Name field, type the name you want for your project.
Step 4: In the Location field, specify the directory where you want to store the project file, Object files
generated by the compiler and assembler are also stored here. You can type the full path in the location field
or click the browse
button and use the choose directory dialog box.
Step 5: In the Project Type field, select a Project Type from the drop-down list. Choose either Executable
(.out) or Library (lib). Executable indicates that the project generates an executable file. Library indicates
that you are building an object library.
Step 6: In the Target field, select the target family that identifies your CPU. This information is necessary
when tools are installed for multiple targets.
Step 7: Click Finish.
A project file called projectname.pjt is created. This file stores all files and project settings used by your
project.
Step 2: In the Add Files to Project dialog box, specify a file to add. If the file does not exist in the current
directory, browse to the correct location. Use the Files of Type drop-down list to set the type of files that
appear in the File name field.
Step 3: Click Open to add the specified file to your project. Paths followed for adding files are:
Step4: Also create a new file for the program and save as the program name.asm or .c depending on the
program and add it in the project.
Step 5: Add F2407.h file from the desktop to the folder project name created in step 1 of project creation.
Thus the project is now ready for programming and it can be interfaced with the kit by JTAG and .out file is
loaded with this CC Studio and output can be seen through ports of the kit.
Results:
ACC
CARRY FLAG
Results:
Value before execution
ACC
0F006H
LOCATION 8000h
0003H
CARRY FLAG
0
LACC #0DA0Fh
1
MAR *, AR1
ADD *+
END B END
Results:
ACC
Carry flag
AR1
PC
TMS320LF2407A.
Power supply adaptor cable
DB25 connector printer cable.
Software:
Code composer studio 3.1
Windows 95/98/NT/XP.
Program:
.def_c_int0
.include f2407.h
.text
_c_int0
LDP #100h
SPLK #0FDDFh,10h
LACC #0DA0Fh
LARP 01
LAR AR0, #0003h
LAR AR1, #8010h
ADD *0+
END B END
Results:
ACC
Carry flag
AR0
AR1
0
0003h
8010h
1
0003h
8013h
Objective:
To write a program to add numbers using indirect addressing modes using *0+
operand and pointing next auxiliary register along with shift.
Equipments required:
Hardware:
PC
TMS320LF2407A
Power supply adaptor cable.
DB25 connector printer cable
Software:
code composer studio 3.1
windows 95/98/NT/XP.
Program:
.def_c_int0
.include f2407.h
.text
_c_int0
LDP #100h
SPLK #0FDDFh, 8010h
LACC #0DA0Fh
LARP 01
LAR AR0, #0003h
LAR AR1, #8010h
ADD *0+, 8, AR4
END B END
Results:
ACC
Carry flag
AR0
AR1
ARP
0
0003h
8010h
01
1
0003h
8013h
04
Date:
Objective:
To write a program to store 0-127 in 300h-37Fh and move block of data from
300h-37Fh to 380h-3FFh.
Equipments Required:
Hardware:
PC
TMS320LF2407A
Power supply adapter cable
DB25 connector printer cable
Software:
Windows 95/98/NT/XP
Code Composer 3.1
Flow chart:
Start
Load count value in AR0 and load AR1 and AR2 values
Make AR1 as current auxiliary register Load the accumulator value in mem. Address pointed by AR1
Count=0
BB
Count=0
No
Yes
Program:
END
.def _c_int0
.include f2407.h
.text
_c_int0
LAR AR0, #127
LAR AR1, #300H
LAR AR2, #380h
LACL #00h
Loop: MAR *, AR1
SACL *+, 0, AR0
ADD #1
BANZ Loop
LAR AR0, #127
`
LAR AR1,#300H
LOOP2 :LACL #0
MAR *, AR1
LACL *+, 0, AR2
SACL *+, AR0
BANZ LOOP2
END B END
Result:
Acc
AR0
AR1
AR2
Exp No: 3
Date:
Objective:
To write a program to complement the data in memory location 380h-3FFh.
Equipments Required:
Hardware:
PC
TMS320LF2407A
Power supply adapter cable
DB25 connector printer cable
Software:
Windows 95/98/NT/XP
Code Composer 3.1
Flow chart:
Start
Count=0
no
yes
END
Program:
.def _c_int0
.include f2407.h
.text
_c_int0
LDP #7
LAR AR0, #127
LAR AR1, #380H
Loop: LACL #00h
MAR *, AR1
LACL *, 0, AR1
CMPL
SACL *+, AR0
BANZ Loop
END B END
Result:
AR0
AR1
ACC
Date:
Objective:
To write a program to multiply two numbers using auxiliary registers as pointer to
different memory address.
Equipments required:
Hardware:
PC
TMS320LF2407A
Power supply adaptor cable
DB25 connector printer cable
Software:
Code composer studio 3.1.
Windows 95/98/NT/XP.
Algorithm:
1. start
2. Load AR0 with the memory address which contains the data to be multiplied.
3. Load AR1 with the memory address which contains the data to be multiplied.
4. Store the data at location pointed by AR0 into TREG register.
5. Multiply the data
6. Store the data in the accumulator
7. Move the data from accumulator to the required memory location
Program:
.def _c_int0
.include f2407.h
.text
_c_int0
LAR AR0, #200h
MAR *, AR1
LAR AR1, #270h
LTA *, AR0
MPY *, AR3
PAC
LAR AR3, #300h
Results:
ACC
200h
270h
PREG
300h
301h
Delay Routine
Exp. No.: 5
Date:
Objective:
Machine cycles
1
2
RPT #
NOP
BANZ
4 when true
2 when false
Program:-
with
LDP #224
SPLK #0601h, SCSR1
F
Fclk*1 prescalar.
DELAY: MAR *, AR0
LAR AR0, #4D59h
LOOP:
RPT #499
NOP
BANZ LOOP
: Delay Routine
Result:
Delay is generated using RPT instruction.
Equipments Required:
Hardware:
PC
TMS320LF2407A
Power supply adapter cable
DB25 connector printer cable
Software:
Windows 95/98/NT/XP
Code Composer studio 3.1
Registers Involved:
SCSR1: System control and status register
MCRA: Mux Control register A
PADATDIR: PortA data and direction control register
Algorithm:
1. Start
2. Configure SCSR1 for required clk prescalar.
3. Configure MCRA for secondary function of the GPIO pins.
4. Configure PADATDIR in order to make the I/O pins as output pins.
5. Send High Signal on port A
6. Call Delay
7. Send Low signal on port A
8. Call delay
9. Go to step 5
Flow chart:
Start
Delay Calculation:
Calculation of delay for 1sec.
With Fclk=10 Mhz and prescalar Fclk*1
Instruction
MAR *
LAR *, _
Machine cycles
1
2
RPT #
NOP
BANZ
4 when true
2 when false
Delay required (sec) = ((Total machine cycles)*(time taken to execute 1 machine cycle))
1sec= [1+2+x (1+500+4)+2]
X=19801
X=4D59. Value must be loaded into ARx
Program:.def _c_int0
.include f2407.h
.text
_c_int0
LACC #0h
LDP #224
SPLK #0601h, SCSR1
LDP #225
SPLK #0FF00h, MCRA
LOOP: SPLK #0FF0Fh, PADATDIR
B DELAY
SPLK #0FF00h, PADATDIR
B DELAY
B LOOP
DELAY: MAR *, AR0
LAR AR0, #4D59h
LOOP1: RPT #499
N OP
BANZ LOOP1
Connection Diagram:
Result:
Algorithm:
Step1: Start.
Step2: Initialize General Purpose Timer 1..
Step3: Initialize variables and hardware.
Step4: Turn on timer 1.
Step5: Enable Timer 1 interrupt flag.
Step6: Reset timer 1 interrupt flag.
Step7: Set duty cycle to table value
Step8: Set End of sine wave.
Step9: End
Registers Involved:
T1PR=921
T1PR register is to be loaded as followsPeriod Value = CPUCLK/PRESCALER/DESIRED FREQ = 14*10^6/1/500=28000
CPUCLK=14MHz
PRESCALER=1. This is set by bits 10-8 of T1CON
CMPR1= 460
For 50% duty cycle CMPR1 value will be half of T1PR
GPTCONA = 0x0042
Enable all GP Timer Compare outputs and polarity of GP Timer1 and GP Timer2
compare outputs to active High
T1CON=0x9142
Select Continuous Up counting mode ,set input prescaler to 1,select internal clock, enable
timer operation and program the counter to stop immediately on emulation suspend.
MCRA = T1PWM
Configure all the pins to operate in primary function.
Program:
#include "system.h"
#include "eva.h"
#include "io2407.h"
unsigned int sine[32] = {460, 550, 637, 716, 786, 843, 886, 912,
921, 912, 886, 843, 786, 716, 637, 550, 460, 371,
284, 205, 135, 78, 35, 9, 0, 9, 35, 78, 135, 205, 284, 371 };
unsigned int cosine[32] = {921, 912, 886, 843, 786, 716, 637, 550,
460, 371, 284, 205, 135, 78, 35, 9,0, 9, 35, 78, 135,
205, 284, 371, 460, 550, 637, 716, 786, 843, 886, 912};
/* Initialise General Purpose Timer 1. */
void init_GPT1(void)
{
MCRA |= T1PWM; /* Turn on T1PWM */
T1CON = 0x8142; /* Turn off GPT1 */
GPTCONA |= 0x0042;
T1PR = 921; /* Period = 921 + 1 decimal. 16 kHz */
T1CMPR = 460; /* Duty = 50% */
To
pin12
Filter Circuit
Graphs:
To pin 17
Exp No: 8
Date:
Objective:
To generate asymmetric PWM pulses of 10kHz of 75% duty cycle under
continuous up count mode & active high condition.
Equipments Required:
Hardware:
PC
TMS320LF2407A
Power supply adapter cable
DB25 connector printer cable
Software:
Windows 95/98/NT/XP
Code Composer 3.1
Solution:
SPLK #0000 0110 0000 1101b,SCSR1
bit 15
0:
reserved
bit 14
0:
CLKOUT=CPUCLK
bit 13-12
00: IDLE1 selected for low power mode
bit 11-9
011: PLL x1 mode
bit 8
0:
reserved
bit 7
0: disable ADC module clock
bit 6
0: disable SCI module clock
bit 5
0: disable SPI module clock
bit 4
0: disable CAN module clock
bit 3
1: enable EVB module clock
bit 2
1: enable EVA module clock
bit 1
0: reserved
bit 0
1: clear the ILLADR bit
SPLK #0000 0000 0100 0010b,GPTCONA
bit 15
0:
reserved
bit 14
0: T2STAT,read only
bit 13
0: T1STAT,read only
bit 12-11 00: reserved
bit 10-9
00: T2TOADC,00 = no timer2 event starts ADC
bit 8-7
00: T1TOADC,00 = no timer1 event starts ADC
bit 6
1: TCOMPOE,0 = Hi-Z all timers compare outputs
bit 5-4
bit 3-2
bit 1-0
00:
00:
10:
reserved
T2PIN,00 = forced low
T1PIN,10 = active high
Flowchart:
Program:
.def_c_int0
.include f2407.h
.text
_c_int0
NOP
LDP #DP_PF1
SPLK #060CH,SCSR1
LDP #0E1H
SPLK #0FFFFH,MCRA
SPLK #0FFFFH,MCRC
LDP #0E8H
SPLK #0000H,T1CNT
SPLK #01F3H,T1PR
SPLK #00A6H,T1CMPR
SPLK #0042H,GPTCONA
SPLK #9142H,T1CON
LOOP B LOOP
Waveform :
Results:
Asymmetric PWM pulses of 10KHz of 75% duty cycle is obtained.
Inferences:
For getting 75% duty cycle PWM pulse with active high condition the compare register
should be loaded with one-fourth the period register value.
Exp.No: 9
Date:
Objective:
To write a program to generate PWM pulses of frequency 1kHz using full compare units.
Equipments Required:
Hardware:
PC
TMS320LF2407A
Power supply adapter cable
DB25 connector printer cable
Software:
Windows 95/98/NT/XP
Code Composer studio 3.1
Algorithm:
Step1: Start.
Step2: Configure SCSR1 register as required so as to enable clock for EVA module.
Step3: Configure pins to operate in primary function using MCRA instruction.
Step4: Initialize timer counter value to zero.
Step5: Set up and load ACTR
Step6: Set up and load DBTCON, if dead band is to be used.
Step7: Initialize CMPR1
Step8: Set up and load COMCON without enabling compare operation.
Step9: Set up and load COMCON to enable compare operation.
Step10: Set up and load T1CON to start the operation.
Step11: Rewrite CMPRx with newly determined values.
Step12: end
In the following program up counting mode of the timer 1 has been used.
Registers Involved:
CPUCLK=10MHz
PRESCALER=2. This is set by bits 10-8 of T1CON
T1PR=10000
T1PR register is to be loaded as follows-
TxPR=
CMPR1= 2499=(09C3)h
For 50% duty cycle CMPR1 value will be half of T1PR
GPTCONA = 004Ah
Enable all GP Timer Compare outputs and polarity of GP Timer1 and GP Timer2
compare outputs to active High
T1CON=(9142)h
Select Continuous Up counting mode, set input pre-scalar to 1,select internal clock, enable
timer operation and program the counter to stop immediately on emulation suspend.
MCRA = 0FFFh
Flowchart:
START
Start
Configure Compare Control Register without enabling compare operation i.e, to 04A00h
Configure Compare Control Register with enabling compare operation i.e, to 0CA00h
Program:
.def _c_int0
.include f2407.h
.text
_c_int0
NOP
LDP #DP_PF1
SPLK #0605H, SCSR1
LDP #DP_PF2
SPLK #0FFFFH, MCRA
LDP #0E8H
SPLK #0000H, T1CNT
SPLK #004AH, GPTCONA
SPLK #1387H, T1PR
SPLK #09C3H, CMPR1
SPLK #0AAAH, ACTRA
SPLK #4A00H, COMCONA
SPLK #0CA00H, COMCONA
SPLK #9142h, T1CON
END
B END
To check the square wave output on the oscilloscope, the following connections should be made:
Each Compare Unit has two outputs namely PWM1 and PWM2.
If COMPARE unit 1 is used we check the output at pins 9 and 19 (ground) for PWM1 signal and
for another signal namely PWM2 pins 10 and 20(ground) are to be connected to the C.R.O.
Waveform:
Results:
PWM pulses of 50% duty cycle are generated using full compare unit.
Inferences:
If Timer1 period register T1PR value is set to value 4999 and compare unit value is set to 2500
and hence PWM pulses of 50% duty cycle will be generated.
PC
TMS320LF2407A
Power supply adapter cable
DB25 connector printer cable
Resister 17K
Potentiometer 10K
Software:
Windows 95/98/NT/XP
Registers Involved:
SCSR1: System control status register1
SCSR2: System control status register2
ADCTRL1: ADC control register1
MAX_CONV: Maximum number of auto conversion
CHSELSEQ1: ADC input channel select sequencing control register
ADCTRL2: ADC control register2
RESULT0: ADC result register0
Algorithm:
1. Start
2. Configure SCSR1 in order to enable the clock for ADC and select the clock
prescalar.
3. Configure SCSR2 to disable the watchdog timer and to select the mode of
operation.
4. Configure ADCTRL1 in order to decide the acquisition time prescalar and to run
the ADC in start-stop mode.
5. Configure MAX_CONV register for maximum one conversion in one ADC
trigger.
6. Configure CHSELSEQ1 register to select 1 of the 16 multiplexed analog input
ADC channels for an auto-sequenced conversion and to specify the sequence of
conversion.
7. Configure ADCTRL2 to trigger the ADC through software.
8. Give some delay for ADC to finish the conversion.
9. Check whether the conversion is finished or not by monitoring the bit 12 in
ADCTRL2.
10.
If the conversion is finished load the result from RESULT0 register into
the accumulator. Shift the data by 6 and store it into desired memory location.
11. End
Flowchart:
START
NO
YES
Store the result in
accumulator
B
Load AR0 with specified
memory address
Program:.def _c_int0
.include f2407.h
.text
_c_int0
LDP #225
SPLK #0681h, SCSR1
LACL SCSR2
OR #000Bh
AND #000Fh
SACL SCSR2
LDP #225
SPLK #4000h, ADCTRL1
NOP
NOP
SPLK #3000h, ADCTRL1
SPLK #0000h, MAX_CONV
SPLK #0000h, CHSELSEQ1
SPLK #4000h, ADCTRL2
NOP
NOP
LOOP1: SPLK #2000h, ADCTRL2
LOOP2: NOP
NOP
NOP
LACL ADCTRL2
XOR #2200h
BCND LOOP3, EQ
B LOOP2
LOOP3: LDP #225
LACL RESULT0
SFR 6
MAR *, AR0
LAR AR0, #300h
SACL *+, 0, AR0
B LOOP1
Result:
The analog signal at ADCIN0 pin of DSP is converted into the equivalent digital value
and the result is stored into specified memory location.
Equipments Required:
Hardware:
PC
TMS320LF2407A
Power supply adapter cable
DB25 connector printer cable
Resisters 1K
TL250
MOSFET IRF 640
Software:
Windows 95/98/NT/XP
Code Composer studio 3.1
Algorithm:
Step1: Start.
Step2: Configure SCSR1 register as required so as to enable clock for EVA module.
Step3: Configure pins to operate in primary function using MCRA instruction.
Step4: Initialize T1PR for 20kHz frequency.
Step5: set T1CNT to zero.
Step6: Set T1CMPR for 50%duty cycle.
Step7: Configure GPTCONA for active high pulse.
Step8: Configure T1CON for continuous up count mode
Step9: Wait till the PWM is generated
Step10: repeat the process
In the following program up counting mode of the timer 3 has been used.
Registers Involved:
T1PR
T1PR register is to be loaded as follows-
T1CON=9142h
Select Continuous Up counting mode, set input pre-scalar to 1,select internal clock, enable timer
operation and program the counter to stop immediately on emulation suspend.
MCRA = 0FFFFh
Configure all the pins to operate in primary function.
Start
Set Data page to 224
End
Program:
.def _c_int0
.include f2407.h
.text
_c_int0
LDP #224
SPLK #070CH,SCSR1
LDP #0E1H
SPLK #0FFFFH,MCRA
LDP #0E8H
SPLK #0000H,T1CNT
SPLK #249,T1PR
SPLK #125,T1CMPR
SPLK #0042H,GPTCONA
SPLK #9142H,T1CON
LOOP B LOOP
Circuit Diagram:
Pin Diagram:
Connection Circuitry:
Output Waveform1:
SCSR1 : 0605h
The clock prescalar is selected as 1 x Fin and the EVA module is enabled.
Fin is the CPU clock frequency = 10 MHz
MCRA = 0FFFh
Program
.def _c_int0
.include f2407.h
.text
_c_int0
NOP
LDP #224
SPLK# 0605H, SCSR1
LDP# 225
SPLK# 0FFFFH, MCRA
LDP# 0E8H
SPLK# 0000H, T1CNT
SPLK# 004AH, GPTCONA
SPLK# 030DH, T1PR
SPLK# 0186H, CMPR1
SPLK# 0176H, CMPR2
SPLK# 0012H, ACTRA
SPLK# 0CA00H, COMCONA
SPLK# 8F4AH, T1CON
END B END
50Hz pulses
Pulses with dead band(50Hz)
HARDWARE SETUP
HARDWARE RESULTS
Conclusion
This experiment is performed to get PWM output of frequency 50 Hz and 50%
duty cycle which can be used as the switching pulses for a single phase Inverter. The
frequency of the pulses can be varied by adjusting the value of period register, T1PR and
pre scalar values in T1CON and SCSR1 registers. To select the logic level of PWM
output from compare actions, the value in ACTRA is configured. Instead of using a
deadband registers, 2 compare registers are configured to get a deadband of 240 s.
Objective: To write a program to generate six PWM pulses with and without dead band
Equipments Required:
Hardware:
1.
PC
2.
TMS320LF2407A
3.
Power supply adapter cable
4.
DB25 connector printer cable
Software:
1
Windows 95/98/NT/XP
2
Code Composer studio 3.1
Algorithm:
Step1: Start.
Step2: Configure SCSR1 register as required so as to enable clock for EVA module.
Step3: Configure pins to operate in primary function using MCRA instruction.
Step4: Initialize timer counter T1CNT value to zero.
Step5: Set up and load ACTR
Step6: Set up and load DBTCON.
Step7: Set up and load T1PR
Step8: Initialize CMPR1, CMPR2, CMPR3
Step9: Set up and load COMCON to enable compare operation.
Step10: Set up and load T1CON to start the operation.
Step11: Set up and load GPTCONA.
Step12: end
FLOWCHART:
start
Configure Compare Control Register with enabling compare operation i.e, to 0CA00h
In the following program up counting mode of the timer 1 has been used.
Registers Involved:
T1PR= 1387H
T1PR register is to be loaded as followsPeriod Value = (5000-1) =4999
CPUCLK=10MHz
PRESCALER=1 this is set by bits 10-8 of T1CON
CMPR1, CMPR2, CMPR3= 2500
For 50% duty cycle CMPR1, CMPR2, CMPR3 value will be half of T1PR
GPTCONA = 004Ah
Enable all GP Timer Compare outputs and polarity of GP Timer1 and GP Timer2
compare outputs to active High
T1CON=1046h
Select Continuous Up counting mode, set input pre-scalar to 1,select internal clock, enable
timer operation and program the counter to stop immediately on emulation suspend.
MCRA = 0FFFh
Configure all the pins to operate in primary function.
ACTRA = 0666h
Pin 1,3,5 are active high . Pin 2,4,6 are active low
COMCONA = CA00h
Enabling Compare operation and all remaining bits remain same as configured as above.
DBTCON = 0FF4h
Enabling (EDBT1, EDBT2, EDBT3). Dead band prescaler = x/32. Dead band time period = 15
Program:
.def _c_int0
.include f2407.h
.text
_c_int0
NOP
LDP #DP_PF1
SPLK #0005H,SCSR1
LDP #DP_PF2
SPLK #0FFFFH,MCRA
LDP #0E8H
SPLK #0000H,T1CNT
SPLK #004A,GPTCONA
SPLK #1387H,T1PR
SPLK #0FF4h,DBTCONA
SPLK #,09C4H,CMPR1
SPLK #,09C4H,CMPR2
SPLK #,09C4H,CMPR3
SPLK #0666H,ACTRA
SPLK #0CA00H,COMCONA
SPLK #1046,T1CON
loop
B loop
To check the square wave output on the oscilloscope, the following connections should be made:
Compare Unit 1 has two outputs namely PWM1 and PWM2.
If COMPARE unit 1 is used we check the output at pins 9 and 19 (ground) for PWM1 signal and
for another signal namely PWM2 pins 10 and 20(ground) are to be connected to the C.R.O.
Compare Unit 2 has two outputs namely PWM3 and PWM4.
If COMPARE unit 2 is used we check the output at pins 11 and 19 (ground) for PWM3 signal and
for another signal namely PWM4 pins 12 and 20(ground) are to be connected to the C.R.O.
Compare Unit 3 has two outputs namely PWM5 and PWM6.
If COMPARE unit 3 is used we check the output at pins 13 and 19 (ground) for PWM5 signal and
for another signal namely PWM6 pins 14 and 20(ground) are to be connected to the C.R.O.
Waveform:
Without Dead band:
Results:
PWM pulses of 50% duty cycle are generated using full compare unit.
Inferences:
If Timer1 period register T1PR value is set to value 4999 and compare 1, 2, 3 values is set to
2500 and hence PWM pulses of 50% duty cycle will be generated.
Output Waveform