標(biāo)題: DSP2833x例程GPIO_output_LED [打印本頁(yè)]

作者: lxiiii    時(shí)間: 2017-12-25 20:09
標(biāo)題: DSP2833x例程GPIO_output_LED
源程序如下:
  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. …………限于本文篇幅 余下代碼請(qǐng)從51黑下載附件…………
復(fù)制代碼

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



作者: jiangkeqin_sy    時(shí)間: 2018-4-12 16:12
學(xué)習(xí)啊




歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1