久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 3075|回復: 0
打印 上一主題 下一主題
收起左側

dsp DM642用定時器點亮LED 源程序

[復制鏈接]
跳轉到指定樓層
樓主
這是dsp  DM642芯片用定時器點亮LED燈的程序


單片機源程序如下:
  1. // TI File $Revision: /main/1 $
  2. // Checkin $Date: September 21, 2007   08:58:44 $
  3. //###########################################################################
  4. //
  5. // FILE:    Example_2833xLedBlink.c
  6. //
  7. // TITLE:   DSP2833x eZdsp LED Blink Getting Started Program.
  8. //
  9. // ASSUMPTIONS:
  10. //
  11. //    This program requires the DSP2833x header files.
  12. //
  13. //
  14. //    As supplied, this project is configured for "boot to SARAM"
  15. //    operation.  The 2833x Boot Mode table is shown below.
  16. //    For information on configuring the boot mode of an eZdsp,
  17. //    please refer to the documentation included with the eZdsp,
  18. //
  19. //       $Boot_Table:
  20. //
  21. //         GPIO87   GPIO86     GPIO85   GPIO84
  22. //          XA15     XA14       XA13     XA12
  23. //           PU       PU         PU       PU
  24. //        ==========================================
  25. //            1        1          1        1    Jump to Flash
  26. //            1        1          1        0    SCI-A boot
  27. //            1        1          0        1    SPI-A boot
  28. //            1        1          0        0    I2C-A boot
  29. //            1        0          1        1    eCAN-A boot
  30. //            1        0          1        0    McBSP-A boot
  31. //            1        0          0        1    Jump to XINTF x16
  32. //            1        0          0        0    Jump to XINTF x32
  33. //            0        1          1        1    Jump to OTP
  34. //            0        1          1        0    Parallel GPIO I/O boot
  35. //            0        1          0        1    Parallel XINTF boot
  36. //            0        1          0        0    Jump to SARAM            <- "boot to SARAM"
  37. //            0        0          1        1    Branch to check boot mode
  38. //            0        0          1        0    Boot to flash, bypass ADC cal
  39. //            0        0          0        1    Boot to SARAM, bypass ADC cal
  40. //            0        0          0        0    Boot to SCI-A, bypass ADC cal
  41. //                                              Boot_Table_End$
  42. //
  43. // DESCRIPTION:
  44. //
  45. //    This example configures CPU Timer0 for a 500 msec period, and toggles the GPIO32
  46. //    LED on the 2833x eZdsp once per interrupt. For testing purposes, this example
  47. //    also increments a counter each time the timer asserts an interrupt.
  48. //
  49. //       Watch Variables:
  50. //          CpuTimer0.InterruptCount
  51. //
  52. //       Monitor the GPIO32 LED blink on (for 500 msec) and off (for 500 msec) on the 2833x eZdsp.
  53. //
  54. //###########################################################################
  55. // $TI Release: DSP2833x Header Files V1.10 $
  56. // $Release Date: February 15, 2008 $
  57. //###########################################################################


  58. #include "DSP2833x_Device.h"     // DSP2833x Headerfile Include File
  59. #include "DSP2833x_Examples.h"   // DSP2833x Examples Include File

  60. // Prototype statements for functions found within this file.
  61. interrupt void cpu_timer0_isr(void);
  62. unsigned int Count,Flag;

  63. void main(void)
  64. {

  65. // Step 1. Initialize System Control:
  66. // PLL, WatchDog, enable Peripheral Clocks
  67. // This example function is found in the DSP2833x_SysCtrl.c file.
  68.    InitSysCtrl();

  69. // Step 2. Initalize GPIO:
  70. // This example function is found in the DSP2833x_Gpio.c file and
  71. // illustrates how to set the GPIO to it's default state.
  72. // InitGpio();  // Skipped for this example


  73. // Step 3. Clear all interrupts and initialize PIE vector table:
  74. // Disable CPU interrupts
  75.    DINT;

  76. // Initialize the PIE control registers to their default state.
  77. // The default state is all PIE interrupts disabled and flags
  78. // are cleared.
  79. // This function is found in the DSP2833x_PieCtrl.c file.
  80.    InitPieCtrl();

  81. // Disable CPU interrupts and clear all CPU interrupt flags:
  82.    IER = 0x0000;
  83.    IFR = 0x0000;

  84. // Initialize the PIE vector table with pointers to the shell Interrupt
  85. // Service Routines (ISR).
  86. // This will populate the entire table, even if the interrupt
  87. // is not used in this example.  This is useful for debug purposes.
  88. // The shell ISR routines are found in DSP2833x_DefaultIsr.c.
  89. // This function is found in DSP2833x_PieVect.c.
  90.    InitPieVectTable();

  91. // Interrupts that are used in this example are re-mapped to
  92. // ISR functions found within this file.
  93.    EALLOW;  // This is needed to write to EALLOW protected registers
  94.    PieVectTable.TINT0 = &cpu_timer0_isr;

  95.    Count = 0;                                        //初始化變量
  96.    Flag=0;

  97.    EDIS;    // This is needed to disable write to EALLOW protected registers

  98. // Step 4. Initialize the Device Peripheral. This function can be
  99. //         found in DSP2833x_CpuTimers.c
  100.    InitCpuTimers();   // For this example, only initialize the Cpu Timers
  101. #if (CPU_FRQ_150MHZ)
  102. // Configure CPU-Timer 0 to interrupt every 500 milliseconds:
  103. // 150MHz CPU Freq, 50 millisecond Period (in uSeconds)
  104.    ConfigCpuTimer(&CpuTimer0, 150, 500000);
  105. #endif
  106. #if (CPU_FRQ_100MHZ)
  107. // Configure CPU-Timer 0 to interrupt every 500 milliseconds:
  108. // 100MHz CPU Freq, 50 millisecond Period (in uSeconds)
  109.    ConfigCpuTimer(&CpuTimer0, 100, 500000);
  110. #endif

  111. // To ensure precise timing, use write-only instructions to write to the entire register. Therefore, if any
  112. // of the configuration bits are changed in ConfigCpuTimer and InitCpuTimers (in DSP2833x_CpuTimers.h), the
  113. // below settings must also be updated.

  114.    CpuTimer0Regs.TCR.all = 0x4001; // Use write-only instruction to set TSS bit = 0

  115. // Step 5. User specific code, enable interrupts:

  116. // Configure GPIO0-3 as a GPIO output pin
  117.    EALLOW;
  118.    GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 0;
  119.    GpioCtrlRegs.GPADIR.bit.GPIO0 = 1;
  120.    GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 0;
  121.    GpioCtrlRegs.GPADIR.bit.GPIO1 = 1;
  122.    GpioCtrlRegs.GPAMUX1.bit.GPIO2 = 0;
  123.    GpioCtrlRegs.GPADIR.bit.GPIO2 = 1;
  124.    GpioCtrlRegs.GPAMUX1.bit.GPIO3 = 0;
  125.    GpioCtrlRegs.GPADIR.bit.GPIO3 = 1;
  126.    EDIS;

  127. // Enable CPU INT1 which is connected to CPU-Timer 0:
  128.    IER |= M_INT1;

  129. // Enable TINT0 in the PIE: Group 1 interrupt 7
  130.    PieCtrlRegs.PIEIER1.bit.INTx7 = 1;

  131. // Enable global Interrupts and higher priority real-time debug events:
  132.    EINT;   // Enable Global interrupt INTM
  133.    ERTM;   // Enable Global realtime interrupt DBGM

  134. // Step 6. IDLE loop. Just sit and loop forever (optional):
  135.    for(;;);
  136. }


  137. interrupt void cpu_timer0_isr(void)
  138. {
  139.    CpuTimer0.InterruptCount++;
  140.    GpioDataRegs.GPATOGGLE.bit.GPIO0 = 1; // Toggle GPIO0 once per 500 milliseconds
  141.    GpioDataRegs.GPATOGGLE.bit.GPIO1 = 1; // Toggle GPIO1 once per 500 milliseconds
  142.    GpioDataRegs.GPATOGGLE.bit.GPIO2 = 1; // Toggle GPIO2 once per 500 milliseconds
  143.    GpioDataRegs.GPATOGGLE.bit.GPIO3 = 1; // Toggle GPIO3 once per 500 milliseconds
  144.    // Acknowledge this interrupt to receive more interrupts from group 1
  145.    PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
  146. }


  147. //===========================================================================
  148. // No more.
  149. //===========================================================================
