Control Read Timer Status | Controller Circuit

Saturday, January 8, 2011

Control Read Timer Status

Reads status timer there are two ways. First with reading actual price 16 bits from timer, and second is detect does timer meet condition of overflow. If timer applied is timer mode 8-bit, read of enough actual price easy. Read the price of 1 the byte and finish.



But if timer applied is mode 13 bits or 16 bits, problem becomes more complex. What if actual price of low byte is 255 and read of high byte is 15. At cost ought to be high byte 14 and low byte is 255, because when reading low byte 255, a few moments then high byte will increase one when read, so that read becomes slips 256 calculations because laying in high byte.



The resolving is with reading high byte beforehand and then reads low byte. Then high byte is read again and then is compared to read initial, if differing, hence used is read of high byte that is first.



Sometime that is need to be known only when timer reset becomes null. Equally, insignificant how is much actual prices from timer, but when timer overflow and back is become null. When overflow, microcontroller automatically bit doormat TFx in register TCON. This means checking of enough overflows by checked does bit TFx set or no. In this way can made program to determine tubing definitive. From solution before all, known that to get tubing 0,05 seconds is required chopper until 46. 079 times. Usage of this mode initialization timer would with the price of difference between 65. 535 and 46. 079, that is 19. 457. So 46. 079 the next counter after 19. 457 will cause timer overflow.



Segment of Program Example of Timer

MOV TH0, #76 ; (76X256 = 19.456)

MOV TL0, #01 ; (19.456 + 1 = 19.457)

MOV TMOD, #01 ; Timer 0 Mode 16-bit

SETB TR0 ; Start Timer 0

JNB TF0, $ ; Loop to overflow

No comments:

Post a Comment