+ All Categories
Home > Documents > Controlling Modules with MMRs

Controlling Modules with MMRs

Date post: 10-Feb-2016
Category:
Upload: lynnea
View: 25 times
Download: 0 times
Share this document with a friend
Description:
Controlling Modules with MMRs. MPC555 Block Diagram. How Do I Control These Modules?. These devices get their operating instructions through a set of registers The CPU can modify these registers through memory addresses “Memory-Mapped Registers” What do these registers do? - PowerPoint PPT Presentation
20
CS 478: Microcontroller Systems University of Wisconsin-Eau Claire Dan Ernst Controlling Modules with Controlling Modules with MMRs MMRs
Transcript
Page 1: Controlling Modules with MMRs

CS 478: Microcontroller SystemsUniversity of Wisconsin-Eau Claire Dan Ernst

Controlling Modules with MMRsControlling Modules with MMRs

Page 2: Controlling Modules with MMRs

CS 478: Microcontroller SystemsUniversity of Wisconsin-Eau Claire Dan Ernst

MPC555 Block DiagramMPC555 Block Diagram

Page 3: Controlling Modules with MMRs

CS 478: Microcontroller SystemsUniversity of Wisconsin-Eau Claire Dan Ernst

How Do I Control These Modules?How Do I Control These Modules?

• These devices get their operating instructions through a set of registers

• The CPU can modify these registers through memory addresses– “Memory-Mapped Registers”

• What do these registers do?• Where do I find them?

• The Controller’s Users Manual is the definitive source!

Page 4: Controlling Modules with MMRs

CS 478: Microcontroller SystemsUniversity of Wisconsin-Eau Claire Dan Ernst

Internal Memory MapInternal Memory Map(MPC555 user’s manual, Appendix A)

Page 5: Controlling Modules with MMRs

CS 478: Microcontroller SystemsUniversity of Wisconsin-Eau Claire Dan Ernst

A Simple MMR-Driven DeviceA Simple MMR-Driven Device

Periodic Interrupt Timer

• This basic timer has many uses– To implement a clock– To check user input periodically– To monitor environment changes– To switch between programs

Page 6: Controlling Modules with MMRs

CS 478: Microcontroller SystemsUniversity of Wisconsin-Eau Claire Dan Ernst

Periodic Interrupt TimerPeriodic Interrupt Timer

A timer is basically a counter of clock cycles.

count register

Adder

-1

mux

count

reset

clock zero? timer expires

Page 7: Controlling Modules with MMRs

CS 478: Microcontroller SystemsUniversity of Wisconsin-Eau Claire Dan Ernst

Periodic Interrupt TimerPeriodic Interrupt TimerTime Period

= (count + 1) × clock cycle time= (count + 1) / clock frequency

EX: The clock frequency is 5MHz.The needed time period is 10ms.What is the count value?

Page 8: Controlling Modules with MMRs

CS 478: Microcontroller SystemsUniversity of Wisconsin-Eau Claire Dan Ernst

Periodic Interrupt TimerPeriodic Interrupt TimerTime Period

= (count + 1) × clock cycle time= (count + 1) / clock frequency

EX 2: The clock frequency is 5MHz.The needed time period is 1 sec.What is the count value?

FYI: The count register is 16-bit

Page 9: Controlling Modules with MMRs

CS 478: Microcontroller SystemsUniversity of Wisconsin-Eau Claire Dan Ernst

Periodic Interrupt TimerPeriodic Interrupt Timer

• How to program a timer?– Set up count value– Check if the timer expires– Configure interrupt, if interrupt is to be used– Read current value (if supported)

Page 10: Controlling Modules with MMRs

CS 478: Microcontroller SystemsUniversity of Wisconsin-Eau Claire Dan Ernst

What does the manual say?What does the manual say?

• Check the table of contents:

(Page 6-15 has a short description of what the timer does)

Page 11: Controlling Modules with MMRs

CS 478: Microcontroller SystemsUniversity of Wisconsin-Eau Claire Dan Ernst

Internal Memory MapInternal Memory Map

Page 12: Controlling Modules with MMRs

