📄 mega8学习笔记(10_1)-------cocoguojia 原创--单片机实验室-----嘉哥.htm
字号:
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">i<st1:chmetcnv
w:st="on" UnitName="C" SourceValue="2" HasSpace="False"
Negative="False" NumberType="1"
TCSC="0">2c</st1:chmetcnv></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">TWI</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><SPAN
lang=EN-US><FONT face="Times New Roman">i<st1:chmetcnv
w:st="on" UnitName="C" SourceValue="2" HasSpace="False"
Negative="False" NumberType="1"
TCSC="0">2c</st1:chmetcnv></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
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">P162</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">P163</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">TWI</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的部分可先不看。P269
P270看看利用系统i2c函数的例子,仔细推敲一下,其实利用系统函数,i2c程序可以编写的
再严密或者说抗干扰强的 程序。我写的程序只起抛砖引玉的作用。</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">I<st1:chmetcnv
w:st="on" UnitName="C" SourceValue="2" HasSpace="False"
Negative="False" NumberType="1"
TCSC="0">2C</st1:chmetcnv></FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">原理的资料看看,<st1:PersonName
w:st="on"
ProductID="马潮">马潮</st1:PersonName>老师写的</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><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><FONT face="Times New Roman">i<st1:chmetcnv
w:st="on" UnitName="C" SourceValue="2" HasSpace="False"
Negative="False" NumberType="1"
TCSC="0">2c</st1:chmetcnv></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<st1:chmetcnv
w:st="on" UnitName="C" SourceValue="2" HasSpace="False"
Negative="False" NumberType="1"
TCSC="0">2c</st1:chmetcnv></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">
scl</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">sda</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">----------i<st1:chmetcnv
w:st="on" UnitName="C" SourceValue="2" HasSpace="False"
Negative="False" NumberType="1"
TCSC="0">2c</st1:chmetcnv></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><SPAN
lang=EN-US><FONT
face="Times New Roman">sda</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">scl</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">4K7
</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">10K</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">mega8
IO</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">sda</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">IO</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><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'">
在Mega8学习笔记(10.1)里我会用采用<SPAN lang=EN-US><FONT
face="Times New Roman">CVAVR</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">I<st1:chmetcnv
w:st="on" UnitName="C" SourceValue="2" HasSpace="False"
Negative="False" NumberType="1"
TCSC="0">2C</st1:chmetcnv></FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">系统函数</SPAN>写24C02</SPAN></P></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'">
在Mega8学习笔记(10.2)里我会用像51单片机那样写24C02的方法来写i2c</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'">
在Mega8学习笔记(10.3)里我会用avr单片机独特的方式写24C02</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'">以上三种方法均是IO口模拟I2C</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN
lang=EN-US><FONT
face="Times New Roman">//</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</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=0X55</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><FONT
face="Times New Roman">//</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">0x05</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">0x55</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">0x55</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</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><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
face=宋体>采用</FONT><SPAN lang=EN-US><FONT
face="Times New Roman">CVAVR</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">I<st1:chmetcnv
w:st="on" UnitName="C" SourceValue="2" HasSpace="False"
Negative="False" NumberType="1"
TCSC="0">2C</st1:chmetcnv></FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">系统函数</SPAN></FONT></o:p></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><FONT face="Times New Roman">Chip type<SPAN
style="mso-spacerun: yes">
</SPAN>: ATmega<st1:chmetcnv w:st="on" UnitName="l"
SourceValue="8" HasSpace="False" Negative="False"
NumberType="1"
TCSC="0">8L</st1:chmetcnv></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN
lang=EN-US><FONT face="Times New Roman">Program
type<SPAN
style="mso-spacerun: yes">
</SPAN>: Application </FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN
lang=EN-US><FONT face="Times New Roman">IDWE<SPAN
style="mso-spacerun: yes">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -