Unit 2 Timer - CIP51 - Calculations
Unit 2 Timer - CIP51 - Calculations
TIMERS
Link: https://www.youtube.com/watch?v=kaCOTQwo7KY
• Timers are used for: interval timing, event counting or baud rate generation
• In interval timing applications, a timer is programmed to overflow at a regular interval
and the following:
• Set the timer overflow flag or
• Generate an interrupt
• This can also be used to generate waveforms at set frequencies
• Event counting is used to determine the number of occurrences of an event, rather than to
measure the elapsed time between events. In this case, the timer functions as a counter.
• An “event” is any external stimulus that provides a high-to-low transition at the
selected input pin
• The timers can also function as the baud rate generators for the C8051F340’s internal
serial ports (UART0 and UART1)
• “Baud rate” is the bit rate of the serial port
(the time period of a bit)
C8051F340 TIMERS
• C8051F340 has four counter/timers: Timer 0, Timer 1, Timer 2 and Timer 3
• Timer 0 and Timer 1 are nearly identical and have four primary modes of operation.
• Timer 2 and Timer 3 offer 16-bit and split 8-bit timer functionality with auto-reload.
Timer/ Counter Registers
Description Register Function
Name
Timer Control TCON Enables and disables Timer0 and Timer1, Also has overflow
Register flag and interrupt related bits
Timer Mode TMOD Selects the timer or counter operation with C/T0 and C/T1
Register bits, Also has mode selection for timer0 and timer1
Clock Control CKCON Controls clock supplied to timer0 and timer 1 if configured
to use prescaled clock inputs, or system clock
0 0 0 0 0 0 0 1