打印

新手上路,2407 做SPWM,望前辈们指出错误

[复制链接]
2560|2
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
guo19877|  楼主 | 2010-3-5 10:17 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
SPWM, dc, ce, AD, AC
本人菜鸟,先声明,刚接触DSP,自己胡乱写的,用查表法做SPWM

#include "2407_c.h"
//=============正弦波数据====================
uchar code  sin_tab[512]={
4000 ,4400 ,4800 ,4A00 ,4C00 ,4E00 ,4F00 ,5000
,5090 5120 ,5150 ,51E0 ,5260 ,52E0 ,5360 ,53E0
,5450 ,54C0 ,5530 ,55A0 ,5610 ,5680 ,56E8 ,574F
,57B5 ,581A ,587E ,58E1 ,5943 ,59A4 ,5A04 ,5A5D
,5AB5 ,5B0D ,5B64 ,5BBB ,5C11 ,5C64 ,5CBC ,5D11
,5D65 ,5DB9 ,5E0C ,5E5F ,5EB1 ,5F03 ,5F55 ,5FA6
,5FF7 ,6047 ,6097 ,60E0 ,6129 ,6172 ,61BA ,6202
,6248 ,628F ,62D5 ,631A ,635E ,63A1 ,63E3 ,6424
,6464 ,649D ,64D5 ,650C ,6542 ,6577 ,65AB ,65DE
,6610 ,6641 ,6671 ,669A ,66C2 ,66E9 ,670F ,6734
,6759 ,677E ,67A3 ,67C7 ,67EA ,680C ,682D ,684E
,6867 ,6880 ,6898 ,68AF ,68C5 ,68DA ,68EE ,6901
,6913 ,6925 ,6936 ,6946 ,694f ,6957 ,695e ,6964
,6969 ,696E ,6972 ,6976 ,6979 ,697C ,697F ,6981
,6983 ,6985 ,6987 ,6989 ,698A ,698B ,698C ,698D
,698D ,698D ,698D ,698D ,698D ,698D ,698D ,698D
,698D ,698D ,698D, 698D ,698D ,698D ,698D, 698D
,698D ,698C, 698B ,698A ,6989 ,6987 ,6985, 6983
,6981 ,697F, 697C ,6979 ,6976, 6972 ,696E, 6969
,6964, 695e, 6957 ,694f, 6946 ,6936 ,6925, 6913
,6901 ,68EE 68DA, 68C5, 68AF ,6898 ,6880, 6867
,684E, 682D ,680C, 67EA ,67C7 ,67A3 ,677E ,6759
,6734 ,670F ,66E9 ,66C2 ,669A, 6671 ,6641, 6610
,65DE, 65AB, 6577, 6542, 650C, 64D5 ,649D ,6464
,6424, 63E3 ,63A1 ,635E ,631A ,62D5 ,628F ,6248
,6202 ,61BA, 6172 ,6129 ,60E0 ,6097 ,6047 ,5FF7
,5FA6 ,5F55 ,5F03 ,5EB1 ,5E5F ,5E0C ,5DB9 ,5D65
,5D11 ,5CBC ,5C64 ,5C11 ,5BBB ,5B64 ,5B0D ,5AB5
,A5D ,5A04 ,59A4 ,5943 ,58E1 ,587E ,581A ,57B5
,574F ,56E8 ,5680 ,5610 ,55A0 ,5530 ,54C0 ,5450
,53E0 ,5360 ,52E0 ,5260 ,51E0 ,5150 ,5120 ,5090
,5000 ,4F00 ,4E00, 4C00, 4A00 ,4800 ,4400 ,4000
,4000, ,3C00 ,3800 ,3400 ,3200 ,3000 ,2F00, ,2E00
,2D70, ,2CE0 ,2C50 ,2BD0 ,2B50 ,2AD0 ,2A50 ,29E0
,2970 ,2900 ,2890 ,2820 ,27B0, 2748 ,26E1, ,367B
,2616, ,25B2 ,254F, 24ED, 248C ,242C, ,23D3, ,237B
,2323, ,22BF ,2268 ,2212, 21BC ,2167 ,2112 ,20BD
,2069 ,2015 ,1FC2, ,1F6F ,1F1D ,1ECB ,1E7A ,1E29
,1DD9, ,1D89 ,1D40, ,1CF7 ,1CAE, ,1C66,  ,1C1E ,1BD6
,1B8F ,1B48 ,1B03 ,1ABF ,1A7C ,1A3A ,19F9 ,19B9
,1980 ,1948 ,1911 ,18DB ,18A6 ,1872 ,183F ,180D
,17DC ,17AC ,1783 ,175B ,1734 ,170E ,16E9 ,16C5
,16A2 ,1680 ,165F ,163F ,161F ,15FF ,15DF ,15C6
,15AD ,1595 ,157C ,1564 ,154C ,1536 ,1520 ,150B
,14E2 ,14CE ,14BB ,14A8 ,1496 ,1484 ,1472 ,1460
,144F ,143F ,142F ,1426 ,141E ,1416 ,140F ,1409
,1404 ,13FF ,13FB ,13F7 ,13F4 ,13F1 ,13EF ,13ED
,13EC ,13EB ,13EB ,13EB ,13EB ,13EB ,13EB ,13EB
      
,13EB ,13EB ,13EB ,13EB ,13EB ,13EB ,13EB ,13EC
,13ED ,13EF ,13F1 ,13F4 ,13F7 ,13FB ,13FF ,1404
,1409 ,140F ,1416 ,141E ,1426 ,142F ,143F ,144F
,1460 ,1472 ,1484 ,1496 14A8 ,14BB ,14CE ,14E2
,150B ,1520 ,1536 ,154C ,1564 ,157C ,1595 ,15AD
,15C6 ,15DF ,15FF ,161F ,163F ,165F ,1680 ,16A2
,16C5 ,16E9 ,170E ,1734 ,175B ,1783 ,17AC ,17DC
,180D ,183F ,1872 ,18A6 ,18DB ,1911 ,1948   ,1980
,19B9 ,19F9 ,1A3A ,1A7C ,1ABF ,1B03 ,1B48 ,1B8F
,1BD6 ,1C1E ,1C66 ,1CAE ,1CF7 ,1D40 ,1D89 ,1DD9
,1E29 ,1E7A ,1ECB ,1F1D ,1F6F ,1FC2 ,2015 ,2069
,20BD ,2112 ,2167 ,21BC ,2212 ,2268 ,22BF ,2323
,237B ,23D3 ,242C ,248C ,24ED ,254F ,25B2 ,2616
,367B ,26E1 ,2748 ,27B0 ,2820 ,2890 ,2900 ,2970
,29E0 ,2A50 ,2AD0 ,2B50 ,2BD0 ,2C50 ,2CE0 ,2D70
,2E00 ,2F00 ,3000 ,3200 ,3400 ,3800 ,3C00 ,4000

};

