r8c peripherals 1

Upload: bhushan-pawar

Post on 03-Jun-2018

226 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/12/2019 R8C Peripherals 1

    1/38

    2009, Renesas Technology America, Inc., All Rights Reserved1

    Course Introduction

    Purpose

    This course provides an introduction to the peripheral functions built

    into R8C Tiny series microcontrollers (MCUs).

    Objective Learn about the features and operation of the

    TimerRA, TimerRB, TimerRC, TimerRD and TimerRE functions.

    Understand the basics of the Watchdog Timer.

    Discover how the Power-on Reset (POR) andLow-Voltage Detect (LVD) functions operate.

    Content

    33 pages

    6 questions

    Learning Time

    35 minutes

  • 8/12/2019 R8C Peripherals 1

    2/38

    2009, Renesas Technology America, Inc., All Rights Reserved2

    Versatile Set of Timers

    Timer RA Timer RB Timer RC Timer RD Timer RETimer structure 8 bit 8-bit 16 bit 2 x 16 bit 4 bit + 8 bit

    Prescaler 8 bit 8 bit - - -

    Timer Mode Yes Yes Yes Yes -

    Pulse Output Mode Yes - - - -

    Event Counter Mode Yes - - - -Pulse Width

    Measurement ModeYes - - - -

    Pulse Period

    Measurement ModeYes - - - -

    Programmable

    Waveform

    Generation Mode

    - Yes Yes, 2 PWMmodes

    Yes, 4 PWMmodes

    -

    Programmable

    One-Shot

    Generation Mode

    - Yes - - -

    Programmable WaitOne-Shot Generation

    Mode

    - Yes - - -

    Input Capture Mode - - Yes Yes -

    Output Compare Mode - - Yes Yes Yes

    Real Time Clock Mode - - - - Yes

    The Watchdog Timeris covered separately in this course.

  • 8/12/2019 R8C Peripherals 1

    3/38

    PROPERTIES

    On passing, 'Finish' button: Goes to Next Slide

    On failing, 'Finish' button: Goes to SlideAllow user to leave quiz: At any time

    User may view slides after quiz: After passing quiz

    User may attempt quiz: Unlimited times

  • 8/12/2019 R8C Peripherals 1

    4/38 2009, Renesas Technology America, Inc., All Rights Reserved

    4

    Which of the following timers on the R8C family is 16bit ?Click Done when you are finished.

    Timer RA

    Timer RBB

    Done Reset ShowSolution

    A

    C Timer RC

    Question

    Timer RED

  • 8/12/2019 R8C Peripherals 1

    5/38 2009, Renesas Technology America, Inc., All Rights Reserved

    5

    Timer RA

  • 8/12/2019 R8C Peripherals 1

    6/38

    2009, Renesas Technology America, Inc., All Rights Reserved6

    Timer RB

  • 8/12/2019 R8C Peripherals 1

    7/38

    2009, Renesas Technology America, Inc., All Rights Reserved7

    Timer RC

  • 8/12/2019 R8C Peripherals 1

    8/38

    2009, Renesas Technology America, Inc., All Rights Reserved8

    Timer RD

  • 8/12/2019 R8C Peripherals 1

    9/38

    2009, Renesas Technology America, Inc., All Rights Reserved9

    Timer RE

  • 8/12/2019 R8C Peripherals 1

    10/38

    2009, Renesas Technology America, Inc., All Rights Reserved10

    FFFF

    Timer Mode

    FF

    Reload register Reload register

    FF

    210

    Count Start flag

    TRAPRE Pre-scaler TRA Counter

    Timer RA

    Interruptf2fOCOf8

    f1

    Count Source

    The timer counts an internally generated count source.

    Operation: When the timer underflows, it reloads the register contents before continuing to count.

    1 0 110 01 2

    00h

    Timer RA Mode registerTimer RA Mode Register is used to put Timer RA into the

    Timer Mode and start/stop the counting.08h

    0

    1 2

    Example: Timer RA

  • 8/12/2019 R8C Peripherals 1

    11/38

    2009, Renesas Technology America, Inc., All Rights Reserved11

    Pulse Output Mode

    1

    Reload register Reload register

    2

    20

    Count Start flag

    TRAPRE Pre-scaler TRA Counter f2

    fOCOf8

    f1

    Count Source

    1

    Toggle flip-flop

    Q

    Q

    CK 01

    TMOD bits

    The timer counts an internally generated count source, the TRAO pin outputs a pulse whose polarity is inverted whenthe timer underflows.

    Operation: When the timer underflows, it reloads the register contents before continuing to count.

    TRAO

    1

    Example: Timer RA

  • 8/12/2019 R8C Peripherals 1

    12/38

    2009, Renesas Technology America, Inc., All Rights Reserved12

    Pulse Output Mode: Timer RA Example

    1

    Reload Register Reload Register

    2

    20

    Count Start Flag

    PREX register TX register f2

    fOCOf8

    f1

    Count Source

    1

    Toggle flip-flop

    Q

    Q

    CK 01

    TMOD bits

    The timer counts an internally generated count source, the TRAO pin outputs a pulse whose polarity is inverted when the timer underflows.

    Operation: When the timer underflows, it reloads the register contents before continuing to count.

    CNTR0

    1

  • 8/12/2019 R8C Peripherals 1

    13/38

    PROPERTIES

    On passing, 'Finish' button: Goes to Next Slide

    On failing, 'Finish' button: Goes to Next SlideAllow user to leave quiz: After user has completed quiz

    User may view slides after quiz: At any time

    User may attempt quiz: Unlimited times

  • 8/12/2019 R8C Peripherals 1

    14/38

    2009, Renesas Technology America, Inc., All Rights Reserved14

    Question

    Is the following statement true or false?

    Click Done when you are finished.

    The functionality of the Pulse Output Mode is exactly the same

    as in Timer mode, except a pulse is output on the TRAO pin.

    True

    False

    Done

  • 8/12/2019 R8C Peripherals 1

    15/38

    2009, Renesas Technology America, Inc., All Rights Reserved15

    Generate Complementary Outputs

    1

    Reload register Reload register

    2

    20

    Count Start flag

    TRAPRE Pre-scaler TRA Counter f2

    fOCO

    f8

    f1

    Count Source

    1

    Toggle flip-flop

    Q

    Q

    CK 01

    TMOD bits

    1

    TRAIO

    TRAO

    TRAIO has the option to be a port pin or an inverted output of TRAO

    1

    Example: Timer RA

  • 8/12/2019 R8C Peripherals 1

    16/38

    2009, Renesas Technology America, Inc., All Rights Reserved16

    Event Counter Mode

    FF

    Reload register Reload register

    FF

    FFFF0

    Count Start Flag

    TRAPRE Pre-scaler TRA Counter

    External

    Count Source

    1TRAIO

    Timer RA Mode register

    00h02h

    0

    0

    2

    2

    0Ah

    102 Timer RAInterrupt

    Example: Timer RA

    The timer counts an external signal fed to TRAIO pin.

    Operation: When the timer underflows, it reloads the register contents before continuing to count.

    Timer RA Mode Register is use to put Timer RA into Event

    Counter Mode, selects the active edge of the count Source,and starts/stops the counter.

  • 8/12/2019 R8C Peripherals 1

    17/38

    2009, Renesas Technology America, Inc., All Rights Reserved17

    Pulse Width Measurement Mode

    0

    Reload register Reload register

    5

    500

    Count Start flag

    TRAPRE Pre-scaler TRA Counter

    f2

    f32

    f8

    f1

    1

    TRAIO

    Timer RAInterrupt

    TRAIO pin

    IR bit in TRAICregister

    Count Stop Count Stop

    The timer measures the pulse width of an external signal fed into the TRAIO pin.

    TUNDF bit inTRACR register

    Timer Underflow

    Count Source

    Example: Timer RA

  • 8/12/2019 R8C Peripherals 1

    18/38

    2009, Renesas Technology America, Inc., All Rights Reserved18

    Pulse Period Measurement Mode: Timer RA

    TRAIO pin

    Underflow

    signal of

    prescaler

    TRA

    contents 0F 0E 0D 0F 0E 0D 0C 0B 0A 09 0F 0E

    0F 0E 0D

    Timer RA

    interrupt

    Timer RA active

    Edge detected

    ( TEGDF bit)

    0B 0A 09

    00 0F

    00 0F

    Timer RAunderflow

    (TUNDF bit)

    Contents of readout buffer

    Timer RA

    reloads

    Timer RA

    read

    Timer RA

    read

    Cleared to 0 by program

    Period being measured

    Timer RA

    reloads

  • 8/12/2019 R8C Peripherals 1

    19/38

    2009, Renesas Technology America, Inc., All Rights Reserved19

    Programmable Waveform Gen. Mode

    FF

    Reload register TRBSC register

    FF

    1FF0

    Count Start flag

    TRBPRE Pre-scaler Timer RB Counter f2

    TRA UNF

    f8

    f1

    Count Source

    1

    Toggle flip-flop

    Q

    Q

    CK

    01

    TMOD bits

    FF

    TRBPR register

    TRBO

    P3_1 bit

    021010210FF

    Primary period Primary periodSecondary period

    A signal is output from the TRBO pin which is inverted each time the counter underflows, it reloads the contents of primary reload

    register and secondary reload register alternately before continuing to count.

    0

    0

    2 1

    102101

    Example: Timer RB

  • 8/12/2019 R8C Peripherals 1

    20/38

  • 8/12/2019 R8C Peripherals 1

    21/38

    PROPERTIES

    On passing, 'Finish' button: Goes to Next Slide

    On failing, 'Finish' button: Goes to Next SlideAllow user to leave quiz: After user has completed quiz

    User may view slides after quiz: At any time

    User may attempt quiz: Unlimited times

  • 8/12/2019 R8C Peripherals 1

    22/38

    2009, Renesas Technology America, Inc., All Rights Reserved22

    BE

    Done ResetShow

    Solution

    A

    C

    C

    B

    A

    D

    The input that the timer counts is an externalsignal that is fed into the MCU through the

    TRAIO pin.

    When a trigger occurs, the timer starts

    operating once for a given period.

    After the Count Start bit has been set, the timerwaits for a high signal on the TRAIO pin.E

    D A signal is output from the TRBO pin and isinverted each time the counter underflows.

    Question

    Event Counter Mode

    Pulse Width Measurement Mode

    Pulse Period Measurement Mode

    Programmable WaveformGenerator Mode

    Programmable One-ShotGenerator Mode

    Match each timer mode to its function by dragging the letterson the left to their appropriate locations on the right.Click Done when you are finished.

    If an underflow occurs while the timer is

    counting, the TUNDF bit goes high so that theunderflow can be taken into account.

  • 8/12/2019 R8C Peripherals 1

    23/38

    2009, Renesas Technology America, Inc., All Rights Reserved23

    Generating a Precise Pulse Width

    01 00 01Contents of

    TRA

    TSTART bit in

    TRACR register

    Output of TRAO

    out pin

    Pre-scaler RA

    underflow signal

    Count Source

    IR bit in TRAIC

    register

    CountStarts

    Waveform

    Output Starts

    Waveform

    Output ends

    Timer RA

    primaryreloads

    Set to 1 by program

    Set to 0 by program

  • 8/12/2019 R8C Peripherals 1

    24/38

    2009, Renesas Technology America, Inc., All Rights Reserved24

    Programmable Wait One Shot Generation Mode: Timer RB

    In this mode, upon program or external trigger input, the device outputs the one-shot pulse from the TRBO pin after waiting for a given length of time.

    When a trigger occurs, the timer starts outputting a pulse for a given length of time equal to the set value in the TRBSC register. This is only after

    waiting for the TRBPR register to overflow.

    01 00 02

    Count Source

    Timer RB One

    Shot bit

    Contents of

    TRBPR

    Prescaler RB

    underflow signal

    Interrupt

    Request bit in

    Timer RB

    Interrupt Control

    register

    TRBO out pin

    01 00 01

    Set to 1 by program, or set to 1 by

    INT0 pin input trigger

    Set to 0 when counting

    completed

    Count

    Starts

    Timer RB secondary

    reloads

    Timer RB primary

    reloads

    Waveform output starts

    Waveform output end

    Wait starts

  • 8/12/2019 R8C Peripherals 1

    25/38

    2009, Renesas Technology America, Inc., All Rights Reserved25

    Input Capture Mode

  • 8/12/2019 R8C Peripherals 1

    26/38

    2009, Renesas Technology America, Inc., All Rights Reserved26

    TimerRC Timer Mode Output Compare

    Ti RC PWM M d

  • 8/12/2019 R8C Peripherals 1

    27/38

    2009, Renesas Technology America, Inc., All Rights Reserved27

    TimerRC PWM Mode

  • 8/12/2019 R8C Peripherals 1

    28/38

    2009, Renesas Technology America, Inc., All Rights Reserved28

    TimerRD Complementary PWM Mode

  • 8/12/2019 R8C Peripherals 1

    29/38

    2009, Renesas Technology America, Inc., All Rights Reserved29

    TimerRD Complementary PWM Mode

  • 8/12/2019 R8C Peripherals 1

    30/38

    PROPERTIES

    On passing, 'Finish' button: Goes to Next Slide

    On failing, 'Finish' button: Goes to Next SlideAllow user to leave quiz: After user has completed quiz

    User may view slides after quiz: At any time

    User may attempt quiz: Unlimited times

  • 8/12/2019 R8C Peripherals 1

    31/38

  • 8/12/2019 R8C Peripherals 1

    32/38

    2009, Renesas Technology America, Inc., All Rights Reserved32

    Watchdog Timer

    1/16

    1/128

    WatchdogTimer InterruptRequest

    WatchdogTimer Reset

    PM12 = 0

    PM12 = 1

    WDC7 = 0

    WDC7 = 1

    Set to 7FFF16

    Write to WDTS register

    RESET

    CPU

    Clock

    Pre-scaler

    WatchdogTimer

    The WDT circuit contains a 15-bit counter that

    counts down the clock derived by dividing the CPU

    clock by 16 or 128 using the pre-scaler.

    P O R t F ti

  • 8/12/2019 R8C Peripherals 1

    33/38

    2009, Renesas Technology America, Inc., All Rights Reserved33

    Power-On Reset Function

    CPUReset IC

    CPURes

    et ICReset

    CCT

    No External Reset IC required

    0.5

    Vdet

    5.0

    time

    time

    Internal

    state in

    Reset

    CPU Reset Reset Released

    (1/f(RING)) X 32

    Vdet = 3.8V 0.5V

    More Than 1ms

    VCC [V]

    S

    R

    Q

    5-bit

    counter

    Internal

    RESET

    signal

    RESET

    fRING-S

    VCC > Vdet detectiontrigger

    5K

    5K

    L V lt D t t F ti

  • 8/12/2019 R8C Peripherals 1

    34/38

    2009, Renesas Technology America, Inc., All Rights Reserved34

    Low Voltage Detect Function

    2.7

    Vdet

    5.0

    time

    time

    Internal

    state in

    Reset

    CPU ResetReset Released

    (1/f(RING)) X 32

    Vdet = 3.8V 0.5V

    VCC [V]

    Reset Released

    The operation of the LVD function is essentially the

    same as the operation of the POR.

    LVD O ti

  • 8/12/2019 R8C Peripherals 1

    35/38

    2009, Renesas Technology America, Inc., All Rights Reserved35

    LVD Operation

    Voltage Detect Enable

    5.0 V

    Vdet

    Sampling time

    3 to 4 clocks (1/f(RING)) X 32

    Internal Reset Signal

    Voltage Detect Flag

    Voltage Detect

    Interrupt Request

    Sampling time

    3 to 4 clocks

    VCC

    Interrupt

    Acknowledge

    Interrupt

    Acknowledge

    5.0 V

  • 8/12/2019 R8C Peripherals 1

    36/38

    PROPERTIES

    On passing, 'Finish' button: Goes to Next Slide

    On failing, 'Finish' button: Goes to Next SlideAllow user to leave quiz: After user has completed quiz

    User may view slides after quiz: At any time

    User may attempt quiz: Unlimited times

  • 8/12/2019 R8C Peripherals 1

    37/38

    2009, Renesas Technology America, Inc., All Rights Reserved37

    Which statements describe the LVD function?Select all that apply and then click Done.

    Causes the Voltage Detection flag to go to zero when VCC drops below

    the detection voltage level

    Generates a Voltage Detection Interrupt and an internal Reset signal if

    VCC stays below Vdet during the sampling time of 1, 2, 4 or 8 clockcycles

    Removes the Reset and generates a Voltage Detection Interrupt request

    32 On-chip oscillator cycles after VCC rises above the Vdet level

    Resets the microcomputer automatically whenever it is turned on

    without using an external Reset circuit

    Done

    Question

    Course Summary

  • 8/12/2019 R8C Peripherals 1

    38/38

    2009, Renesas Technology America, Inc., All Rights Reserved38

    Timer functions

    Timer modes

    Watchdog timer

    Power-On Reset function

    Low Voltage Detect function

    Course Summary

    http://www.renesasinteractive.com