DspBios V542笔记(二) CSL LED测试程序2

2630阅读 0评论2013-12-25 lyq2325272
分类:C/C++

软件平台:CCS V5.4.0

硬件平台:SEED-DEC5502

说明:DSP/BIOS、CSL以及创建工程见“DspBios V542_CSL LED测试程序1”,该工程还是基于DspBios V5.4.2.01.09例程Hello

 

步骤:

A、              双击打开hello.tcf,在CLK上面右击,选择Insert CLK,输入名称,例程中使用clk1,见附图1

B、              clk1上面右击,选择Properties,将Function,修改_ledtaskFxn,见附图2

C、              CLK上面右击,选择Properties,将Microsecond/Int修改为1000000(表示1s中断一次),见附图3

D、              关闭tcf配置窗口,并再修改hello.c文件为附件中内容,并在工程的Properties中将CSL库文件的路径添加进去,见附图4

E、               下载运行

注意:完成步骤E后运行会提示#35 #error NO CHIP DEFINED,解决方法为:选择工程,右击选择Properties,然后Build->C5500 Compiler->Advanced Options->Predefined Symbols中添加"CHIP_5502"

附件:


点击(此处)折叠或打开

  1. #include <std.h>
  2. #include <stdio.h>
  3. #include <log.h>

  4. #include "hellocfg.h"
  5. #include <csl.h>
  6. #include <csl_pll.h>
  7. #include <csl_chip.h>
  8. #include <csl_irq.h>
  9. #include <csl_gpt.h>

  10. void delay_vt(Int i);
  11. /* Define the power-off time length of LED */
  12. Uint16 LEDMARK = 0;        // 设置指示灯的开关标志

  13. /* 通过定义宏来控制两个外围存储器映射的寄存器,从而实现对GPIO口的控制 */
  14. #define GPIODIR     (*(volatile ioport Uint16*)(0x3400))
  15. #define GPIODATA     (*(volatile ioport Uint16*)(0x3401))
  16. /*
  17.  * ======== main ========
  18.  */
  19. Void main()
  20. {
  21.     LOG_printf(&trace, "hello world!");

  22.     /* Config GPIO7 in order to ignite led D5*/
  23.     GPIODIR = 0x80;    // config the GPIO7 as output pin
  24.     /* fall into DSP/BIOS idle loop */
  25.     return;
  26. }

  27. void clk1Fxn()
  28. {
  29.     if(LEDMARK==0)
  30.              {
  31.                  GPIODATA = 0x00;                /* 关闭指示灯D5 */
  32.                  LEDMARK = 1;
  33.              }
  34.              else
  35.              {
  36.                  GPIODATA = 0x80;                /* 打开指示灯D5 */
  37.                  LEDMARK = 0;
  38.              }
  39. }

附图


附图1

附图2

附图3

附图4

上一篇:DspBios V542笔记(一) CSL LED测试程序1
下一篇:DspBios V542笔记(三) CSL LED测试程序3