1 / 17

Microprocessor and Microcontroller Based Systems

بسم الله الرحمن الرحيم. The Islamic University of Gaza Faculty of Engineering Electrical Engineering Department. Microprocessor and Microcontroller Based Systems. EELE4315 — Fall 2010. Instructor: Eng.Moayed N. EL Mobaied. Lecture 13. Free-run timer TMR0.

gamma
Télécharger la présentation

Microprocessor and Microcontroller Based Systems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. بسم الله الرحمن الرحيم The Islamic University of Gaza Faculty of Engineering Electrical Engineering Department Microprocessor and Microcontroller Based Systems EELE4315 — Fall 2010 Instructor: Eng.Moayed N. EL Mobaied Lecture 13

  2. Free-run timer TMR0 Timer Review Timers are usually most complicated parts of a microcontroller, so it is necessary to set aside more time for their explaining. With their application it is possible to create relations between a real dimension such as "time" and a variable which represents status of a timer within a microcontroller. 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.

  3. Free-run timer TMR0

  4. Free-run timer TMR0 Timer Review PIC16F84 has an 8-bit timer. Number of bits determines what value timer counts to before starting to count from zero again. In the case of an 8-bit timer, that number is 256. Prescaler is a name for the part of a microcontroller which divides oscillator clock before it will reach logic that increases timer status.

  5. Free-run timer TMR0 Timer Review Number which divides a clock is defined through first three bits in OPTION register. The highest divisor is 256. This actually means that only at every 256th clock, timer value would increase by one. This provides us with the ability to measure longer timer periods.

  6. Free-run timer TMR0

  7. Free-run timer TMR0

  8. Free-run timer TMR0

  9. Free-run timer TMR0 Timer Review After each count up to 255, timer resets its value to zero and starts with a new cycle of counting to 255. During each transition from 255 to zero, T0IF bit in INTCOM register is set. If interrupts are allowed to occur, this can be taken advantage of in generating interrupts and in processing interrupt routine. It is up to programmer to reset T0IF bit in interrupt routine, so that new interrupt, or new overflow could be detected.

  10. Free-run timer TMR0 Timer Review Beside the internal oscillator clock, timer status can also be increased by the external clock on RA4/TOCKI pin. Choosing one of these two options is done in OPTION register through T0CS bit. If this option of external clock was selected, it would be possible to define the edge of a signal (rising or falling), on which timer would increase its value.

  11. Free-run timer TMR0

  12. Free-run timer TMR0

  13. Free-run timer TMR0 Timer Review Prescaler can be assigned either timer TMR0 or a watchdog. Watchdog is a mechanism which microcontroller uses to defend itself against programs getting stuck. microcontroller also has program where problems can occur as well. When this happens, microcontroller will stop working and will remain in that state until someone resets it. Because of this, watchdog mechanism has been introduced. After a certain period of time, watchdog resets the microcontroller.

  14. Free-run timer TMR0 Prescaler is accorded to timer TMR0, or to watchdog timer trough PSA bit in OPTION register. By clearing PSA bit, prescaler will be accorded to timer TMR0. When prescaler is accorded to timer TMR0, all instructions of writing to TMR0 register (CLRF TMR0, MOVWF TMR0, BSF TMR0,...) will clear prescaler. When prescaler is assigned to a watchdog timer, only CLRWDT instruction will clear a prescaler and watchdog timer at the same time .

  15. Free-run timer TMR0 Prescaler change is completely under programmer's control, and can be changed while program is running. There is only one prescaler and one timer. Depending on the needs, they are assigned either to timer TMR0 or to a watchdog.

  16. Free-run timer TMR0

  17. Prescaler

More Related