The first button will be used to set the time delay (500ms for every push) and the second button will be used to start the timer sequence blinking. In this tutorial we will set two buttons as two inputs and 8 LED as 8 outputs. The time taken for the Timer register depends on the value of Prescaler and the value of the Fosc. The Fosc stands for Frequency of the Oscillator, it is the frequency of the Crystal used. This interrupt informs the MCU that this particular time has lapped. This interrupt is called as the Timer Interrupt. For example if the value of prescaler is 64, then for every 64 th pulse the Timer will be incremented by 1.Īs the timer increments and when it reaches to its maximum value of 255, it will trigger an interrupt and initialize itself to 0 back again. The range of the prescaler id is from 1 to 256 and the value of the Prescaler can be set using the OPTION Register (The same one that we used for pull up resistors). Prescaler is a name for the part of a microcontroller which divides oscillator clock before it will reach logic that increases timer status. As said earlier there are both the 8-bit and 16-bit Timers in our PIC MCU, the main difference between them is that the 16-bit Timer has much better Resolution that the 8-bit Timer. Now, let us see what each one really means. To start using a timer we should understand some of the fancy terms like 8-bit/16-bit timer, Prescaler, Timer interrupts and Focs. The Timer0 module timer/counter has the following features: Once we understand the Timer 0 it will be easy to work on Timer 1 and Timer 2 as well. In this tutorial we will be using the Timer 0 for our application. The Timer 0 and Timer 2 are 8-bit Timers and Timer 1 is a 16-bit Timer. They are names as Timer0, Timer1 and Timer2. The PIC16F877A PIC MCU has three Timer Modules. Physically, timer is a register whose value is continually increasing to 255, and then it starts all over again: 0, 1, 2, 3, 4…255….0, 1, 2, 3……etc. The maximum delay that can be used is based on Crystal oscillator used. Larger values of delays cannot be created using macros, example a delay of half hour cannot be created by delay macros.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |