TH1=TL1= -(FOSC/12/32/BAUD)那个负号啥意思哦?一直这样用但是都...

2020-01-26 12:52发布

void InitUart()
{
        SCON = 0x5a;                        
        TMOD |= 0x20;                       
    TH1 = TL1 = -(FOSC/12/32/BAUD);   
    TR1 = 1;                           
}
一直都这样用  但是不知道啥意思哦
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
15条回答
millwood0
2020-01-27 20:40
  1. TH1 = TL1 = -(FOSC/12/32/BAUD);
复制代码you can think of an incrementing timer as one that starts from a negative number and generates an interrupt when it reaches 0.

The code above essentially does that and it is fairly common for such code.

However,
  1. TH1 = TL1 = -...
复制代码is almost surely wrong.

The typical implementation is this:
  1. TH1 = -(FOSC/12/32/BAUD) >> 8;
  2. TL1 = -(FOSC/12/32/BAUD);
复制代码or, in case you have TH1:TL1 next to each other and in the right order:
  1. T1 = -(...);
复制代码ADCs frequently allow that.

一周热门 更多>