Docsity

Controlling Modules with MMRs - Microcontroller Systems - Lecture Slides, Slides of Microcontrollers

Partial preview of the text

Download Controlling Modules with MMRs - Microcontroller Systems - Lecture Slides and more Slides Microcontrollers in PDF only on Docsity!

Controlling Modules with MMRs

MPC555 Block Diagram

Internal Memory Map

(MPC555 user‟s manual, Appendix A)

A 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

Periodic Interrupt Timer

Time 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?

Periodic Interrupt Timer

Time 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

What does the manual say?

  • Check the table of contents:

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

Internal Memory Map

MPC555 PIT Programming

PIT Enable 0: enable decrement counter 1: disable decrement counter

PInterrupt Enable 0: disable interrupt 1: enable interrupt

PIT Freeze 0: no effect 1: disable decrement counter if internal signal FREEZE is asserted

PIT Status 0: no PIT int asserted 1: PIT int asserted

PS PIE PITF PTE

PIRQ

Interrupt level for PIT

PICSR: Periodic Interrupt Control & Select Register

MPC555 PIT Programming

PTE : PIT enable PIF : PIT freeze

PITC : PIT count value PS : PIT status

PIE : PIT interrupt enable PITR : current counter value (Read-Only)

PTE

Clock Disable

PIF

16-bit Modulus counter

PITC

PS

PIE

PIT Interrupt

PITR: Periodic Interrupt Timer Register

Reserved

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?

PIT

PIT Initialization

; r4 base address of SIU regs lis r4, 0x2f

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

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

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

Software 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)

Configuring the SWT