📄 mega8学习笔记(7)-------cocoguojia 原创--单片机实验室-----嘉哥.htm
字号:
href="http://www.mcublog.com/blog/blog2007/cocoguojia/archives/2008/28232.html#">阅读全文<SPAN
id=ob_logreaded></SPAN></A> | <A
href="http://www.mcublog.com/blog/blog2007/cocoguojia/archives/2008/28232.html#cmt">回复(2)</A>
<SPAN id=ob_logm28232></SPAN>| <A
href="http://www.mcublog.com/blog/showtb.asp?id=28232"
target=_blank>引用通告<SPAN id=ob_tbnum></SPAN></A> | <A
href="http://www.mcublog.com/blog/user_post.asp?logid=28232"
target=_blank>编辑</A></DIV></TD></TR></TBODY></TABLE>
<TABLE height=14 cellSpacing=0 cellPadding=0 width="100%"
align=center border=0>
<TBODY>
<TR>
<TD
class=content5></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
<DIV id=blogaddon>
<LI>标签:<SPAN><A
href="http://www.mcublog.com/blog/blog2007/cocoguojia/cmd.html?uid=16550&do=tag_blogs&id=485">MEGA8</A></SPAN> <SPAN><A
href="http://www.mcublog.com/blog/blog2007/cocoguojia/cmd.html?uid=16550&do=tag_blogs&id=33">AVR</A></SPAN> <SPAN><A
href="http://www.mcublog.com/blog/blog2007/cocoguojia/cmd.html?uid=16550&do=tag_blogs&id=5591">自学</A></SPAN> <SPAN><A
href="http://www.mcublog.com/blog/blog2007/cocoguojia/cmd.html?uid=16550&do=tag_blogs&id=5559">CVAVR</A></SPAN> <SPAN><A
href="http://www.mcublog.com/blog/blog2007/cocoguojia/cmd.html?uid=16550&do=tag_blogs&id=741">eeprom</A></SPAN> <SPAN><A
href="http://www.mcublog.com/blog/blog2007/cocoguojia/cmd.html?uid=16550&do=tag_blogs&id=37">程序</A></SPAN> </LI></DIV>
<DIV id=morelog>
<UL>
<LI>上一篇:<A
href="http://www.mcublog.com/blog/blog2007/cocoguojia/archives/2008/28231.html">Mega8学习笔记(6)-------cocoguojia 原创</A>
<LI>下一篇:<A
href="http://www.mcublog.com/blog/blog2007/cocoguojia/archives/2008/28253.html">Mega8学习笔记(8)-------cocoguojia 原创</A>
</LI></UL></DIV>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD>
<TABLE class=seyle4 cellSpacing=0 cellPadding=0 width="100%"
border=0>
<TBODY>
<TR>
<TD> </TD></TR>
<TR>
<TD
class=content9><STRONG>Re:Mega8学习笔记(7)-------cocoguojia 原创<A
name=15362></A></STRONG></TD></TR>
<TR>
<TD>
<DIV align=right>[ <SPAN id=t_15362>2008-5-29
21:58:14</SPAN> | By: <SPAN class=style3><SPAN
id=n_15362>chenshaocheng</SPAN></SPAN>
]</DIV></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD height=3> </TD></TR></TBODY></TABLE>
<TABLE style="TABLE-LAYOUT: fixed" cellSpacing=0 cellPadding=0
width="100%" align=center border=0>
<TBODY>
<TR>
<TD><SPAN class=oblog_text><A
href="http://www.mcublog.com/blog/go.asp?url=http://chenshaocheng.mcublog.com"
target=_blank><IMG class=ob_face height=48
alt=chenshaocheng
src="Mega8学习笔记(7)-------cocoguojia 原创--单片机实验室-----嘉哥.files/ico_default.gif"
width=48 align=absMiddle></A><SPAN
id=c_15362>哦,呵呵,没事,我们学DSP的时间太少.所以还头大看见这程序</SPAN></SPAN></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD height=3> </TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY class=seyle99>
<TR>
<TD>
<DIV align=right><A
href="http://www.mcublog.com/blog/go.asp?url=http://chenshaocheng.mcublog.com"
target=_blank>个人主页</A> | <A
href="javascript:reply_quote('15362')">引用</A> | <A
href="http://www.mcublog.com/blog/blog2007/cocoguojia/archives/2008/28232.html#top">返回</A>
| <A
href="http://www.mcublog.com/blog/user_comments.asp?action=del&id=15362"
target=_blank>删除</A> | <A
href="http://www.mcublog.com/blog/user_comments.asp?action=modify&re=true&id=15362"
target=_blank>回复</A></DIV></TD></TR></TBODY></TABLE>
<TABLE height=14 cellSpacing=0 cellPadding=0 width="100%"
align=center border=0>
<TBODY>
<TR>
<TD
class=content5></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD>
<TABLE class=seyle4 cellSpacing=0 cellPadding=0 width="100%"
border=0>
<TBODY>
<TR>
<TD> </TD></TR>
<TR>
<TD
class=content9><STRONG>Re:Mega8学习笔记(7)-------cocoguojia 原创<A
name=15342></A></STRONG></TD></TR>
<TR>
<TD>
<DIV align=right>[ <SPAN id=t_15342>2008-5-28
16:58:49</SPAN> | By: <SPAN class=style3><SPAN
id=n_15342>chenshaocheng</SPAN></SPAN>
]</DIV></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD height=3> </TD></TR></TBODY></TABLE>
<TABLE style="TABLE-LAYOUT: fixed" cellSpacing=0 cellPadding=0
width="100%" align=center border=0>
<TBODY>
<TR>
<TD><SPAN class=oblog_text><A
href="http://www.mcublog.com/blog/go.asp?url=http://chenshaocheng.mcublog.com"
target=_blank><IMG class=ob_face height=48
alt=chenshaocheng
src="Mega8学习笔记(7)-------cocoguojia 原创--单片机实验室-----嘉哥.files/ico_default.gif"
width=48 align=absMiddle></A><SPAN
id=c_15342>嘉哥,如果你懂DSP,帮我看一看下面这段程序(SPWM波生成实验代码).谢谢!<BR>#i
nclude "math.h"<BR>#i nclude "f2407_c.h" <BR>#define PI
3.1415926<BR>extern void ini(void); <BR>extern interrupt
void timer2_isr(void);<BR>void delay5s(void);<BR>float
sin_table[33]={0,0.189,0.371,0.541,0.690,0.815,0.909,0.972,0.98,<BR>0.972,0.909,0.815,0.690,0.541,0.371,0.189,0,<BR>-0.189,-0.371,-0.541,-0.690,-0.815,-0.909,-0.972,-0.98,<BR>-0.972,-0.909,-0.815,-0.690,-0.541,-0.371,-0.189,0};<BR>unsigned
int index_pwm=0; <BR>unsigned int a,b,c=0;<BR>float
timer2_per=200;<BR>unsigned int num_f_d=33; <BR>float f;
<BR>unsigned int d;<BR><BR>void
main(void)<BR>{<BR>unsigned int
i,j;<BR>ini();<BR><BR>asm(" CLRC
INTM");--开总中断<BR><BR><BR>for(i=0;i<10;i++)
<BR>delay5s();<BR>delay5s();<BR>delay5s();<BR>delay5s();<BR>delay5s();<BR>*IMR
|= 0x0001;<BR><BR>for(;;)delay5s();;<BR>}<BR><BR>void
delay5s(void)<BR>{<BR>unsigned long
i;<BR><BR>for(i=0;i<5000;i++);<BR>}<BR>void
ini(void)<BR>{ <BR>unsigned int e;<BR>*SCSR1 =
0x00FD;<BR>*SCSR2 = (*SCSR2 | 0x000B) &
0x000F;<BR>*WDCR = 0x00E8;<BR>WSGR = 0x0040;<BR>*MCRA =
0x0fc0; <BR>*MCRB = 0xFE00; <BR>*MCRC = 0x0000;
<BR>*PFDATDIR = *PFDATDIR | 0x2000;<BR>*T1CON = 0x0000;
<BR>*T2CON = 0x0000; <BR>*GPTCONA = 0x0080; <BR>*T1CNT =
0x0000; <BR>*T1PR =32*timer2_per; <BR>d=*T1PR;
<BR>*DBTCONA = 0xff3; <BR>*ACTRA = 0x0666; <BR>*COMCONA
= 0x8200; <BR>*T1CON = 0x0840; <BR>*DBTCONA=0xff3;
<BR>*T2CNT = 0x0000; <BR>*T2PR = timer2_per; <BR>*T2CON
= 0xD640; <BR>*IMR = 0x0000; <BR>*IFR = 0x003F; <BR>*IMR
= 0x0004; <BR>*EVAIFRA = 0xFFFF; <BR>*EVAIFRB = 0xFFFF;
<BR>*EVAIFRC = 0xFFFF; <BR>*EVAIMRA = 0x0000;
<BR>*EVAIMRB = 0x0001; <BR>*EVAIMRC = 0x0000;
<BR>*EVBIFRA = 0xFFFF; <BR>*EVBIFRB = 0xFFFF;
<BR>*EVBIFRC = 0xFFFF; <BR>*EVBIMRA = 0x0000;
<BR>*EVBIMRB = 0x0000; <BR>*EVBIMRC = 0x0000;
<BR>}<BR><BR>interrupt void
timer2_isr(void)<BR>{<BR>*EVAIFRB = *EVAIFRB &
0x0001;
<BR>f=0.2+156.0/timer2_per;<BR>if(f>0.98)<BR>f=0.98;<BR>a=*CMPR1=f*d*(0.5+0.5*sin_table[index_pwm%num_f_d]);<BR>b=*CMPR2=f*d*(0.5+0.5*sin_table[(index_pwm+((2*num_f_d)/3))%num_f_d]);<BR>c=*CMPR3=f*d*(0.5+0.5*sin_table[(index_pwm+((num_f_d)/3))%num_f_d]);<BR>index_pwm++;<BR>if(index_pwm>=num_f_d)index_pwm=0;<BR><BR>}
<DIV
class=quote><STRONG>以下为嘉哥的回复:</STRONG><BR>8位机还能看看,dsp我不懂,呵呵</DIV></SPAN></SPAN></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD height=3> </TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY class=seyle99>
<TR>
<TD>
<DIV align=right><A
href="http://www.mcublog.com/blog/go.asp?url=http://chenshaocheng.mcublog.com"
target=_blank>个人主页</A> | <A
href="javascript:reply_quote('15342')">引用</A> | <A
href="http://www.mcublog.com/blog/blog2007/cocoguojia/archives/2008/28232.html#top">返回</A>
| <A
href="http://www.mcublog.com/blog/user_comments.asp?action=del&id=15342"
target=_blank>删除</A> | <A
href="http://www.mcublog.com/blog/user_comments.asp?action=modify&re=true&id=15342"
target=_blank>回复</A></DIV></TD></TR></TBODY></TABLE>
<TABLE height=14 cellSpacing=0 cellPadding=0 width="100%"
align=center border=0>
<TBODY>
<TR>
<TD
class=content5></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
<DIV id=form_comment>
<DIV id=gg_usercomment></DIV><A name=cmt></A>
<DIV class=title>发表评论:</DIV>
<FORM id=commentform name=commentform
onsubmit="return Verifycomment()"
action=/blog/savecomment.asp?logid=28232 method=post>
<DIV class=d1><LABEL>昵称:<INPUT id=UserName maxLength=20
name=UserName></LABEL></DIV>
<DIV class=d2><LABEL>密码:<INPUT id=Password type=password
maxLength=20 name=Password> (游客无须输入密码)</LABEL></DIV>
<DIV class=d3><LABEL>主页:<INPUT id=homepage maxLength=50 size=42
value=http:// name=homepage></LABEL></DIV>
<DIV class=d4><LABEL>标题:<INPUT id=commenttopic maxLength=50 size=42
value=Re:Mega8学习笔记(7)-------cocoguojia 原创
name=commenttopic></LABEL></DIV>
<DIV class=d5><INPUT id=edit type=hidden name=edit>
<DIV id=oblog_edit>数据载入中...</DIV></DIV>
<DIV class=d6><SPAN id=ob_code></SPAN><INPUT onclick='oblog_edittext.createTextRange().execCommand("Copy");' type=submit value= 提 交 ></DIV></FORM></DIV></TD></TR></TBODY></TABLE></DIV></TD>
<TD vAlign=top align=right width=205><IMG height=425 alt=""
src="Mega8学习笔记(7)-------cocoguojia 原创--单片机实验室-----嘉哥.files/index_04.jpg"
width=150></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width=1004 border=0>
<TBODY>
<TR>
<TD vAlign=top bgColor=#f4f4f4><IMG height=18 alt=""
src="Mega8学习笔记(7)-------cocoguojia 原创--单片机实验室-----嘉哥.files/index_16.jpg"
width=1004> </TD></TR></TBODY></TABLE><SPAN id=gg_userbot></SPAN>
<DIV id=powered><A href="http://www.mcublog.com/" target=_blank><IMG
alt="Powered by McuBLog."
src="Mega8学习笔记(7)-------cocoguojia 原创--单片机实验室-----嘉哥.files/mcublog_powered.gif"
border=0></A></DIV>
<SCRIPT
src="Mega8学习笔记(7)-------cocoguojia 原创--单片机实验室-----嘉哥.files/200805.htm"></SCRIPT>
<SCRIPT
src="Mega8学习笔记(7)-------cocoguojia 原创--单片机实验室-----嘉哥.files/count.htm"></SCRIPT>
<SCRIPT
src="Mega8学习笔记(7)-------cocoguojia 原创--单片机实验室-----嘉哥.files/commentedit.htm"></SCRIPT>
<SCRIPT
src="F:\download\mega8学习笔记\Mega8学习笔记(7)-------cocoguojia 原创--单片机实验室-----嘉哥.files\count(1).htm"></SCRIPT>
<SCRIPT src=""></SCRIPT>
<SCRIPT
src="Mega8学习笔记(7)-------cocoguojia 原创--单片机实验室-----嘉哥.files/ShowXml.htm"></SCRIPT>
<SCRIPT
src="F:\download\mega8学习笔记\Mega8学习笔记(7)-------cocoguojia 原创--单片机实验室-----嘉哥.files\count(2).htm"></SCRIPT>
</BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -