📄 mega8学习笔记(9)-------cocoguojia 原创--单片机实验室-----嘉哥.htm
字号:
lang=EN-US><FONT
face="Times New Roman">SS</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">SS</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 18pt; TEXT-INDENT: -18pt; mso-list: l1 level1 lfo1; tab-stops: list 18.0pt"><SPAN
lang=EN-US
style="mso-fareast-font-family: 'Times New Roman'"><SPAN
style="mso-list: Ignore"><FONT
face="Times New Roman">2、<SPAN
style="FONT: 7pt 'Times New Roman'">
</SPAN></FONT></SPAN></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">SPDR</FONT></SPAN></P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l1 level1 lfo1; tab-stops: list 18.0pt"><SPAN
lang=EN-US
style="mso-fareast-font-family: 'Times New Roman'"><SPAN
style="mso-list: Ignore"><FONT
face="Times New Roman">3、<SPAN
style="FONT: 7pt 'Times New Roman'">
</SPAN></FONT></SPAN></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">spi</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">
asm</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">sei</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">spi</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><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></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN
lang=EN-US><FONT
face="Times New Roman">1</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">SS</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 18pt; TEXT-INDENT: -18pt; mso-list: l1 level1 lfo1; tab-stops: list 18.0pt"><FONT
face="Times New Roman"><SPAN lang=EN-US
style="mso-fareast-font-family: 'Times New Roman'"><SPAN
style="mso-list: Ignore">4、<SPAN
style="FONT: 7pt 'Times New Roman'">
</SPAN></SPAN></SPAN><SPAN
lang=EN-US>2</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">SPDR</FONT></SPAN></P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo2; tab-stops: list 18.0pt"><SPAN
lang=EN-US
style="mso-fareast-font-family: 'Times New Roman'"><SPAN
style="mso-list: Ignore"><FONT
face="Times New Roman">3、<SPAN
style="FONT: 7pt 'Times New Roman'">
</SPAN></FONT></SPAN></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">SS</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">SS</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">4</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">spi</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">
asm</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">sei</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">spi</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">SPDR</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><FONT
face="Times New Roman"> </FONT></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">//</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">SPI</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">
10</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"> ,
</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">数码管是共阳的,</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">74hc164</FONT></SPAN></P></SPAN>
<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">//-------------------------------------------------<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">#i nclude
<mega8.h><SPAN
style="mso-spacerun: yes">
</SPAN>//</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">#i nclude
<delay.h><SPAN
style="mso-spacerun: yes">
</SPAN>//</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">
</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><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">//----------------------------------------------------------------------------------------------------</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><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><SPAN
lang=EN-US><SPAN style="mso-spacerun: yes"><FONT
face="Times New Roman">
</FONT></SPAN></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>0<SPAN
style="mso-spacerun: yes">
</SPAN>1<SPAN
style="mso-spacerun: yes">
</SPAN>2<SPAN
style="mso-spacerun: yes">
</SPAN>3<SPAN
style="mso-spacerun: yes">
</SPAN>4<SPAN
style="mso-spacerun: yes">
</SPAN>5<SPAN
style="mso-spacerun: yes">
</SPAN>6<SPAN
style="mso-spacerun: yes">
</SPAN>7<SPAN
style="mso-spacerun: yes">
</SPAN>8<SPAN
style="mso-spacerun: yes">
</SPAN>9<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">unsigned char
constsm_duan[10]={~0X<st1:chmetcnv w:st="on" TCSC="0"
NumberType="1" Negative="False" HasSpace="False"
SourceValue="3"
UnitName="F">3F</st1:chmetcnv>,~0X06,~0X5B,~0X<st1:chmetcnv
w:st="on" TCSC="0" NumberType="1" Negative="False"
HasSpace="False" SourceValue="4"
UnitName="F">4F</st1:chmetcnv>,~0X66,~0X6D,~0X7D,~0X07,~0X<st1:chmetcnv
w:st="on" TCSC="0" NumberType="1" Negative="False"
HasSpace="False" SourceValue="7"
UnitName="F">7F</st1:chmetcnv>,0X90};
//此行是由于博客格式的影响,其实这是上面一行的</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><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">//-------------------------------------------------<SPAN
style="mso-spacerun: yes">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -