
Prescaler value is written to TMR0 register.
The prescaler is activated by bit PSA. The prescaler is a circuit that divides the signal frequency by 2, 4, 8, 16, …, 256. In some cases, the clock coming from the oscillator could be too fast for our applications: we can lower it by using the frequency prescaler. The clock source can be internal or external and is controlled by T0CS bit. T0CON (Timer 0 Control) register is used to program the timer and includes the bits shown in figure (T0CS, PSA etc.). All the parts to the left are the clock source circuits. The Timer 0 stores the value TMR0 registers. Timer 0 can be operated both as a timer and counter. Reading PORT B will end the mismatch condition and allow the bit to be cleared(must be cleared in software)Ġ-None of the RB7 – RB4 pins have changed state. INTF (RB0/INT External Interrupt Flag Bit)ġ-RB0/INT External interrupt occurred(must be cleared in software))Ġ-RB0/INT External interrupt did not occurġ-At least one of the RB7 – RB4 pins changed state a mismatch condition will continue to set line bit. TMR0IF (TMR0 Overflow Interrupt Flag bit)ġ-TMR0 register has overflowed (must be cleared in software) RBIE(RB Port Change Interrupt Enable Bit) INTE (RB0/INT External Interrupt Enable Bit)Ġ-Disables the RB0/INT external interrupt TMR0IE (TMR0 Overflow Interrupt Enable bit) Structure of INTCON :ġ-Enables all unmasked peripheral interrupts Prescaler is not accessible but can be configured using PS2:PS0 bits of OPTION_REG. This register contains the Timer0 overflow flag(TMR0IF) and corresponding Interrupt Enable flag(TMR0IE).Ġ-Internal instruction cycle clock (CLKO)ġ-Increment on high-to-low transition on T0CKI pinĠ-Increment on low-to-high transition on T0CKI pin This register will hold the count value.When this register overflows (FF to 00) then an interrupt will be generated. This registers is used to configure the TIMER0 Prescalar, Clock Source etc The below table shows the registers associated with PIC16f877A Timer 0 module. Timer 0 has a register called TMR0 Register, which is 8 bits of size. Interrupt on overflow from 0XFF to 0X00.
#Back to work timer software
Build 8-bit software programmable prescaler.The main features of Timer 0 is given below: Now, we have to learn deeper about these three Timer Modules.
These modules help to perform various timer, Counter or PWM Generation. These three-timer modules as named as TIMER 0, TIMER 1 and TIMER 2. These timer module terminals are also multiplexed with other functions for handling alternate functions. The PIC16F877A basically has three timer modules. It allows the timer to be clocked at the rate a user desires. Prescaler: Prescaler is a block that presents inside the timer module and it is used to divide the clock frequency by a constant. Once it reaches the max value, it will roll back to zero setting up an Overflow flag and generates the interrupt if enabled. The timer is nothing but a simple binary counter that can be configured to count clock pulses(Internal/External). The digital cycles counted by the timer can be supplied internally through the peripheral clock or externally through a crystal, in this article we will look into the details of pic16f877a timer with examples. The timer is used to count cycles and perform a particular action at a specified moment or optionally start an interrupt cycle. It maintains the timing of operation in sync with a system clock or an external clock. It is an important application in an embedded system. The Timer is used to measure the time or generate an accurate time delay.