找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

帖子
查看: 3662|回復(fù): 1
打印 上一主題 下一主題
收起左側(cè)

DSP2833x例程GPIO_output_LED

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:266728 發(fā)表于 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復(fù)用為GPIO功能
  70.    GpioCtrlRegs.GPADIR.bit.GPIO0 = 1;  // GPIO0設(shè)置為輸出
  71.    GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 0; // GPIO1 = GPIO1
  72. ……………………

  73. …………限于本文篇幅 余下代碼請從51黑下載附件…………
復(fù)制代碼

所有資料51hei提供下載:
lab1-GPIO_output_LED.rar (412.62 KB, 下載次數(shù): 26)


分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復(fù)

使用道具 舉報

沙發(fā)
ID:267330 發(fā)表于 2018-4-12 16:12 | 只看該作者
學習啊
回復(fù)

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機教程網(wǎng)

快速回復(fù) 返回頂部 返回列表