R8C PERIPHERALS PART 1 - Renesas Electronics 00 02 Count Source Timer RB One Shot bit Contents of...

33
© 2009, Renesas Technology America, Inc., All Rights Reserved 1 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) and Low-Voltage Detect (LVD) functions operate. Content 33 pages 5 questions Learning Time 35 minutes

Transcript of R8C PERIPHERALS PART 1 - Renesas Electronics 00 02 Count Source Timer RB One Shot bit Contents of...

Page 1: R8C PERIPHERALS PART 1 - Renesas Electronics 00 02 Count Source Timer RB One Shot bit Contents of TRBPR Prealer RB underflow signal Interrupt Request bit in Timer RB Interrupt Control

© 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 theTimerRA, 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

5 questions

Learning Time

35 minutes

Page 2: R8C PERIPHERALS PART 1 - Renesas Electronics 00 02 Count Source Timer RB One Shot bit Contents of TRBPR Prealer RB underflow signal Interrupt Request bit in Timer RB Interrupt Control

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

Versatile Set of Timers

Timer RA Timer RB Timer RC Timer RD Timer RE

Timer 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

- YesYes, 2 PWM

modes

Yes, 4 PWM

modes -

Programmable

One-Shot

Generation Mode

- Yes - - -

Programmable Wait

One-Shot Generation

Mode

- Yes - - -

Input Capture Mode - - Yes Yes -

Output Compare Mode - - Yes Yes Yes

Real Time Clock Mode - - - - Yes

The Watchdog Timer is covered separately in this course.

Page 3: R8C PERIPHERALS PART 1 - Renesas Electronics 00 02 Count Source Timer RB One Shot bit Contents of TRBPR Prealer RB underflow signal Interrupt Request bit in Timer RB Interrupt Control

PROPERTIES

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

On failing, 'Finish' button: Goes to Slide

Allow user to leave quiz: At any time

User may view slides after quiz: After passing quiz

User may attempt quiz: Unlimited times

Page 4: R8C PERIPHERALS PART 1 - Renesas Electronics 00 02 Count Source Timer RB One Shot bit Contents of TRBPR Prealer RB underflow signal Interrupt Request bit in Timer RB Interrupt Control

© 2009, Renesas Technology America, Inc., All Rights Reserved4

Timer RA

Page 5: R8C PERIPHERALS PART 1 - Renesas Electronics 00 02 Count Source Timer RB One Shot bit Contents of TRBPR Prealer RB underflow signal Interrupt Request bit in Timer RB Interrupt Control

© 2009, Renesas Technology America, Inc., All Rights Reserved5

Timer RB

Page 6: R8C PERIPHERALS PART 1 - Renesas Electronics 00 02 Count Source Timer RB One Shot bit Contents of TRBPR Prealer RB underflow signal Interrupt Request bit in Timer RB Interrupt Control

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

Timer RC

Page 7: R8C PERIPHERALS PART 1 - Renesas Electronics 00 02 Count Source Timer RB One Shot bit Contents of TRBPR Prealer RB underflow signal Interrupt Request bit in Timer RB Interrupt Control

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

Timer RD

Page 8: R8C PERIPHERALS PART 1 - Renesas Electronics 00 02 Count Source Timer RB One Shot bit Contents of TRBPR Prealer RB underflow signal Interrupt Request bit in Timer RB Interrupt Control

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

Timer RE

Page 9: R8C PERIPHERALS PART 1 - Renesas Electronics 00 02 Count Source Timer RB One Shot bit Contents of TRBPR Prealer RB underflow signal Interrupt Request bit in Timer RB Interrupt Control

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

FFFF

Timer Mode

FF

Reload register Reload register

FF

210

Count Start flag

TRAPRE Pre-scaler TRA Counter

Timer RAInterrupt

f2

fOCO

f8

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 theTimer Mode and start/stop the counting.08h

0

1 2

Example: Timer RA

Page 10: R8C PERIPHERALS PART 1 - Renesas Electronics 00 02 Count Source Timer RB One Shot bit Contents of TRBPR Prealer RB underflow signal Interrupt Request bit in Timer RB Interrupt Control

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

Pulse Output Mode

1

Reload register Reload register

2

20

Count Start flag

TRAPRE Pre-scaler TRA Counterf2

fOCO

f8

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

