找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 3305|回复: 1
打印 上一主题 下一主题
收起左侧

TMS320F28335 dsp的常用功能使用例程 库文件源码下载

[复制链接]
跳转到指定楼层
楼主
TMS320F28335的例程,适合新手学习


所有资料51hei提供下载:
ZQ28335_examples.7z (2 MB, 下载次数: 86)

单片机源程序如下:
  1. //###########################################################################
  2. //
  3. // FILE:   Example_2833xAdcToDMA.c
  4. //
  5. // TITLE:  DSP2833x ADC To DMA
  6. // ASSUMPTIONS:
  7. //
  8. //    This program requires the DSP2833x header files.
  9. //
  10. //    Make sure the CPU clock speed is properly defined in
  11. //    DSP2833x_Examples.h before compiling this example.
  12. //
  13. //    Connect the signals to be converted to channel A0, A1, A2, and A3.
  14. //
  15. //    As supplied, this project is configured for "boot to SARAM"
  16. //    operation.  The 2833x Boot Mode table is shown below.
  17. //    For information on configuring the boot mode of an eZdsp,
  18. //    please refer to the documentation included with the eZdsp,
  19. //
  20. //       $Boot_Table:
  21. //
  22. //         GPIO87   GPIO86     GPIO85   GPIO84
  23. //          XA15     XA14       XA13     XA12
  24. //           PU       PU         PU       PU
  25. //        ==========================================
  26. //            1        1          1        1    Jump to Flash
  27. //            1        1          1        0    SCI-A boot
  28. //            1        1          0        1    SPI-A boot
  29. //            1        1          0        0    I2C-A boot
  30. //            1        0          1        1    eCAN-A boot
  31. //            1        0          1        0    McBSP-A boot
  32. //            1        0          0        1    Jump to XINTF x16
  33. //            1        0          0        0    Jump to XINTF x32
  34. //            0        1          1        1    Jump to OTP
  35. //            0        1          1        0    Parallel GPIO I/O boot
  36. //            0        1          0        1    Parallel XINTF boot
  37. //            0        1          0        0    Jump to SARAM            <- "boot to SARAM"
  38. //            0        0          1        1    Branch to check boot mode
  39. //            0        0          1        0    Boot to flash, bypass ADC cal
  40. //            0        0          0        1    Boot to SARAM, bypass ADC cal
  41. //            0        0          0        0    Boot to SCI-A, bypass ADC cal
  42. //                                              Boot_Table_End$
  43. //
  44. //
  45. // DESCRIPTION:
  46. //
  47. // ADC is setup to convert 4 channels for each SOC received, with  total of 10 SOCs.
  48. // Each SOC initiates 4 conversions.
  49. // DMA is set up to capture the data on each SEQ1_INT.  DMA will re-sort   
  50. // the data by channel sequentially, i.e. all channel0 data will be together
  51. // all channel1 data will be together.
  52. //
  53. // Code should stop in local_DINTCH1_ISR when complete
  54. //
  55. // Watch Variables:
  56. //      DMABuf1
  57. //
  58. //###########################################################################
  59. //
  60. // Original source by: M.P.
  61. //
  62. // $TI Release: DSP2833x Header Files V1.01 $
  63. // $Release Date: September 26, 2007 $
  64. //###########################################################################

  65. #include "DSP2833x_Device.h"     // DSP2833x Headerfile Include File
  66. #include "DSP2833x_Examples.h"   // DSP2833x Examples Include File

  67. // ADC start parameters
  68. #if (CPU_FRQ_150MHZ)     // Default - 150 MHz SYSCLKOUT
  69.   #define ADC_MODCLK 0x3 // HSPCLK = SYSCLKOUT/2*ADC_MODCLK2 = 150/(2*3)   = 25.0 MHz
  70. #endif
  71. #if (CPU_FRQ_100MHZ)
  72.   #define ADC_MODCLK 0x2 // HSPCLK = SYSCLKOUT/2*ADC_MODCLK2 = 100/(2*2)   = 25.0 MHz
  73. #endif
  74. #define ADC_CKPS   0x1   // ADC module clock = HSPCLK/2*ADC_CKPS   = 25.0MHz/(1*2) = 12.5MHz
  75. #define ADC_SHCLK  0xf   // S/H width in ADC module periods                        = 16 ADC clocks
  76. #define AVG        1000  // Average sample limit
  77. #define ZOFFSET    0x00  // Average Zero offset
  78. #define BUF_SIZE   160    // Sample buffer size

  79. // Global variable for this example
  80. Uint16 j = 0,ADC_END = 0; // ADC finish flag

  81. #pragma DATA_SECTION(ADC_Result,"DMARAML4");
  82. volatile float ADC_Result[160];

  83. #pragma DATA_SECTION(DMABuf1,"DMARAML4");
  84. volatile Uint16 DMABuf1[160];

  85. volatile Uint16 *DMADest;
  86. volatile Uint16 *DMASource;
  87. interrupt void local_DINTCH1_ISR(void);

  88. void main(void)
  89. {
  90.    Uint16 i;

  91. // Step 1. Initialize System Control:
  92. // PLL, WatchDog, enable Peripheral Clocks
  93. // This example function is found in the DSP2833x_SysCtrl.c file.
  94.    InitSysCtrl();

  95. // Specific clock setting for this example:
  96.    EALLOW;
  97.    SysCtrlRegs.HISPCP.all = ADC_MODCLK;        // HSPCLK = SYSCLKOUT/ADC_MODCLK
  98.    EDIS;

  99. // Step 2. Initialize GPIO:
  100. // This example function is found in the DSP2833x_Gpio.c file and
  101. // illustrates how to set the GPIO to it's default state.
  102. // InitGpio();  // Skipped for this example

  103. // Step 3. Clear all interrupts and initialize PIE vector table:
  104. // Disable CPU interrupts
  105.    DINT;

  106. // Initialize the PIE control registers to their default state.
  107. // The default state is all PIE interrupts disabled and flags
  108. // are cleared.
  109. // This function is found in the DSP2833x_PieCtrl.c file.
  110.    InitPieCtrl();

  111. // Disable CPU interrupts and clear all CPU interrupt flags:
  112.    IER = 0x0000;
  113.    IFR = 0x0000;

  114. // Initialize the PIE vector table with pointers to the shell Interrupt
  115. // Service Routines (ISR).
  116. // This will populate the entire table, even if the interrupt
  117. // is not used in this example.  This is useful for debug purposes.
  118. // The shell ISR routines are found in DSP2833x_DefaultIsr.c.
  119. // This function is found in DSP2833x_PieVect.c.
  120.    InitPieVectTable();

  121. // Interrupts that are used in this example are re-mapped to
  122. // ISR functions found within this file.
  123.    EALLOW;        // Allow access to EALLOW protected registers
  124.    PieVectTable.DINTCH1= &local_DINTCH1_ISR;
  125.    EDIS;   // Disable access to EALLOW protected registers
  126.       
  127.    IER = M_INT7 ;                                     //Enable INT7 (7.1 DMA Ch1)
  128.    EnableInterrupts();
  129.    
  130. // Step 4. Initialize all the Device Peripherals:
  131. // This function is found in DSP2833x_InitPeripherals.c
  132. // InitPeripherals(); // Not required for this example
  133.    InitAdc();  // For this example, init the ADC

  134. // Specific ADC setup for this example:
  135.    AdcRegs.ADCTRL1.bit.ACQ_PS = ADC_SHCLK;
  136.    AdcRegs.ADCTRL3.bit.ADCCLKPS = ADC_CKPS;
  137.    AdcRegs.ADCTRL1.bit.SEQ_CASC = 1;        // 0 Non-Cascaded Mode; 1 Cascaded Mode
  138.    AdcRegs.ADCTRL2.bit.INT_ENA_SEQ1 = 0x1;
  139.    AdcRegs.ADCTRL2.bit.RST_SEQ1 = 0x1;
  140.    AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x0;
  141.    AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x1;
  142.    AdcRegs.ADCCHSELSEQ1.bit.CONV02 = 0x2;
  143.    AdcRegs.ADCCHSELSEQ1.bit.CONV03 = 0x3;
  144.    AdcRegs.ADCCHSELSEQ2.bit.CONV04 = 0x4;
  145.    AdcRegs.ADCCHSELSEQ2.bit.CONV05 = 0x5;
  146.    AdcRegs.ADCCHSELSEQ2.bit.CONV06 = 0x6;
  147.    AdcRegs.ADCCHSELSEQ2.bit.CONV07 = 0x7;
  148.    AdcRegs.ADCCHSELSEQ3.bit.CONV08 = 0x8;
  149.    AdcRegs.ADCCHSELSEQ3.bit.CONV09 = 0x9;
  150.    AdcRegs.ADCCHSELSEQ3.bit.CONV10 = 0xA;
  151.    AdcRegs.ADCCHSELSEQ3.bit.CONV11 = 0xB;
  152.    AdcRegs.ADCCHSELSEQ4.bit.CONV12 = 0xC;
  153.    AdcRegs.ADCCHSELSEQ4.bit.CONV13 = 0xD;
  154.    AdcRegs.ADCCHSELSEQ4.bit.CONV14 = 0xE;
  155.    AdcRegs.ADCCHSELSEQ4.bit.CONV15 = 0xF;

  156.    AdcRegs.ADCMAXCONV.bit.MAX_CONV1 = 15;   // Set up ADC to perform 4 conversions for every SOC
  157.    
  158. //Step 5. User specific code, enable interrupts:
  159.   // Initialize DMA
  160.         DMAInitialize();

  161.         // Clear Table
  162.    for (i=0; i<BUF_SIZE; i++)
  163.    {
  164.      DMABuf1[i] = 0xffff;
  165.    }

  166.         
  167. // Configure DMA Channel
  168.     DMADest   = &DMABuf1[0];              //Point DMA destination to the beginning of the array
  169.         DMASource = &AdcMirror.ADCRESULT0;    //Point DMA source to ADC result register base
  170.         DMACH1AddrConfig(DMADest,DMASource);
  171.         DMACH1BurstConfig(15,1,10);
  172.         DMACH1TransferConfig(9,-15,(-150 + 1));
  173.         DMACH1WrapConfig(100,100,100,100);          //Don't use wrap function
  174.         DMACH1ModeConfig(DMA_SEQ1INT,PERINT_ENABLE,ONESHOT_DISABLE,CONT_DISABLE,SYNC_DISABLE,SYNC_SRC,
  175.                          OVRFLOW_DISABLE,SIXTEEN_BIT,CHINT_END,CHINT_ENABLE);





  176.         StartDMACH1();

  177.    

  178.    // Start SEQ1
  179. ……………………

  180. …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码

评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏2 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:284570 发表于 2019-7-3 18:55 | 只看该作者
这是用的是什么编译器
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

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