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

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 7070|回復(fù): 9
收起左側(cè)

DSPF28335關(guān)于SPWM的源代碼

[復(fù)制鏈接]
ID:247388 發(fā)表于 2018-3-16 15:08 | 顯示全部樓層 |閱讀模式
關(guān)于DSPF28335寫的SPWM代碼分享給大家
0.png
源程序如下:
  1. /*
  2. * main.c
  3. */

  4. #include "DSP28x_Project.h"     // Device Headerfile and Examples Include File

  5. // Prototype statements for functions found within this file.
  6. void InitEPwm1Example(void);
  7. extern void InitSpwm(void);

  8. void main(void) {
  9. // Step 1. Initialize System Control:
  10. // PLL, WatchDog, enable Peripheral Clocks
  11. // This example function is found in the DSP2833x_SysCtrl.c file.
  12.    InitSysCtrl();

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

  17. // For this case just init GPIO pins for ePWM1, ePWM2, ePWM3
  18. // These functions are in the DSP2833x_EPwm.c file
  19.    InitEPwm1Gpio();


  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. // Interrupts that are used in this example are re-mapped to
  39. // ISR functions found within this file.
  40. // EALLOW;  // This is needed to write to EALLOW protected registers
  41. // PieVectTable.EPWM1_INT = &EPWM1_INT_ISR;

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

  43. // Step 4. Initialize all the Device Peripherals:
  44. // This function is found in DSP2833x_InitPeripherals.c
  45. // InitPeripherals();  // Not required for this example

  46. // For this example, only initialize the ePWM

  47.    EALLOW;
  48.    SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0;
  49.    EDIS;

  50.    InitEPwm1Example();
  51.    InitSpwm();

  52.    EALLOW;
  53.    SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1;
  54.    EDIS;

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

  56. // Enable CPU INT3 which is connected to EPWM1-3 INT:
  57.    IER |= M_INT3;

  58. // Enable EPWM INTn in the PIE: Group 3 interrupt 1-3
  59.    PieCtrlRegs.PIEIER3.bit.INTx1 = 1;

  60. // Enable global Interrupts and higher priority real-time debug events:
  61.    EINT;   // Enable Global interrupt INTM
  62.    ERTM;   // Enable Global realtime interrupt DBGM

  63. // Step 6. IDLE loop. Just sit and loop forever (optional):
  64.    for(;;)
  65.    {
  66.            __asm("          NOP");
  67.    }

  68. }
  69. void InitEPwm1Example()
  70. {
  71.    // Setup TBCLK
  72.    EPwm1Regs.TBPRD = 0xffff;           // Set timer period 801 TBCLKs
  73.    EPwm1Regs.TBPHS.half.TBPHS = 0x0000;           // Phase is 0
  74.    EPwm1Regs.TBCTR = 0x0000;                      // Clear counter

  75.    // Set Compare values
  76.    EPwm1Regs.CMPA.half.CMPA = 0x7fff;     // Set compare A value
  77.    EPwm1Regs.CMPB = 0x7fff;               // Set Compare B value

  78.    // Setup counter mode
  79.    EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Count up
  80.    EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE;        // Disable phase loading
  81.    EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV2;       // Clock ratio to SYSCLKOUT
  82.    EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV8;

  83.    // Setup shadowing
  84.    EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
  85.    EPwm1Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
  86.    EPwm1Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;  // Load on Zero
  87.    EPwm1Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;


  88.    // Set actions
  89.    EPwm1Regs.AQCTLA.bit.CAU = AQ_SET;             // Set PWM1A on event A, up count
  90.    EPwm1Regs.AQCTLA.bit.CAD = AQ_CLEAR;           // Clear PWM1A on event A, down count

  91.    EPwm1Regs.AQCTLB.bit.CBU = AQ_SET;             // Set PWM1B on event B, up count
  92.    EPwm1Regs.AQCTLB.bit.CBD = AQ_CLEAR;           // Clear PWM1B on event B, down count

  93.    // Interrupt where we will change the Compare Values
  94.    EPwm1Regs.ETSEL.bit.INTSEL = ET_CTRU_CMPA;      // Select INT on Zero event
  95.    EPwm1Regs.ETSEL.bit.INTEN = 1;                 // Enable INT
  96.    EPwm1Regs.ETPS.bit.INTPRD = ET_1ST;            // Generate INT on 3rd event

  97. }