Page 11: R8C PERIPHERALS PART 1 - Renesas Electronics 00 02 Count Source Timer RB One Shot bit Contents of TRBPR Prealer RB underflow signal Interrupt Request bit in Timer RB Interrupt Control

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

Pulse Output Mode: Timer RA Example

1

Reload Register Reload Register

2

20

Count Start Flag

PREX register TX registerf2

fOCO

f8

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

Page 12: R8C PERIPHERALS PART 1 - Renesas Electronics 00 02 Count Source Timer RB One Shot bit Contents of TRBPR Prealer RB underflow signal Interrupt Request bit in Timer RB Interrupt Control

PROPERTIES

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

On failing, 'Finish' button: Goes to Slide

Allow user to leave quiz: At any time

User may view slides after quiz: After passing quiz

User may attempt quiz: Unlimited times

Page 13: R8C PERIPHERALS PART 1 - Renesas Electronics 00 02 Count Source Timer RB One Shot bit Contents of TRBPR Prealer RB underflow signal Interrupt Request bit in Timer RB Interrupt Control

© 2009, Renesas Technology America, Inc., All Rights Reserved13

Generate Complementary Outputs

1

Reload register Reload register

2

20

Count Start flag

TRAPRE Pre-scaler TRA Counterf2

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

Page 14: R8C PERIPHERALS PART 1 - Renesas Electronics 00 02 Count Source Timer RB One Shot bit Contents of TRBPR Prealer RB underflow signal Interrupt Request bit in Timer RB Interrupt Control

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

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

102Timer 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.

Page 15: R8C PERIPHERALS PART 1 - Renesas Electronics 00 02 Count Source Timer RB One Shot bit Contents of TRBPR Prealer RB underflow signal Interrupt Request bit in Timer RB Interrupt Control

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

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 TRAIC register

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

Page 16: R8C PERIPHERALS PART 1 - Renesas Electronics 00 02 Count Source Timer RB One Shot bit Contents of TRBPR Prealer RB underflow signal Interrupt Request bit in Timer RB Interrupt Control

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

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 RA

underflow

(TUNDF bit)

Contents of read

out buffer

Timer RA

reloads

Timer RA

read

Timer RA

read

Cleared to “0” by program

Period being measured

Timer RA

reloads

Page 17: R8C PERIPHERALS PART 1 - Renesas Electronics 00 02 Count Source Timer RB One Shot bit Contents of TRBPR Prealer RB underflow signal Interrupt Request bit in Timer RB Interrupt Control

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

Programmable Waveform Gen. Mode

FF

Reload register TRBSC register

FF

1FF0

Count Start flag

TRBPRE Pre-scaler Timer RB Counterf2

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

Page 18: R8C PERIPHERALS PART 1 - Renesas Electronics 00 02 Count Source Timer RB One Shot bit Contents of TRBPR Prealer RB underflow signal Interrupt Request bit in Timer RB Interrupt Control

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

Programmable One-Shot Gen. Mode

0

Reload register

1

100

Count Start flag

TRBPRE Pre-scaler Timer RB Counterf2

TRA UDF

f8

f1

Count Source

1

Toggle flip-flop

Q

Q

CK

01

TMOD bits

TRBPR register

TRBO

P3_2 bit

0210102101

Digital

Filter

Input polarity selected to be

one edge or both edges

Polarity

select

TSTARTTOSSTF

TMODx

INT0ENINT0PL

INT0

Example: Timer RB

Page 19: R8C PERIPHERALS PART 1 - Renesas Electronics 00 02 Count Source Timer RB One Shot bit Contents of TRBPR Prealer RB underflow signal Interrupt Request bit in Timer RB Interrupt Control

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

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

Count

Starts

Waveform

Output Starts

Waveform

Output ends

Timer RA

primary

reloads

Set to “1” by program

Set to “0” by program

Page 20: R8C PERIPHERALS PART 1 - Renesas Electronics 00 02 Count Source Timer RB One Shot bit Contents of TRBPR Prealer RB underflow signal Interrupt Request bit in Timer RB Interrupt Control

© 2009, Renesas Technology America, Inc., All Rights Reserved20

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

Page 21: R8C PERIPHERALS PART 1 - Renesas Electronics 00 02 Count Source Timer RB One Shot bit Contents of TRBPR Prealer RB underflow signal Interrupt Request bit in Timer RB Interrupt Control