CS 478: Microcontroller SystemsUniversity of Wisconsin-Eau Claire Dan Ernst

MPC555 PIT ProgrammingMPC555 PIT Programming

3 Registers form the MPC555 PIT programming interface

1. PICSR: Periodic Interrupt Control & Select Register

2. PITC: PIT Counter

3. PITR: Periodic Interrupt Timer Register

Page 13: Controlling Modules with MMRs

CS 478: Microcontroller SystemsUniversity of Wisconsin-Eau Claire Dan Ernst

MPC555 PIT ProgrammingMPC555 PIT Programming

PIT Enable0: enable decrement counter1: disable decrement counter

PInterrupt Enable0: disable interrupt1: enable interrupt

PIT Freeze0: no effect1: disable decrement counter if internal signal FREEZE is asserted

PIT Status0: no PIT int asserted1: PIT int asserted

0x002FC240

PS PIE PITF PTE

0 1 2 3 4 5 6 7

8 9 10 11 12 13 14 15

PIRQ

Interrupt levelfor PIT

PICSR: Periodic Interrupt Control & Select Register

Page 14: Controlling Modules with MMRs

CS 478: Microcontroller SystemsUniversity of Wisconsin-Eau Claire Dan Ernst

MPC555 PIT ProgrammingMPC555 PIT Programming

PTE: PIT enable PIF: PIT freezePITC: PIT count value PS: PIT statusPIE: PIT interrupt enable PITR: current counter value (Read-Only)

PTE

ClockDisable

PIF

16-bitModuluscounter

PITC

PS

PIE

PIT Interrupt

Page 15: Controlling Modules with MMRs

CS 478: Microcontroller SystemsUniversity of Wisconsin-Eau Claire Dan Ernst

PITC: PIT CounterPITC: PIT Counter

0

PITC

16

PITC: PIT counter

PIT Time-out period = (PITC+1)/(PIT Frequency)

PIT Frequency depends on another module…

0x2F C244

Page 16: Controlling Modules with MMRs

CS 478: Microcontroller SystemsUniversity of Wisconsin-Eau Claire Dan Ernst

PITR: Periodic Interrupt Timer RegisterPITR: Periodic Interrupt Timer Register

16Reserved

31

PIT: Leftover (current) count in PIT counter

Writes to PITR have no effect: read only.

If you want to read the current PIT count to estimate time to next PIT interrupt?

0x2F C248

PIT150

Page 17: Controlling Modules with MMRs

CS 478: Microcontroller SystemsUniversity of Wisconsin-Eau Claire Dan Ernst

PIT InitializationPIT Initialization; r4 base address of SIU regs

lis r4, 0x2f

; set PISCR bits: PIRQ=08, PS=PS, PIE=1, PITF=0, PTE=0; so flag is cleared, interrupt is enabled, timer is; enabled, and level is assigned (Level 0)

li r0,0x0804 sth r0,0xC240(r4)

;PITC = 33000 = 0x80e8 and store it in PITC (0x2fc244) li r5, 0x80e8

sth r5, 0xC244(r4)

;now enable PIT: PTE = 1 lhz r0, 0xC240(r4) ori r0, r0, 0x1 sth r0, 0xC240(r4)

Page 18: Controlling Modules with MMRs

CS 478: Microcontroller SystemsUniversity of Wisconsin-Eau Claire Dan Ernst

How to handle a PIT InterruptHow to handle a PIT Interrupt

Easy, as far as module handlers go

Write a ‘1’ to the PS field. This indicates that you’ve handled the interrupt, and the count will immediately start over again with the same period (from PITC)

If you want to change the period, modify PITC.

Page 19: Controlling Modules with MMRs

CS 478: Microcontroller SystemsUniversity of Wisconsin-Eau Claire Dan Ernst

Software Watchdog TimerSoftware Watchdog Timer• Timer used to guarantee forward progress for the processor.

• SWT must get attention every so often, or it will generate a NMI (reset)

Page 20: Controlling Modules with MMRs

CS 478: Microcontroller SystemsUniversity of Wisconsin-Eau Claire Dan Ernst

Configuring the SWTConfiguring the SWT


Recommended