復(fù)制代碼

所有資料51hei提供下載:
SPWM.zip (91.11 KB, 下載次數(shù): 99)


回復(fù)

使用道具 舉報(bào)

ID:15377 發(fā)表于 2018-3-29 06:39 | 顯示全部樓層
謝謝分享!
回復(fù)

使用道具 舉報(bào)

ID:247467 發(fā)表于 2018-4-18 20:02 | 顯示全部樓層
也是今天才看了,PWM這個(gè)部分,感覺還不太深入,可以看看這個(gè)程序,好好在學(xué)習(xí)一下
回復(fù)

使用道具 舉報(bào)

ID:324611 發(fā)表于 2018-12-20 10:58 | 顯示全部樓層
正在學(xué)習(xí)spwm,收藏了。
回復(fù)

使用道具 舉報(bào)

ID:284570 發(fā)表于 2019-7-20 17:53 | 顯示全部樓層
贊!
回復(fù)

使用道具 舉報(bào)

ID:742944 發(fā)表于 2020-5-2 18:34 | 顯示全部樓層
不錯(cuò),學(xué)習(xí)了
回復(fù)

使用道具 舉報(bào)

ID:746506 發(fā)表于 2020-5-7 22:33 | 顯示全部樓層
請問無法打開“Cover.h”源文件是什么意思?
回復(fù)

使用道具 舉報(bào)

ID:746506 發(fā)表于 2020-5-7 22:34 | 顯示全部樓層
你好,請問無法打開“Cover.h”文件,是不是少了這個(gè)頭文件?請問樓主有這個(gè)文件嗎,可以發(fā)我一下嗎
回復(fù)

使用道具 舉報(bào)

ID:755142 發(fā)表于 2020-5-29 19:55 | 顯示全部樓層
大佬,我想請教,加個(gè)好友唄
回復(fù)

使用道具 舉報(bào)

ID:755142 發(fā)表于 2020-5-29 19:58 | 顯示全部樓層
JerZY 發(fā)表于 2020-5-7 22:33
請問無法打開“Cover.h”源文件是什么意思?

用啥打開呀
回復(fù)

使用道具 舉報(bào)

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

本版積分規(guī)則

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

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

快速回復(fù) 返回頂部 返回列表
主站蜘蛛池模板: 一级片子 | 欧美精品久久久 | 婷婷综合五月天 | www.4567| 激情91 | 欧美亚洲国产一区 | 激情五月综合 | av成人在线观看 | 日韩欧美国产不卡 | 国产视频中文字幕在线观看 | 999久久久| 一区二区三区欧美在线 | 久久久中文 | 国产精品日韩欧美一区二区 | 九九热国产精品视频 | 成人深夜福利网站 | 日韩在线中文 | 日本电影一区二区 | 欧美黑人一级爽快片淫片高清 | 99精品免费视频 | 黄色一级视频 | 久久日韩粉嫩一区二区三区 | 99国产精品99久久久久久粉嫩 | 天堂av免费观看 | 日韩一区二区在线视频 | 欧美2区 | 成人免费看黄网站在线观看 | 中文字幕第100页 | 午夜成人免费视频 | 中文字幕动漫成人 | 91国语清晰打电话对白 | 盗摄精品av一区二区三区 | 亚洲精品一区二区在线观看 | 全免费a级毛片免费看视频免费下 | 一区二区三区四区在线视频 | 中文字幕综合 | 日韩一级免费观看 | 欧美 日韩 国产 一区 | 亚洲国产精品视频 | 狠狠操狠狠干 | 黄色网址在线免费观看 |