⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pic42.htm

📁 pic单片机原理
💻 HTM
📖 第 1 页 / 共 2 页
字号:
                      </font>* <font face="宋体">复位定时器<br>
                      </font>* <font face="宋体">自振式看门狗</font>WDT.</font></span></p>
                    <p align="justify"><font size="2"><span class="lh15">2<font face="宋体">)指令周期:<br>
                      </font></span></font><span class="lh15"><font size="2">PIC16C54<font face="宋体">采用</font>8<font face="宋体">位宽的数据总线和</font>12<font face="宋体">位宽指令总线相互独立的哈佛</font>(Harvard)<font face="宋体">结构,与其它一些单片机相比,程序代码更加紧凑,指令执行速度更快。图(</font>2<font face="宋体">)</font> 
                      <font face="宋体">所示的是</font> <font face="宋体">时钟/指令时序图</font></font></span></p>
                    <p align="center"><font size="2"><font face="宋体"><img alt="wpe2.jpg (16690 字节)" src="image/newpag13.jpg" width="556" height="209"><br>
                      图</font>2</font></p>
                    <p align="justify"><font size="2">&nbsp;&nbsp;&nbsp; <font face="宋体"><span class="lh15">如图</span></font><span class="lh15">2<font face="宋体">所示,从引脚</font>OSC1<font face="宋体">输入或振荡电路产生的时钟信号在内部经四分频产生四个不重叠的时钟</font> 
                      Q1,Q2,Q3,Q4<font face="宋体">。程序计数器</font>PC<font face="宋体">在每个</font>Q1<font face="宋体">节拍间加</font>1<font face="宋体">,指令在</font>Q4<font face="宋体">节拍从程序存储器中取出并锁存于指令寄存器中,在下一指令周期被译码并执行。因此,在程序执行过程中,取指令与执行指令可重迭进行,即当一条指令被执行时,下一条指令已从程序存储器中读出。</font></span></font></p>
                    <p align="justify"><font size="2">3<font face="宋体">)引脚功能说明</font></font></p>
                    <p align="center"><font size="1"><img alt="wpe3.jpg (7164 字节)" src="image/newpag14.jpg" width="277" height="168"></font></p>
                    <p align="justify"><font size="1"><span class="lh15">RA0-R</span></font><span class="lh15"><font size="2">A3:<font face="宋体">可位控</font>4<font face="宋体">位双向</font>I/O<font face="宋体">口,输入为</font>TTL<font face="宋体">电平<br>
                      </font>RB0<font face="宋体">-</font>RB7<font face="宋体">:可位控</font>8<font face="宋体">位双向</font>I/O<font face="宋体">口,输入为</font>TTL<font face="宋体">电平<br>
                      </font>TOCKI<font face="宋体">:定时器/计数器</font>TMR0<font face="宋体">的外部触发计数信号输入端。软件定义</font>TMR0<font face="宋体">为计数器时,此引脚上的信号上升沿或下降沿用于计数,可通过软件设置</font>OPTION<font face="宋体">寄存器相应的控制位选择触发边沿,当</font>TMR0<font face="宋体">为内部时钟源时,该引脚当接</font>VDD<font face="宋体">或</font>VSS,<font face="宋体">以减少功耗。<br>
                      </font>MCLR:<font face="宋体">当为低电平时,单片机复位<br>
                      </font>VSS<font face="宋体">:地端<br>
                      </font>VDD<font face="宋体">:电源电压<br>
                      </font>OSC1<font face="宋体">:振荡信号输入端<br>
                      </font>OSC2<font face="宋体">:振荡信号输出端</font></font></span></p>
                    <p align="justify"><font face="宋体" size="3">二.应用实例</font></p>
                    <table cellpadding="0" cellspacing="0" border="0">
                      <tbody>
                        <tr> 
                          <td vAlign="top"> <p align="left" class="lh15">如图4所示,PIC16C54芯片处于睡眠状态,当任一按键按下,将唤醒PIC16C54进行键盘处理。本例中,按下SW1,点亮绿灯,按下SW2,点亮红灯。 
                              进入睡眠时,应将键扫描输出线SCAN1,SCAN2置为低电平,进入睡眠后,电容C被充分充电,使MCLR保持高电平。当有按键按下时,电容C经电阻R2或R3放电,其两端电压迅速下降(下降时间约为1ms),从而使MCLR下拉为低电平,进入复位。唤醒PIC16C54的复位时间(大约为18ms),也应更小于键按下的最小时间(大约为50-100ms)。 
                              每次扫描即SCAN1,SCAN2为低电平的时间大约为10ms,当键处理程序完成后,程序对键盘循环扫描直至键释放,然后将SCAN1,SCNA2输出置为低电平,单片机重新进入睡眠。图中所示的电阻R4-R8用来防止电容C放电产生的大电流,保护芯片。</p>
                            <p align="center"><font face="宋体" size="3"><img alt="wpe4.jpg (13020 字节)" src="image/newpag18.jpg" width="446" height="206"></font><br>
                              图4</p>
                            <p align="left" class="lh15">程序清单:</p>
                            <p align="left"><span class="lh15">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ORG 
                              0<br>
                              START &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CALL INIT_PORT_B 
                              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;初始化B口<br>
                              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                              CALL DELAY &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;延时<br>
                              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                              CALL SCAN_KEYS &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;键盘扫描<br>
                              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                              MOVWF GP &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;W-&gt;GP<br>
                              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                              BTFSC GP,SW1 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;按键SW1按下?<br>
                              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                              BCF PORTB,GRN_LED &nbsp;&nbsp;&nbsp;;点亮绿灯<br>
                              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                              BTFSC GP,SW2 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;按键SW2按下?<br>
                              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                              BCF PORTB,RED_LED &nbsp;&nbsp;&nbsp;;点亮红灯<br>
                              CHK_FOR_KEY &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CALL 
                              DELAY &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;延时<br>
                              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                              CALL SCAN_KEYS &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;键盘扫描<br>
                              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                              XORLW 0 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;键释放<br>
                              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                              GO TO CHK_FOR_KEY &nbsp;&nbsp;&nbsp;;继续扫描<br>
                              NO_KEY_PRESSED &nbsp;&nbsp;&nbsp;BCF PORTB,SCAN1 
                              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;置SCAN1为低电平<br>
                              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                              BCF PORTB,SCAN2 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;置SCAN2为低电平<br>
                              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                              SLEEP &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;睡眠<br>
                              </span> </p></td>
                          <td width="209" align="center"> <div align="center"><img alt="wpe6.jpg (20748 字节)" src="image/newpag16.jpg" width="209" height="822"><br>
                              图5</div></td>
                        </tr>
                      </tbody>
                    </table></td>
                </tr>
              </tbody>
            </table>
              </td>
        </tr>
      </table>
      <table width="700" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td width="20">&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
      </table>
      <table width="700" border="0" cellspacing="0" cellpadding="0">
        <tr bgcolor="#990000"> 
          <td height="1" width="634"></td>
        </tr>
        <tr align="right"> 
          <td height="6"></td>
        </tr>
        <tr align="right"> 
          <td><font color="#990000" size="2">[ <a href="index.htm">返回</a> ]</font> 
          </td>
        </tr>
        <tr>
          <td>&nbsp;</td>
        </tr>
        <tr> 
          <td>&nbsp;</td>
        </tr>
      </table></td>
  </tr>
</table> 
 
</body> 
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -