📄 mega8学习笔记(6)-------cocoguojia 原创--单片机实验室-----嘉哥.htm
字号:
<DIV class=content4><!-- BEGIN: tb -->
<DIV
id=newblog>数据载入中...</DIV><!-- END: tb --></DIV></TD></TR></TBODY></TABLE><!-- END: last_tb -->
<TABLE class=table3 cellSpacing=0 cellPadding=0 width="100%"
align=center border=0>
<TBODY>
<TR>
<TD class=b2 align=middle height=43>最 新 留 言</TD></TR>
<TR>
<TD>
<DIV class=content4>
<DIV id=newmessage>数据载入中...</DIV></DIV></TD></TR></TBODY></TABLE>
<TABLE class=table3 cellSpacing=0 cellPadding=0 width="100%"
align=center border=0>
<TBODY>
<TR>
<TD class=b2 align=middle height=43>搜 索</TD></TR>
<TR>
<TD>
<DIV class=content4>
<DIV id=search>数据载入中...</DIV></DIV></TD></TR></TBODY></TABLE>
<TABLE class=table3 cellSpacing=0 cellPadding=0 width="100%"
align=center border=0>
<TBODY>
<TR>
<TD class=b2 align=middle height=43>用 户 登 录</TD></TR>
<TR>
<TD align=middle>
<DIV class=content4>
<DIV id=ob_login>数据载入中...</DIV></DIV></TD></TR></TBODY></TABLE><!-- BEGIN: link -->
<TABLE class=table3 cellSpacing=0 cellPadding=0 width="100%"
align=center border=0>
<TBODY>
<TR>
<TD class=b2 align=middle height=43>友 情 连 接</TD></TR>
<TR>
<TD>
<TABLE style="TABLE-LAYOUT: fixed; OVERFLOW: hidden"
cellSpacing=0 cellPadding=0 width="87%" align=center
border=0><TBODY>
<TR>
<TD class=b1>
<DIV id=links></DIV>
<DIV
id=gg_userlinks></DIV></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
<TABLE class=table3 cellSpacing=0 cellPadding=0 width="100%"
align=center border=0>
<TBODY>
<TR>
<TD class=b2 align=middle height=43>博 客 信 息</TD></TR>
<TR>
<TD align=right>
<TABLE class=b1 cellSpacing=5 cellPadding=2 width="87%"
border=0>
<TBODY>
<TR>
<TD class=b1 align=left>
<DIV id=info>数据载入中...</DIV>
<DIV id=aobomusic></DIV></TD></TR>
<TR>
<TD class=b1 align=left>
<DIV id=xml><SPAN id=txml></SPAN><BR><BR><A
href="http://www.mcublog.com/blog/blog2007/cocoguojia/rss2.xml"
target=_blank><IMG height=14
src="Mega8学习笔记(6)-------cocoguojia 原创--单片机实验室-----嘉哥.files/xml.gif"
width=36
border=0></A></DIV></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><!-- END: link --></TD></TR></TBODY></TABLE></TD>
<TD vAlign=top>
<DIV id=content>
<TABLE cellSpacing=0 cellPadding=0 width="93%" align=center border=0>
<TBODY>
<TR>
<TD>
<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>Mega8学习笔记(6)-------cocoguojia 原创 <IMG
src="Mega8学习笔记(6)-------cocoguojia 原创--单片机实验室-----嘉哥.files/jhinfo.gif"></STRONG></TD></TR>
<TR>
<TD>
<DIV align=right>[ 2008-5-28 11:41:00 | By: <SPAN
class=style3>嘉哥</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><SPAN id=ob_logd28231></SPAN>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">下面我就以《</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman"> AVR
</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">单片机入门与实践</SPAN><FONT
face="Times New Roman"> </FONT><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">》李弘</SPAN><FONT
face="Times New Roman"> </FONT><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">等编著</SPAN><SPAN
lang=EN-US><SPAN style="mso-spacerun: yes"><FONT
face="Times New Roman"> </FONT></SPAN></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">北京航空航天大学出版社这本书来讲述学习心得</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN
lang=EN-US><o:p><FONT
face="Times New Roman"> </FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">前言:关于运算放大器的比较器的应用知识先看看(大学里学了,再温习一遍吧,自己找资料)。关于</SPAN><SPAN
lang=EN-US><FONT
face="Times New Roman">mega8</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的模拟比较器我们可以这样理解,在单片机里有个运放就行了,很简单的,</SPAN><SPAN
lang=EN-US><FONT
face="Times New Roman">20</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">分钟搞的定。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN
lang=EN-US><o:p><FONT
face="Times New Roman"> </FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">第六章:模拟比较器功能</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN
lang=EN-US><o:p><FONT
face="Times New Roman"> </FONT></o:p></SPAN></P><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">主要的控制寄存器就两个,</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">SFIOR
</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和</SPAN><SPAN
lang=EN-US><FONT
face="Times New Roman">ACSR</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。其中</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">SFIOR
</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">可以看成个选择开关,按照书上说的赋值就是了(有必要设置的时候才设置)。仔细研究一下</SPAN><SPAN
lang=EN-US><FONT
face="Times New Roman">ACSR</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。</SPAN></P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt"></SPAN><SPAN
lang=EN-US><o:p><FONT
face="Times New Roman"> </FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">看完了,</SPAN><SPAN
lang=EN-US><FONT
face="Times New Roman">OK</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">,开始实践吧,编一个比较</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">AIN0
</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman"> AIN1
</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">大小的程序,若</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">AIN0<SPAN
style="mso-spacerun: yes">
</SPAN>AIN1</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">之间的大小关系发生变化</SPAN><FONT
face="Times New Roman"> <SPAN
lang=EN-US>,</SPAN></FONT><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">则小</SPAN><SPAN
lang=EN-US><FONT
face="Times New Roman">led</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">灯(串联</SPAN><SPAN
lang=EN-US><FONT
face="Times New Roman">330</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">欧的电阻,正极接</SPAN><SPAN
lang=EN-US><FONT
face="Times New Roman">+5V</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">,负极接</SPAN><SPAN
lang=EN-US><FONT
face="Times New Roman">PORTB.0---------</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">如没有特殊说明,在本笔记中</SPAN><SPAN
lang=EN-US><FONT
face="Times New Roman">led</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">小灯都是这种接法,即低电平点亮)亮</SPAN><SPAN
lang=EN-US><FONT
face="Times New Roman">2S</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN
lang=EN-US><o:p><FONT
face="Times New Roman"> </FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN
lang=EN-US><FONT face="Times New Roman">#i nclude
<mega8.h></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN
lang=EN-US><FONT face="Times New Roman">#i nclude
<delay.h> </FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN
lang=EN-US><o:p><FONT
face="Times New Roman"> </FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN
lang=EN-US><o:p><FONT
face="Times New Roman"> </FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN
lang=EN-US><FONT face="Times New Roman">interrupt
[ANA_COMP] void anacomp_isr(void)</FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN
lang=EN-US><FONT face="Times New Roman">{<SPAN
style="mso-spacerun: yes">
</SPAN></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN
lang=EN-US><FONT face="Times New Roman"><SPAN
style="mso-spacerun: yes">
</SPAN>PORTB.0=0;</FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN
lang=EN-US><FONT face="Times New Roman"><SPAN
style="mso-spacerun: yes">
</SPAN>delay_ms(2000);</FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN
lang=EN-US><FONT face="Times New Roman">}
</FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN
lang=EN-US><o:p><FONT
face="Times New Roman"> </FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN
lang=EN-US><FONT face="Times New Roman">void
init(void)</FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN
lang=EN-US><FONT face="Times New Roman">{<SPAN
style="mso-spacerun: yes">
</SPAN></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN
lang=EN-US><FONT face="Times New Roman"><SPAN
style="mso-spacerun: yes">
</SPAN>PORTB=0x01;</FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN
lang=EN-US><FONT face="Times New Roman"><SPAN
style="mso-spacerun: yes">
</SPAN>DDRB=0x01;</FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN
lang=EN-US><FONT face="Times New Roman"><SPAN
style="mso-spacerun: yes">
</SPAN>ACSR|=1<<3;<SPAN
style="mso-spacerun: yes">
</SPAN></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN
lang=EN-US><FONT face="Times New Roman"><SPAN
style="mso-spacerun: yes">
</SPAN>#asm("sei")</FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN
lang=EN-US><FONT face="Times New Roman">}
</FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN
lang=EN-US><o:p><FONT
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -