Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/30/00 21:14
Read: times


 
#2942 - RE: 8051 Timer 1 interrupt
(someone should sanity check this for me - I didn't verify anything)

The number of "ticks" is:
16Mhz / 12 / (250us)^-1 = 333.3 = 014Dh
that will trigger an interrupt every 249.75 us

However, the value you need to load into T1 is a number that will create an overflow in 014Dh ticks. If you have a 16 bit counter, you would use:
10000h - 014Dh = 0FEB3h

Now you need to consider which timer / counter operation mode you'll use.

Mode 3: 8 bit counter - can not use
Mode 2: 8 bit counter - can not use*
Mode 1: 16 bit counter - can use
Mode 0: 13 bit counter - can use

* Mode 2 would be best because it automatically reloads, but your count value excceds its 8 bit counter. You could load Mode 2 counter with 125us value and ignore every other interrupt for 250us effective rate. When the interrupt fires, toggle a memory bit and if high (or low) return from interrupt else process your 250us interrupt routine. The tick value of 333.33 woul be rounded to 334 (a multiple of 2) for a tick rate of 167 decimal = 0A7h. The counter value would be 0100h - 0A7h = 059h.

Mode 1 & 0 could be used but you have to reload the counter before it will
start again. This might mean that the 250us delay is stretched by the amount
of time the interrupt routine takes to reload the timer (value can be adjusted but remember higher level interrupts). In some applications, that is ok... in other applications, that is a problem.

-Jay C. Box

List of 3 messages in thread
TopicAuthorDate
8051 Timer 1 interrupt            01/01/70 00:00      
RE: 8051 Timer 1 interrupt            01/01/70 00:00      
RE: 8051 Timer 1 interrupt            01/01/70 00:00      

Back to Subject List