復制代碼

所有資料51hei提供下載:
Ex01_ZQ28335_Timer0_LED.rar (387.17 KB, 下載次數: 4)


評分

參與人數 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎勵!

查看全部評分

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

使用道具 舉報

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

本版積分規則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 国产精久久久久久久 | 色精品 | 亚洲国产成人精品女人久久久 | 91精品www | 天天插天天操 | 精品婷婷 | 一级欧美一级日韩片免费观看 | 国产一区二区三区视频 | 亚洲综合一区二区三区 | 国产亚洲成av人片在线观看桃 | 中文视频在线 | 午夜精品久久久久久久久久久久 | 蜜桃毛片| 日韩成人在线观看 | 欧美性久久 | 国产精品久久久久久久 | 亚洲天堂av网 | 免费观看一级特黄欧美大片 | 日日操操 | av在线播放网 | 日本不卡一区 | 日韩av.com| 一区二区三区精品视频 | 午夜在线影院 | 亚洲一区二区三区在线视频 | 亚洲色图综合 | 国产一区二区欧美 | a级毛片毛片免费观看久潮喷 | 中文字幕 在线观看 | 成人免费视频在线观看 | 高清久久久 | 亚洲精品久久久一区二区三区 | 国产真实乱对白精彩久久小说 | 国产精品区二区三区日本 | 欧美精品乱码久久久久久按摩 | 激情五月婷婷综合 | 国产美女精品视频 | 亚洲一二三视频 | 羞羞视频在线观看 | 久久精品久久久久久 | 久久一区视频 |