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

 找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開始

搜索
查看: 3098|回復(fù): 0
打印 上一主題 下一主題
收起左側(cè)

dsp DM642用定時(shí)器點(diǎn)亮LED 源程序

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:410924 發(fā)表于 2018-10-17 09:32 | 只看該作者 |只看大圖 回帖獎(jiǎng)勵(lì) |倒序?yàn)g覽 |閱讀模式
這是dsp  DM642芯片用定時(shí)器點(diǎn)亮LED燈的程序


單片機(jī)源程序如下:
  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. //===========================================================================
復(fù)制代碼

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


評(píng)分

參與人數(shù) 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎(jiǎng)勵(lì)!

查看全部評(píng)分

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

使用道具 舉報(bào)

本版積分規(guī)則

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

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

快速回復(fù) 返回頂部 返回列表
主站蜘蛛池模板: 亚洲一区免费视频 | 一区二区三区视频免费看 | 欧美精品一区二区三区蜜桃视频 | 国产精品美女久久久免费 | 亚洲人久久 | 一级毛片在线看 | 国产99精品 | 日韩精品一 | 成人精品一区二区三区中文字幕 | 午夜精品一区二区三区免费视频 | 97伊人 | 国精日本亚洲欧州国产中文久久 | 成人国产精品视频 | 狠狠撸在线视频 | 精品一区二区三区不卡 | 一区二区久久 | 成人亚洲性情网站www在线观看 | 羞羞视频一区二区 | 男女视频免费 | 欧美性生活一区二区三区 | av手机免费在线观看 | 国精日本亚洲欧州国产中文久久 | 久久99深爱久久99精品 | 日韩中文字幕在线视频 | 亚洲高清在线观看 | 五月天天色| 亚洲最大福利网 | 国产伦一区二区三区四区 | 精品国产一区二区三区久久久久久 | 乳色吐息在线观看 | 91精品一区二区三区久久久久久 | 久久久久久久网 | 91精品国产91久久久久游泳池 | 国产成人精品一区二区三区在线 | 中文字幕一区二区三区在线观看 | 综合成人在线 | 日日操夜夜摸 | 91免费高清视频 | 日韩三| 精品欧美一区二区中文字幕视频 | 美女视频黄的免费 |