zoukankan      html  css  js  c++  java
  • [Keil51]51单片机定时器的方式0使用注意

    当 51单片机工作模式寄存器 设置为

        TMOD.M1M0 = 00  工作方式0 

        TMOD.C/T = 0 定时工作模式

    定时器/计数器0 将工作在 13bit 定时器模式。。

    与想当然的 13 bit = 5bit(TH0 ) + 8bit (TL0)的搞法不同的是。。(谁让你不看规格)

    13bit = 8bit(TH0) + 5bit(TL0)  

    TL0的高三位没有用到。。

    假设定时器工作频率为2M,那么中断服务程序定长1ms的写法应该是。。

     1 /*
     2  *  @Func: void TIMER0_IRQHandler(void) interrupt 1
     3  *  @Usage: timer0 interrupt sevices routine
     4  *  @parameter: none
     5  *  @retval:  none
     6  *  @version: 2013-03-07 11:37:50
     7  * */
     8 void TIMER0_IRQHandler(void) interrupt 1{
     9     
    10     TH0 =(8192 - 2*1000)/32;
    11     TL0 =(8192 - 2*1000)%32;
    12 
    13          // do what you need to do 
    14          return;          
    15 }
  • 相关阅读:
    bzoj 1084: [SCOI2005]最大子矩阵
    Python之深浅拷贝
    2,版本控制git --分支
    1,版本控制git--仓库管理
    python-openpyxl操作excel
    ansible-3
    ansible-2
    ansible-1
    celery
    6,MongoDB 之 Array Object 的特殊操作
  • 原文地址:https://www.cnblogs.com/alimy/p/2947740.html
Copyright © 2011-2022 走看看