设为首页 收藏本站
论坛账号至少一个月登录一次,否则会被自动冻结!论坛全站广告位出租2160元一年,有需要联系QQ:2322712906。国内首家由论坛网友持股的IC技术论坛,IC人的乌托邦!
搜索
专业IC版图外包服务 手机号:13816911948 微信同号
广告位:SY02 广告业务联系QQ:2322712906
青软晶尊微电子---IC版图外包服务(13964228177)+教育培训(13573273505)
苏州拓光微电子---芯片设计整体解决方案供应商
美国芯片设计公司提供定制模拟IP ,定制模拟IC,联系人郑生 18988685390(微信同)
查看: 65|回复: 0

[资料] dsp DM642用定时器点亮LED 源程序

[复制链接]
发表于 2019-2-9 21:22:14 | 显示全部楼层 |阅读模式
这是dsp  DM642芯片用定时器点亮LED灯的程序
212057jp8rkcq77kgkw5kg.png

源程序:
  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. //===========================================================================
复制代码

Ex01_ZQ28335_Timer0_LED.rar

387.17 KB, 下载次数: 0, 下载积分: IC币 -2 元

*滑块验证:
您需要登录后才可以回帖 登录 | 入住IC小镇

本版积分规则

关闭

站长推荐上一条 /1 下一条

QQ|Archiver|手机版|IC设计小镇 ( 苏ICP备10008526号  

GMT+8, 2019-2-19 08:36 , Processed in 0.055505 second(s), 10 queries , File On.

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

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