| 数据搜索系统,热门电子元器件搜索 |
|
HT86B05 数据表(PDF) 38 Page - Holtek Semiconductor Inc |
|
|
|||||||||||||||||||||||||||||
HT86B05 数据表(HTML) 38 Page - Holtek Semiconductor Inc |
|
38 / 79 page ![]() HT86BXX/HT86BRXX Rev. 1.60 38 October 20, 2009 Prescaler All of the 8-bit timers possess a prescaler. Bits 0~2 of their associated timer control register, define the pre-scaling stages of the internal clock source of the Timer. The Timer overflow signal can be used to gener- ate signals for the Timer interrupt. Programming Considerations The internal system clock is used as the timer clock source and is therefore synchronized with the overall operation of the microcontroller. In this mode, when the appropriate timer register is full, the microcontroller will generate an internal interrupt signal directing the pro- gram flow to the respective internal interrupt vector. When the Timer is read, the clock is blocked to avoid er- rors, however as this may result in a counting error, this should be taken into account by the programmer. Care must be taken to ensure that the timers are properly ini- tialized before using them for the first time. The associ- ated timer enable bits in the interrupt control register must be properly set otherwise the internal interrupt associated with the timer will remain inactive. The edge select, timer mode and clock source control bits in timer control regis- ter must also be correctly set to ensure the timer is prop- erly configured for the required application. It is also important to ensure that an initial value is first loaded into the timer registers before the timer is switched on; this is because after power-on the initial values of the timer reg- isters are unknown. After the timer has been initialized the timer can be turned on and off by controlling the en- able bit in the timer control register. Timer Program Example The following example program section is based on the HT86B40, HT86B50, HT86B60, HT86BR60, HT86B70, HT86B80 and HT86B90 devices, which contain a single internal 16-bit timer. Programming the timer for other de- vices is conducted in a very similar way. The program shows how the timer registers are setup along with how the interrupts are enabled and managed. Points to note in the example are how, for the 16-bit timer, the low byte must be written first, this is because the 16-bit data will only be written into the actual timer register when the high byte is loaded. Also note how the timer is turned on by setting bit 4 of the respective timer control register. The timer can be turned off in a similar way by clearing the same bit. This example program sets the timer to be in the timer mode which uses the internal system clock as their clock source. #include HT86B40.inc jmp begin : org 04h ; external interrupt vectors reti org 08h reti org 0Ch reti org 10h ; timer 2 interrupt vector jmp tmr2int ; jump here when timer 2 overflows org 14h reti : ; internal timer 2 interrupt routine tmr2int: : ; timer 2 main program placed here : reti : begin: ; setup timer 2 registers mov a,09bh ; setup timer 2 low byte mov tmr2l,a ; low byte must be setup before high byte mov a,0e8h ; setup timer 2 high byte mov tmr2h,a ; setup timer 2 high byte mov a,090h ; setup timer 2 control register mov tmr2c,a ; setup timer mode ; setup interrupt register mov a,01h ; enable master interrupt mov intc,a mov a,01h ; enable timer 2 interrupt mov intch,a : |
|
链接网址 |
| ALLDATASHEET是否为您带来帮助? [ DONATE ] |
关于 Alldatasheet | 广告服务 | 联系我们 | 隐私政策 | 数据表链接 | 链接交换 | 制造商名单 All Rights Reserved©Alldatasheet.com |
| Russian : Alldatasheetru.com | Korean : Alldatasheet.co.kr | Spanish : Alldatasheet.es | French : Alldatasheet.fr | Italian : Alldatasheetit.com Portuguese : Alldatasheetpt.com | Polish : Alldatasheet.pl | Vietnamese : Alldatasheet.vn Indian : Alldatasheet.in | Mexican : Alldatasheet.com.mx | British : Alldatasheet.co.uk | New Zealand : Alldatasheet.co.nz |
|
Family Site : ic2ic.com |
icmetro.com |