PROPERTIES

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

On failing, 'Finish' button: Goes to Slide

Allow user to leave quiz: At any time

User may view slides after quiz: After passing quiz

User may attempt quiz: Unlimited times

Page 22: R8C PERIPHERALS PART 1 - Renesas Electronics 00 02 Count Source Timer RB One Shot bit Contents of TRBPR Prealer RB underflow signal Interrupt Request bit in Timer RB Interrupt Control

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

Input Capture Mode

Page 23: R8C PERIPHERALS PART 1 - Renesas Electronics 00 02 Count Source Timer RB One Shot bit Contents of TRBPR Prealer RB underflow signal Interrupt Request bit in Timer RB Interrupt Control

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

TimerRC Timer Mode Output Compare

Page 24: R8C PERIPHERALS PART 1 - Renesas Electronics 00 02 Count Source Timer RB One Shot bit Contents of TRBPR Prealer RB underflow signal Interrupt Request bit in Timer RB Interrupt Control

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

TimerRC PWM Mode

Page 25: R8C PERIPHERALS PART 1 - Renesas Electronics 00 02 Count Source Timer RB One Shot bit Contents of TRBPR Prealer RB underflow signal Interrupt Request bit in Timer RB Interrupt Control

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

TimerRD Complementary PWM Mode

Page 26: R8C PERIPHERALS PART 1 - Renesas Electronics 00 02 Count Source Timer RB One Shot bit Contents of TRBPR Prealer RB underflow signal Interrupt Request bit in Timer RB Interrupt Control

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

TimerRD Complementary PWM Mode

Page 27: R8C PERIPHERALS PART 1 - Renesas Electronics 00 02 Count Source Timer RB One Shot bit Contents of TRBPR Prealer RB underflow signal Interrupt Request bit in Timer RB Interrupt Control

PROPERTIES

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

On failing, 'Finish' button: Goes to Slide

Allow user to leave quiz: At any time

User may view slides after quiz: After passing quiz

User may attempt quiz: Unlimited times

Page 28: R8C PERIPHERALS PART 1 - Renesas Electronics 00 02 Count Source Timer RB One Shot bit Contents of TRBPR Prealer RB underflow signal Interrupt Request bit in Timer RB Interrupt Control

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

Watchdog Timer

1/16

1/128

Watchdog Timer Interrupt

Request

WatchdogTimer Reset

PM12 = 0

PM12 = 1

WDC7 = 0

WDC7 = 1

Set to 7FFF16

Write to WDTS register

RESET

CPU

Clock

Pre-scaler

Watchdog Timer

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.

Page 29: R8C PERIPHERALS PART 1 - Renesas Electronics 00 02 Count Source Timer RB One Shot bit Contents of TRBPR Prealer RB underflow signal Interrupt Request bit in Timer RB Interrupt Control

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

Power-On Reset Function

CPURes

et 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Ω

Page 30: R8C PERIPHERALS PART 1 - Renesas Electronics 00 02 Count Source Timer RB One Shot bit Contents of TRBPR Prealer RB underflow signal Interrupt Request bit in Timer RB Interrupt Control

© 2009, Renesas Technology America, Inc., All Rights Reserved30

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.

Page 31: R8C PERIPHERALS PART 1 - Renesas Electronics 00 02 Count Source Timer RB One Shot bit Contents of TRBPR Prealer RB underflow signal Interrupt Request bit in Timer RB Interrupt Control

© 2009, Renesas Technology America, Inc., All Rights Reserved31

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

Page 32: R8C PERIPHERALS PART 1 - Renesas Electronics 00 02 Count Source Timer RB One Shot bit Contents of TRBPR Prealer RB underflow signal Interrupt Request bit in Timer RB Interrupt Control

PROPERTIES

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

On failing, 'Finish' button: Goes to Slide

Allow user to leave quiz: At any time

User may view slides after quiz: After attempting quiz

User may attempt quiz: Unlimited times

Page 33: R8C PERIPHERALS PART 1 - Renesas Electronics 00 02 Count Source Timer RB One Shot bit Contents of TRBPR Prealer RB underflow signal Interrupt Request bit in Timer RB Interrupt Control

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

Timer functions

Timer modes

Watchdog timer

Power-On Reset function

Low Voltage Detect function

Course Summary

http://www.renesasinteractive.com