void main()
{
ovm=0;
sex=0;
i=0;
scsr1=0x0608;//状态寄存器1 倍频系数是1,外部时钟15M HZ
wdcr=0x0068;关闭开门狗
t3pr=0x024a;//周期寄存值=15M HZ/(50*512)
comconb=oxa600;
actrb=0x0066;初始化PWM
cmpr4=0x0125;//占空比50% pwm7,pwm8
cmpr5=0x0187;//占空比2/3
t3con=ox9044;//计数模式 连续增
t3cnt=0x0000;//计数寄存器清零
wdcr=0x0068;
imr=0x0002;//中断屏蔽寄存器
gptconb=0x0040;
pwm7=atoi(sin_tab[i]);
pwm8=atoi(sin_tab[i]);
pwm9=atoi(sin_tab[i]);
pwm10=atoi(sin_tab[i]);
i++;
while(i==512)
{i=0;
}
}

相关帖子

沙发
guo19877|  楼主 | 2010-3-5 21:37 | 只看该作者
哎丫丫,怎么没人回答呀,等高手解答!

使用特权

评论回复
板凳
qhd_sinner| | 2010-3-22 10:28 | 只看该作者
怎么连个中断服务程序都没有:L

使用特权

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

本版积分规则

14

主题

28

帖子

1

粉丝