Self study Timer0 assessment intro - PowerPoint PPT Presentation

1 / 10
About This Presentation
Title:

Self study Timer0 assessment intro

Description:

... for the mid-range MCU Family. Section 11= study 11.1, 11.2, ... Not the Watch dog mode or counter mode. Registers/Bits. TMR0. T0CS. PSA. T0IF flag. Prescaler ... – PowerPoint PPT presentation

Number of Views:22
Avg rating:3.0/5.0
Slides: 11
Provided by: leeu9
Category:

less

Transcript and Presenter's Notes

Title: Self study Timer0 assessment intro


1
Self study Timer0 assessment intro
  • Explain in detail how to use Timer0 module as
    timer.

2
What you need to know?
  • At least
  • Reference Manuals for the mid-range MCU
    FamilySection 11gt study 11.1, 11.2, 11.3, 11.6,
  • Data sheet PIC16F684gtstudy 5 until 5.1.2
    includedYou are using the C-language, so it is
    not necessary to understand the macro instruction
    in detail.

3
At the least the next topics
  • fig 11.6 (sheet 4)
  • Limitation
  • Only the timer mode
  • Not the Watch dog mode or counter mode
  • Registers/Bits
  • TMR0
  • T0CS
  • PSA
  • T0IF flag
  • Prescaler
  • Range of delays
  • Code snip example (1) and (2) (sheet 5 and 6)

4
From Reference Manuals for the mid-range MCU
Family (document 33023a)
5
Example (1) code snip polling of the T0IF flag
register
  • /
  • Example of polling the T0IF flag (on overflow)
  • A delay of multi 0.256 msec
  • param uns8 multi lt0xFF
  • /
  • void delayPolling(uns8 multi)
  • TMR00 //clear timer
  • T0CS0 //OPTION_REG.5 see data sheet
  • PSA 0 //OPTION_REG.3 see data sheet
  • OPTION_REG 0b.1111.1000 //bit 2-0 prescaler
    ???
  • OPTION_REG 0b.0000.0111 //bit 2-0 prescaler
    ???
  • //prescaler 1256, Fosc/4 1 MHzgt
    3906 KHzgt 0.256 msec
  • TMR0 255-multi1 //Explane!
  • T0IF0 //clear overflow flag
  • while (T0IF!1)/wait loop/ T0IF0

6
Example (2) code snip polling of the TMR0
register
  • /
  • A delay of milliSec msec
  • param uns16 milliSec
  • CC5X compiler C notation
  • /
  • void delay(uns16 milliSec)
  • uns8 next0 //next is a cyclic counter
    (0-255)
  • TMR0 0 //clear timer
  • T0CS 0 //OPTION_REG.5, see data sheet
  • PSA 0 //OPTION_REG.3, see data sheet
  • OPTION_REG 0b.1111.1000 //bit 2-0 prescaler
  • OPTION_REG 0b.0000.0010 //bit 2-0 prescaler
  • //result prescaler 18 4MhzFosc gt
    125 kHzgt 8 micro sec
  • TMR01 //compensation for 2 instructions see
    data sheet
  • do
  • next 125 //8125gt 1 msec
  • while (TMR0 ! next) /wait loop/
  • milliSec-1

7
(No Transcript)
8
(No Transcript)
9
(No Transcript)
10
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com