Site Index
   Support Home
   C6000 Home
   DaVinci EVM
   EVMDM6437
   EVM6424
   EVMDM642
   XEVM642
   DSKTCI6482
   EVMTCI6482
   DSK6455
   EVM6455
   EVM6418
   DSK6713
   DSK6416
   Ordering Info.
Google

C6000 Site
Support Site
Main Site

EVM6418 LEDPRD Example

The ledprd example is a separate example that is performs the exact same function as the led example using the DSP/BIOS scheduler to run a periodic thread every 200ms instead of using the software delay loop. Follow these instructions to load and run the ledprd example.

  1. Close any projects you were working with previously by selecting Poject -> Close. You should also close any open files you have open in your workspace such to avoid confusion. Click on the X in the upper right hand corner of their windows to close them.

  2. Open the ledprd.pjt Code Composer project using Project -> Open and selecting ledprd.pjt. It is in the directory

       c:\CCStudio\boards\evm6418\examples\ledprd.
  3. Load the ledprd.out executable file. Select File -> Load Program. It will open a file browser dialog. Select the led.out file in the ledprd\Debug directory in the file browser and hit "Open" to load the executable file.

  4. Select the Debug -> Run option under the Debug menu. LED #0 will start blinking slowly.

  5. Move DIP switch #3 up and down, you will see LED #3 change with it.

  6. When you are satisfied that the program is indeed running correctly, stop the program by selecting Debug -> Halt.

To examine the program code, expand the Projects tree at the left of the workspace, then expand the ledprd.pjt and Source subitems. Double click on ledprd.c to see its contents.

You can see that only initialization is done in the main() function. When main() is finished, it returns back to the DSP/BIOS scheduler which takes over responsibility of finding more work to be done. In this case, blinkLED0() is defined as a periodic thread that is scheduled to run every 200ms. Advantages of this method are:

  • No time is wasted spinning in loops. Work is done when it is scheduled or a resource that work depends on becomes available.

  • Independent work can be separated into logical threads that are managed by DSP/BIOS, simplifying your code.

To view the scheduler settings:

  1. Expand the "DSP/BIOS Config" entry in the project view. Double-click on the ledprd.cdb file to open it with the BIOS configuration tool.

  2. Expand the "Scheduling" entry in the configuration tool view. This exposes groups of configurable parameters related to scheduling.

  3. Expand the PRD - Periodic Function Manager section to see a list of currently scheduled periodic threads. There will be one scheduled entry called PRD_blinkLED0. Right click on it and select Properties.

You should see something like this:


Click Image to Enlarge

The function is the name of the thread containing the code to be run, in this case _blinkLED0. The leading underscore is required because blinkLED0() is a C function. Functions written in assembly do not need the underscore. The period is the period blinkLED0() should be called with in ticks. Each tick is equivalent to 1ms, so it will be run every 200ms. Hit cancel to exit out of the properties view.

Adding a Second Thread
A second thread is included in the ledprd.c source file called blinkLED1(). It simply toggles LED #1. This section shows how to add it as a second thread that blinks LED #1 at a different rate than LED #0.

  1. Expand the Scheduling entry in the DSP/BIOS Configuration Tool and right clock on PRD - Periodic Function Manager. Select the Insert PRD menu option. It will create a new scheduling entry called PRD0.

  2. Right click on PRD0 and select Properties. Change the period field to 100 and the function field to _blinkLED1. It will look like this when you are done:

  3. Hit OK to confirm the settings. Single click on PRD0 and the Configuration Tool will let you change the name. Change it to PRD_blinkLED1

  4. Save the new DSP/BIOS configuration file. Select File -> Save.

  5. Re-compile your program. Select Project -> Build.

  6. Load the new led.out executable file. Select File -> Load Program then select ledprd.out in the ledprd\Debug directory in the file browser.

  7. Select the Debug -> Run. LED #0 will be blinking as before but LED #1 will also be blinking at twice the rate.

  8. When you are satisfied that both tasks are running, stop the program by selecting Debug -> Halt.

©Copyright 2002-2012 Spectrum Digital, Inc. All Rights Reserved.