cntrldsp lab2 manual ccsv5 april2013

Upload: luis-velasquez-silva

Post on 10-Feb-2018

233 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/22/2019 CntrlDSP Lab2 Manual CCSv5 April2013

    1/14

    Cntrl Using DSP, Lab 2: F28335 & CCSv5 April 2013

    B.C. Chang & M.U. Salman, MEM Dept. Drexel Univ. 1/14

    MEM800-005

    MEM380-006

    Control Applications of DSP

    Lab 2

    Project Creating & GPIO DSP28355 & CCSv5

    B.C. Chang and Mishah U. Salman

    Department of Mechanical Engineering & Mechanics

    Drexel University

    2013

  • 7/22/2019 CntrlDSP Lab2 Manual CCSv5 April2013

    2/14

    Cntrl Using DSP, Lab 2: F28335 & CCSv5 April 2013

    B.C. Chang & M.U. Salman, MEM Dept. Drexel Univ. 2/14

    1. Objective

    The objective of this lab is to get the students more familiar with the CCSv5.2 and to learn another

    fundamental peripheral, GPIO (general-purpose input/output). In this lab, you will learn how to directly

    create new projects from scratch on CCSv5.2 without using the existing projects of previous CCS version

    and migration like you did in Lab 1. You will create two projects from scratch in the CCSv5.2environment: 2s_hello and 2s_createproj_epwm. GPIO pins are used for general-purpose binary

    input/output operations. Most of the computer peripheral signals are multiplexed with GPIO signals. Thisenables the user to use a pin as GPIO if the peripheral signal or function is not used. On reset, GPIO pinsare configured as inputs. The user can individually program each pin for GPIO mode or peripheral signal

    mode. In this lab, you will also migrate two existing CCSv3.3 projects to CCSv5.2:

    2s_gpio_toggle_delay_A and 2s_gpio_toggle_int_B. The two GPIO projects will be employed to generatedigital signals and send them to GPIO6 (P8:#16) and GPIO7 (P8:#21) pins as outputs. In

    2s_gpio_toggle_delay_A, the timing of the toggled output is controlled by a for loop with time delay,

    while in 2s_gpio_toggle_int_B, interrupts are used to control the timing.

    2. Creating a New Simple Project: 2s_hello

    In this section, you will learn how to create a simple CCSv5 project from scratch. After the project

    2s_hello is created, you can debug (including compiling to covert the source code to the machine code),

    load the machine code to the F28335 DSP chip, and run the program. The function of this simple programis just to print a message like Hello World! on the output device of choice.

    1. Select File New CCS Project from the manual. This opens the New CCS Project wizard.

  • 7/22/2019 CntrlDSP Lab2 Manual CCSv5 April2013

    3/14

    Cntrl Using DSP, Lab 2: F28335 & CCSv5 April 2013

    B.C. Chang & M.U. Salman, MEM Dept. Drexel Univ. 3/14

    2. In the Project Name field, type the new project name: 2s_hello.

    3. In the Output type, select Executable.4. Check the small box to choose Use default location to keep the new project files in your

    workspace folder.

    5. Select C2000 in the Family field.6. In the Variant field: select 2833x Delfino and EZDSPF28335.

    7. In the Connection field, select Spectrum Digital DSK-EVM-eZdsp onboard USB Emulator.

    8. The Advanced settings section is minimized by default.9. Expand the Project templates and examples section. Then select Empty Project (with main.c)

    10.Press the Finish button.

    11.You will see the new project 2s_helloappears on the Project Explorer View window, and a newfolder 2s_hellois created in your workspace folder.

    12.Insert the following C code inside the braces of the voidmain(void)program:puts("hellomem800005/mem380006class!");/*writeastringtostdout*/puts("hopeyouenjoythelab!");/*writeastringtostdout*/while(1){

    }

    13.Debug, load, and run the program, and youll see

    hellomem800005/mem380006class!hopeyouenjoythelab!

    appear on the Console View window.

  • 7/22/2019 CntrlDSP Lab2 Manual CCSv5 April2013

    4/14

    Cntrl Using DSP, Lab 2: F28335 & CCSv5 April 2013

    B.C. Chang & M.U. Salman, MEM Dept. Drexel Univ. 4/14

    3. Creating a New Project: 2s_createproj_epwm

    Now you will repeat the similar procedure described in Section 2 to create another project, this project ismore complicated than the one in the previous section. The function of the project, 2s_createproj_epwm,

    will be the same as that in Lab 1 to generate PWM signals. However, this project will be created from

    scratch, step by step in CCSv5.2, unlike the one in Lab1, which was obtained from migrating an oldCCSv3.3 project.

    1. Select File New CCS Project from the manual. This opens the New CCS Project wizard.

    2. In the Project Name field, type the new project name: 2s_createproj_epwm.

    3. In the Output type, select Executable.4. Check the small box to choose Use default location to keep the new project files in your

    workspace folder.5. Select C2000 in the Family field.

    6. In the Variant field: select 2833x Delfino and EZDSPF28335.

    7. In the Connection field, select Spectrum Digital DSK-EVM-eZdsp onboard USB Emulator.8. The Advanced settings section is minimized by default. Nothing needs to be changed. However,

    you still can expand it to see the compiler version (TIv6.1.0).

    9. Expand the Project templates and examples section. Then select Empty Project you will add

    files to the new project in a little while.

  • 7/22/2019 CntrlDSP Lab2 Manual CCSv5 April2013

    5/14

    Cntrl Using DSP, Lab 2: F28335 & CCSv5 April 2013

    B.C. Chang & M.U. Salman, MEM Dept. Drexel Univ. 5/14

    10.Press the Finish button.

    11.You will see the new project 2s_createproj_epwm appears on the Project Explorer View window,and a new folder 2s_createproj_epwm is created in your workspace folder. Note that the target

    configuration file, EZDSPF28335.ccxml, which is automatically generated, and the linker

    command file, 28335_RAM_lnk.cmd, and a header files folder,

    C:/ti/ccsv5/tools/compiler/c2000_6.1.0/include, are already included in the project. Next, youlladd more files and headers to complete the project creation.

    12.Add files to the project: Select Project Add Files, and look in the folder

    C:\tidcs\c28\DSP2833x\v131\CntrlDSP \2s_createproj_epwm_orig and double click2s_createproj_epwm.cto add it to the project.

    13.Repeat step 12 to look in C:\tidcs\c28\DSP2833x\v131\DSP2833x_common\source and select

    DSP2833x_CpuTimers.c, DSP2833x_DefaultIsr.c, DSP2833x_EPwm.c, DSP2833x_PieCtrl.c,

    DSP2833x_PieVect.c, and DSP2833x_SysCtrl.c.14.Also go to C:\tidcs\c28\DSP2833x\v131\DSP2833x_headers\source to add

    DSP2833x_GlobalVariableDefs.cto the project.

    15.Repeat to find the assembly source files: DSP2833x_ADC_cal.asm,DSP2833x_CodeStartBranch.asm, and DSP2833x_usDelay.asm, in

    C:\tidcs\c28\DSP2833x\v131\DSP2833x_common\source and add them to the project.

  • 7/22/2019 CntrlDSP Lab2 Manual CCSv5 April2013

    6/14

    Cntrl Using DSP, Lab 2: F28335 & CCSv5 April 2013

    B.C. Chang & M.U. Salman, MEM Dept. Drexel Univ. 6/14

    16.Repeat to add the Linker Command File DSP2833x_Headers_nonBIOS.cmdto the project from

    C:\tidcs\c28\DSP2833x\v131\DSP2833x_headers\cmd.17.Look at the Project Explorer View window to make sure there are two .cmd file, eight .c files, and

    three .asm files in the project folder 2s_createproj_epwm.

    18.Next, youll add three more header file folders to the project. Select Project Properties

    Include Optionsfrom the manual. In the lower-right pane of the Properties for2s_createproj_epwm window, click the green arrow icon (Add) to pop up the Add directory

    path.

    19.Press the button File System to search for the directory

    C:\ti\xdais_7_21_01_07\packages\ti\xdais then click the OK button .

  • 7/22/2019 CntrlDSP Lab2 Manual CCSv5 April2013

    7/14

    Cntrl Using DSP, Lab 2: F28335 & CCSv5 April 2013

    B.C. Chang & M.U. Salman, MEM Dept. Drexel Univ. 7/14

    20.Repeat Step 19 again to add the following two header file folders to the project:

    C:/tidcs/c28/DSP283x/v131/DSP283x_common/includeC:/tidcs/c28/DSP283x/v131/DSP283x_headers/include

    21.Now the project is ready for debug and compiling. If there is no error and a xxx.out file isgenerated, load the object file to the DSP chip and run the program.

    22.Check if it is functioning as that in the project, 1s_epwm, in Lab 1.

    4. Connections for GPIO

    Connect the eZdsp board to the USB port of the PC

    DO NOT OPEN THE SOCKETon the board to avoid damaging the DSP chip inside.Connect the DAQ box to PC and Build a LabVIEW VI

    Connect the NI USB-6211 (DAQ) box to PC via USB cable and connect AI0, AI1, and AIGND to

    eZdsp Pins P8: #16, #21 and P8: #19, respectively. A simple LabVIEW VI will be needed to observethe GPIO signals.

    NI USB-6211(DAQ) TI F28335 eZdsp

    AI0 P8: #16

    AI1 P8: #21

    AIGND P8: #19

  • 7/22/2019 CntrlDSP Lab2 Manual CCSv5 April2013

    8/14

    Cntrl Using DSP, Lab 2: F28335 & CCSv5 April 2013

    B.C. Chang & M.U. Salman, MEM Dept. Drexel Univ. 8/14

  • 7/22/2019 CntrlDSP Lab2 Manual CCSv5 April2013

    9/14

    Cntrl Using DSP, Lab 2: F28335 & CCSv5 April 2013

    B.C. Chang & M.U. Salman, MEM Dept. Drexel Univ. 9/14

  • 7/22/2019 CntrlDSP Lab2 Manual CCSv5 April2013

    10/14

    Cntrl Using DSP, Lab 2: F28335 & CCSv5 April 2013

    B.C. Chang & M.U. Salman, MEM Dept. Drexel Univ. 10/14

    5. Generation of GPIO Signals with Timing Controlled by a Time Delay

    5A. Migrate the CCSv3.3 Project 2s_gpio_toggle_delay_A to CCSv5.2

    The CCSv3.3 project, 2s_gpio_toggle_delay_A.pjt, together with the associated C program,

    2s_gpio_toggle_delay_A.c and a gel file 2s_gpio_toggle_delay_A.gel can be found in the folder

    2s_gpio_toggle_delay_A_orig, which is inside the directory C:\tidcs\c28\DSP2833x\v131\CntrlDSP.

    You can employ the migration procedure you learned in Lab 1 to migrate the existing CCSv3.3 Project

    2s_gpio_toggle_delay_A to CCSv5.2. You also have an option to follow the procedure in Section 3 todirectly create the new CCSv5.2 project from scratch based on 2s_gpio_toggle_delay_A.c.

    5B. Debug, Build and Run the Newly Migrated Project 2s_gpio_toggle_delay_A

    1. Select the project by clicking the 2s_gpio_toggle_delay_A in the "Project Explorer"view.2. Click on the green bug (debug button) on the tool bar.

    3. The debugging process will do the following:

    (i) Save all open files in the project selected

    (ii) Build the selected project and create an executable file 2s_gpio_toggle_delay_A.out, whichappears in the folder Debug

    (iii) Automatically switched the CCS Debug perspective

    4. The "Debug"view is now visible.

    (i) This view should always be open. Do not close it. If it is accidently closed, you can open it again

    using the "view debug" menu item.

    (ii) It allows you to connect the target device and control it (run, suspend, etc.)

    5. Select "Run Load Load Program" to load the executable file 2s_gpio_toggle_delay_A.out to

    the target device.

    6. Run Resume

    7. Observe the following GPIO signals:

    Observe the waveform of GPIO6 (P8:#16) and GPIO7 (P8:#21) on an oscilloscope or LabVIEWwith DAQ card.

    8. Select View Expresions. Type the names of the registers on the Expressions view as shown at the

    top of the CCS window.Gpi oDat aRegs. GPADAT. bi t . GPI O6Gpi oDat aRegs. GPADAT. bi t . GPI O7i max

    j max

    9. Select Run Suspend. Observe the values of the registers in the following "Expressions"view.

  • 7/22/2019 CntrlDSP Lab2 Manual CCSv5 April2013

    11/14

    Cntrl Using DSP, Lab 2: F28335 & CCSv5 April 2013

    B.C. Chang & M.U. Salman, MEM Dept. Drexel Univ. 11/14

    10. Use Real-Time Mode to Observe Continuous Update of the values in the Expression View:Click on the clock icon at the top of the CCS Debug perspective.

    11. CCS will ask if you would like to change bit 1 of the ST1 status register to 0. This is required toenter real-time mode.

    12. Select "Yes".

    13. In the upper right corner of the Expressions view, click the "Continuous Refresh"button.14. Observe how the values of registers are changing with time.

    15. Observe the waveform of GPIO6 (P8:#16) and GPIO7 (P8:#21) on an oscilloscope or LabVIEW withDAQ card in real-time mode.

    16. Compute the period and the phase relationship of these GPIO signals from the waveforms.

    17. Observe the changing values of GPIO6 and GPIO7 in the Expression View. Use stop watch to

    measure the period of GPIO signals according to changing values shown in the Expression View.18. Can you modify the program to generate a desired period and a desired phase difference between the

    two GPIO signals?

    19. Use the Expression View to change the value of period in real-time and observe if the waveforms ofGPIO6 and GPIO7 will change.

    6. Generation of GPIO Signals with Timing Controlled by Interrupt

    6A. Migrate the CCSv3.3 Project 2s_gpio_toggle_int_B to CCSv5.2

    The CCSv3.3 project, 2s_gpio_toggle_int_B.pjt, together with the associated C program,

    2s_gpio_toggle_int_B.c and a gel file 2s_gpio_toggle_int_B.gel can be found in the folder

    2s_gpio_toggle_int_B_orig, which is inside the directory C:\tidcs\c28\DSP2833x\v131\CntrlDSP.

    You can employ the migration procedure you learned in Lab 1 to migrate the existing CCSv3.3 Project2s_gpio_toggle_int_B to CCSv5.2. You also have an option to follow the procedure in Section 3 to

    directly create the new CCSv5.2 project from scratch based on 2s_gpio_toggle_int_B.c.

    6B. Debug, Build and Run the Project

    1. Select the project by clicking the 2s_gpio_toggle_int_B in the "Project Explorer"view.2. Click on the green bug (debug button) on the tool bar.

    3. The debugging process will do the following:

    (i) Save all open files in the project selected

  • 7/22/2019 CntrlDSP Lab2 Manual CCSv5 April2013

    12/14

    Cntrl Using DSP, Lab 2: F28335 & CCSv5 April 2013

    B.C. Chang & M.U. Salman, MEM Dept. Drexel Univ. 12/14

    (ii) Build the selected project and create an executable file 2s_gpio_toggle_int_B.out, which appears

    in the folder Debug(iii) Automatically switched the CCS Debug perspective.

    4. The "Debug"view is now visible.

    (i) This view should always be open. Do not close it. If it is accidently closed, you can open it again

    using the "view debug" menu item.

    (ii) It allows you to connect the target device and control it (run, suspend, etc.)

    5. Select "Run Load Load Program" to load the executable file 2s_gpio_toggle_int_B.out to thetarget device.

    6. Run Resume

    7. Observe the following GPIO signals:Observe the waveform of GPIO6 (P8:#16) and GPIO7 (P8:#21) on an oscilloscope or LabVIEWwith DAQ card.

    8. Select View Expresions. Type the names of the registers on the Expressions view as shown at the

    top of the CCS window.Gpi oDat aRegs. GPADAT. bi t . GPI O6Gpi oDat aRegs. GPADAT. bi t . GPI O7CpuTi mer0. I nterr upt CountPer i od

    9. Select Run Suspend. Observe the values of the registers in the following "Expressions"view.10. Use Real-Time Mode to Observe Continuous Update of the values in the Expression View:

    Click on the clock icon at the top of the CCS Debug perspective.

    11. CCS will ask if you would like to change bit 1 of the ST1 status register to 0. This is required to

    enter real-time mode.12. Select "Yes".

    13. In the upper right corner of the Expressions view, click the "Continuous Refresh"button.

    14. Observe how the values of registers are changing with time.15. Observe the waveform of GPIO6 (P8:#16) and GPIO7 (P8:#21) on an oscilloscope or LabVIEW with

    DAQ card in real-time mode.

    16. Compute the period and the phase relationship of these GPIO signals from the waveforms.

    17. Observe the changing values of GPIO6 and GPIO7 in the Expression View. Use stop watch tomeasure the period of GPIO signals according to changing values shown in the Expression View.

    18. Can you modify the program to generate a desired period and a desired phase difference between the

    two GPIO signals?

    7. Discussions

    What approach was used in the 2s_gpio_toggle_delay_A program to achieve timing control? Doesthis approach provide precise timing control? Does this approach use CPU time efficiently? Explain

    the reasoning behind your answers in detail.

    What approach was used in the 2s_ gpio_toggle_int_B program to achieve timing control? Does thisapproach provide precise timing control? Does this approach use CPU time efficiently? Explain the

    reasoning behind your answers in detail.

    Explain what interruptmeans in the 2s_ gpio_toggle_int_B program.

  • 7/22/2019 CntrlDSP Lab2 Manual CCSv5 April2013

    13/14

    Cntrl Using DSP, Lab 2: F28335 & CCSv5 April 2013

    B.C. Chang & M.U. Salman, MEM Dept. Drexel Univ. 13/14

    Appendix A:

    / / =============================================================================/ // / FI LE: 2s_gpi o_t oggl e_del ay_A. c/ // // / Thi s pr ogr ami s modi f i ed f r omExampl e_2833xGpi oToggl e. c,/ /

    / / by B. C. Chang, Chi r ag J agadi sh, Mi shah U. Sal man, Dr exel Uni v./ / on March 28, 2010/ // / Thi s pr ogr am r equi r es t he/ / DSP2833x/ DSP2823x C/ C++ Header Fi l es V1. 31, r el eased by TI on August 4, 2009./ // / ==========================================================================/ // / Toggl e GPI O PORT pi ns,/ / Gpi oDataRegs. GPADAT. bi t . GPI O6,/ / Gpi oDataRegs. GPADAT. bi t . GPI O7,/ / usi ng a f or l oop t o cont r ol t he t i mi ng/ // // / Use Expr essi on Vi ew t o observe

    / // / Gpi oDataRegs. GPADAT. bi t . GPI O6/ / Gpi oDataRegs. GPADAT. bi t . GPI O7/ / i max/ / j max/ // / The pi ns of t hese GPI O port s can be observed usi ng/ / Osci l l oscope./ // / ==========================================================================

    Appendix B:

    / / =============================================================================/ // / FI LE: 2s_gpi o_t oggl e_i nt _B. c/ // // / Thi s pr ogr am i s modi f i ed f r omExampl e_2833xCpuTi mer . c,/ // / by B. C. Chang, Mi shah U. Sal man, Dr exel Uni v./ / on March 28, 2010/ // / Thi s pr ogr am r equi r es t he/ / DSP2833x/ DSP2823x C/ C++ Header Fi l es V1. 31, r el eased by TI on August 4, 2009./ /

    / / ==========================================================================/ // / Toggl e GPI O PORT pi ns,/ / Gpi oDataRegs. GPADAT. bi t . GPI O6,/ / Gpi oDataRegs. GPADAT. bi t . GPI O7,/ / usi ng i nt er r upt t o cont r ol t he t i mi ng/ // / Use Expr essi on Vi ew t o obser ve/ / CpuTi mer 0. I nt er r upt Count/ / Gpi oDataRegs. GPADAT. bi t . GPI O6/ / Gpi oDataRegs. GPFDAT. bi t . GPI O7

  • 7/22/2019 CntrlDSP Lab2 Manual CCSv5 April2013

    14/14

    Cntrl Using DSP, Lab 2: F28335 & CCSv5 April 2013

    B.C. Chang & M.U. Salman, MEM Dept. Drexel Univ. 14/14

    / / per i od/ // / The pi ns of t hese GPI O por t s can be obser ved usi ng/ / Osci l l oscope./ // / ==========================================================================