打印

初学dsp,Easy2812开发板产生SPWM波形

[复制链接]
2430|6
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
zxs2000|  楼主 | 2012-2-28 11:14 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
/*********************************************************************
** 实验目的:产生SPWM波形  **
**********************************************************************/

#include "DSP28_Device.h"
#define MAX_BUF 400
unsigned int * Led8  = (unsigned int *) 0x4100;//二极管地址,由CPLD提供
unsigned int Led_Flag;   //二极管全亮,全灭标志位
unsigned int g_spwm_data[MAX_BUF]={0x3A9,0x3B8,0x3C6,0x3D5,0x3E4,0x3F3,0x401,0x410,0x41F,0x42D,0x43C,0x44A,0x459,0x467,0x476,0x484,0x492,0x4A0,0x4AF,0x4BD,0x4CB,0x4D9,0x4E7,0x4F4,0x502,0x510,0x51D,0x52B,0x538,0x545,0x553,0x560,0x56D,0x579,0x586,0x593,0x59F,0x5AC,0x5B8,0x5C4,0x5D0,0x5DC,0x5E8,0x5F3,0x5FF,0x60A,0x615,0x620,0x62B,0x635,0x640,0x64A,0x654,0x65E,0x668,0x672,0x67B,0x685,0x68E,0x697,0x69F,0x6A8,0x6B0,0x6B9,0x6C1,0x6C8,0x6D0,0x6D7,0x6DF,0x6E6,0x6EC,0x6F3,0x6F9,0x6FF,0x705,0x70B,0x711,0x716,0x71B,0x720,0x725,0x729,0x72D,0x731,0x735,0x739,0x73C,0x73F,0x742,0x745,0x747,0x749,0x74B,0x74D,0x74E,0x750,0x751,0x751,0x752,0x752,0x752,0x752,0x752,0x751,0x751,0x750,0x74E,0x74D,0x74B,0x749,0x747,0x745,0x742,0x73F,0x73C,0x739,0x735,0x731,0x72D,0x729,0x725,0x720,0x71B,0x716,0x711,0x70B,0x705,0x6FF,0x6F9,0x6F3,0x6EC,0x6E6,0x6DF,0x6D7,0x6D0,0x6C8,0x6C1,0x6B9,0x6B0,0x6A8,0x69F,0x697,0x68E,0x685,0x67B,0x672,0x668,0x65E,0x654,0x64A,0x640,0x635,0x62B,0x620,0x615,0x60A,0x5FF,0x5F3,0x5E8,0x5DC,0x5D0,0x5C4,0x5B8,0x5AC,0x59F,0x593,0x586,0x579,0x56D,0x560,0x553,0x545,0x538,0x52B,0x51D,0x510,0x502,0x4F4,0x4E7,0x4D9,0x4CB,0x4BD,0x4AF,0x4A0,0x492,0x484,0x476,0x467,0x459,0x44A,0x43C,0x42D,0x41E,0x410,0x401,0x3F3,0x3E4,0x3D5,0x3C6,0x3B8,0x3A9,0x39A,0x38C,0x37D,0x36E,0x35F,0x351,0x342,0x333,0x325,0x316,0x308,0x2F9,0x2EB,0x2DC,0x2CE,0x2C0,0x2B2,0x2A3,0x295,0x287,0x279,0x26B,0x25E,0x250,0x242,0x235,0x227,0x21A,0x20D,0x1FF,0x1F2,0x1E5,0x1D9,0x1CC,0x1BF,0x1B3,0x1A6,0x19A,0x18E,0x182,0x176,0x16A,0x15F,0x153,0x148,0x13D,0x132,0x127,0x11D,0x112,0x108,0xFE,0xF4,0xEA,0xE0,0xD7,0xCD,0xC4,0xBB,0xB3,0xAA,0xA2,0x99,0x91,0x8A,0x82,0x7B,0x73,0x6C,0x66,0x5F,0x59,0x53,0x4D,0x47,0x41,0x3C,0x37,0x32,0x2D,0x29,0x25,0x21,0x1D,0x19,0x16,0x13,0x10,0x0D,0x0B,0x09,0x07,0x05,0x04,0x02,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x02,0x04,0x05,0x07,0x09,0x0B,0x0D,0x10,0x13,0x16,0x19,0x1D,0x21,0x25,0x29,0x2D,0x32,0x37,0x3C,0x41,0x47,0x4D,0x53,0x59,0x5F,0x66,0x6C,0x73,0x7B,0x82,0x8A,0x91,0x99,0xA2,0xAA,0xB3,0xBB,0xC4,0xCD,0xD7,0xE0,0xEA,0xF4,0xFE,0x108,0x112,0x11D,0x127,0x132,0x13D,0x148,0x153,0x15F,0x16A,0x176,0x182,0x18E,0x19A,0x1A6,0x1B3,0x1BF,0x1CC,0x1D9,0x1E5,0x1F2,0x1FF,0x20D,0x21A,0x227,0x235,0x242,0x250,0x25E,0x26B,0x279,0x287,0x295,0x2A3,0x2B2,0x2C0,0x2CE,0x2DC,0x2EB,0x2F9,0x308,0x316,0x325,0x334,0x342,0x351,0x35F,0x36E,0x37D,0x38C,0x39A};
unsigned int count=0;

interrupt void eva_timer1_isr(void);

void main(void)
{
/*初始化系统*/
InitSysCtrl();
/*关中断*/
DINT;
IER = 0x0000;
IFR = 0x0000;

/*初始化PIE控制寄存器*/
InitPieCtrl();

/*初始化PIE矢量表*/
InitPieVectTable();

/*初始化GPIO*/
InitGpio();

/*初始化EV*/
InitEv();
EALLOW;
    PieVectTable.T1PINT=&eva_timer1_isr;
    EDIS;
    PieCtrl.PIEIER2.bit.INTx4=1;//T1PIN
    IER=0x0002;
EINT;
ERTM;
for(;;)
{
  KickDog(); //剔除看门狗,防止对DSP进行复位
}
}  

//===========================================================================
// No more.
//===========================================================================
interrupt void eva_timer1_isr(void)
{
  EvaRegs.CMPR1=g_spwm_data[count];
  count++;
  if(count>=MAX_BUF)
    count = 0;
if(Led_Flag == 1)
{
  *Led8 = 0x00;   //全亮
  Led_Flag = 0;
}
else
{
  *Led8 = 0xff;   //全灭
  Led_Flag = 1;
}
  EvaRegs.EVAIMRA.bit.T1PINT=1;//使能定时器1的周期中断标志
  EvaRegs.EVAIFRA.bit.T1PINT=1;//复位定时器1的周期中断标志
  PieCtrl.PIEACK.bit.ACK2=1;  
  
}

spwm.rar

288.71 KB

相关帖子

沙发
Cortex-M0| | 2012-3-1 18:00 | 只看该作者
顶一把

使用特权

评论回复
板凳
Ryanhsiung| | 2012-3-3 15:46 | 只看该作者
顶一下,我还没开始玩呢!!

使用特权

评论回复
地板
李不走寻常路| | 2015-7-26 16:06 | 只看该作者
你好 能传给我一份easy2812的资料吗?  我的找不到了 谢谢

使用特权

评论回复
5
li7213405| | 2016-5-30 22:54 | 只看该作者
你好,能传给我一份大道开发板easy2812的资料吗?  我的找不到了 谢谢  QQ邮箱:275354451,

使用特权

评论回复
6
山东电子小菜鸟| | 2016-7-17 22:48 | 只看该作者
支持 顶起

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

34

主题

206

帖子

0

粉丝