找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 3026|回复: 1
打印 上一主题 下一主题
收起左侧

DSP2833x例程GPIO_output_LED

[复制链接]
跳转到指定楼层
楼主
ID:266728 发表于 2017-12-25 20:09 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
源程序如下:
  1. #include "DSP2833x_Device.h"     // DSP2833x Headerfile Include File
  2. #include "DSP2833x_Examples.h"   // DSP2833x Examples Include File

  3. #define          LED1        GpioDataRegs.GPADAT.bit.GPIO0
  4. #define          LED2        GpioDataRegs.GPADAT.bit.GPIO1
  5. #define          LED3        GpioDataRegs.GPADAT.bit.GPIO2
  6. #define          LED4        GpioDataRegs.GPADAT.bit.GPIO3
  7. #define          LED5        GpioDataRegs.GPADAT.bit.GPIO4

  8. void configtestled(void);

  9. void main(void)
  10. {
  11. // Step 1. Initialize System Control:
  12. // PLL, WatchDog, enable Peripheral Clocks
  13. // This example function is found in the DSP2833x_SysCtrl.c file.
  14.    InitSysCtrl();

  15. // Step 2. Initalize GPIO:
  16. // This example function is found in the DSP2833x_Gpio.c file and
  17. // illustrates how to set the GPIO to it's default state.
  18. // InitGpio();  // Skipped for this example
  19.    InitXintf16Gpio();        //zq

  20. // Step 3. Clear all interrupts and initialize PIE vector table:
  21. // Disable CPU interrupts
  22.    DINT;

  23. // Initialize the PIE control registers to their default state.
  24. // The default state is all PIE interrupts disabled and flags
  25. // are cleared.
  26. // This function is found in the DSP2833x_PieCtrl.c file.
  27.    InitPieCtrl();

  28. // Disable CPU interrupts and clear all CPU interrupt flags:
  29.    IER = 0x0000;
  30.    IFR = 0x0000;

  31. // Initialize the PIE vector table with pointers to the shell Interrupt
  32. // Service Routines (ISR).
  33. // This will populate the entire table, even if the interrupt
  34. // is not used in this example.  This is useful for debug purposes.
  35. // The shell ISR routines are found in DSP2833x_DefaultIsr.c.
  36. // This function is found in DSP2833x_PieVect.c.
  37.    InitPieVectTable();
  38.    configtestled();

  39.    //   LED1=1;
  40.   // DELAY_US(10);
  41.   //    LED2=1;
  42.   // DELAY_US(10);
  43.       LED1=0;
  44.    DELAY_US(10);
  45.       LED2=0;
  46.    DELAY_US(10);
  47.       LED3=0;
  48.    DELAY_US(10);
  49.       LED4=0;
  50.    DELAY_US(10);  
  51.       LED5=0;
  52.    DELAY_US(10);  

  53. while(1){
  54.       LED1=~LED1;
  55.    DELAY_US(100000);
  56.       LED2=~LED2;
  57.    DELAY_US(100000);
  58.       LED3=~LED3;
  59.    DELAY_US(100000);
  60.       LED4=~LED4;
  61.    DELAY_US(100000);
  62.       LED5=~LED5;
  63.    DELAY_US(100000);
  64.      }

  65. }




  66. void configtestled(void)
  67. {
  68.    EALLOW;
  69.    GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 0; // GPIO0复用为GPIO功能
  70.    GpioCtrlRegs.GPADIR.bit.GPIO0 = 1;  // GPIO0设置为输出
  71.    GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 0; // GPIO1 = GPIO1
  72. ……………………

  73. …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码

所有资料51hei提供下载:
lab1-GPIO_output_LED.rar (412.62 KB, 下载次数: 26)


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:267330 发表于 2018-4-12 16:12 | 只看该作者
学习啊
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表