56
School of Engineerin g ESI Lektion 7-8

ESI Lektion 7-8

  • Upload
    justis

  • View
    45

  • Download
    0

Embed Size (px)

DESCRIPTION

ESI Lektion 7-8. ESI – Lektion 7-8. ARM Stacks Cortex Interrupt System Systemperipherie eines ARM basierenden Microcontrollers ARM Busse Externe Speicherschnittstelle. ARM Stacks. Memory Map des NXP LPC2138. 4.0 GB. 0xFFFF FFFF. AHB Peripherals. 3.75 GB. 0xF000 0000. - PowerPoint PPT Presentation

Citation preview

Page 1: ESI Lektion 7-8

School ofEngineering

ESI Lektion 7-8

Page 2: ESI Lektion 7-8

School ofEngineering

ESI – Lektion 7-8

● ARM Stacks

● Cortex Interrupt System

● Systemperipherie eines ARM basierenden Microcontrollers

○ ARM Busse

○ Externe Speicherschnittstelle

Page 3: ESI Lektion 7-8

School ofEngineering

ARM Stacks

Page 4: ESI Lektion 7-8

School ofEngineering

AHB Peripherals

VPB Peripherals

Reserved for External Memory

Boot Block

Reserved for On-Chip Memory

On-Chip Static RAM

Reserved for Special Registers

Reserved for On-Chip Memory

On-Chip Non-Volatile Memory

4.0 GB

3.75 GB

3.5 GB

3.0 GB

2.0 GB

1.0 GB

0.0 GB

0xFFFF FFFF

0xF000 0000

0xE000 0000

0xC000 0000

0x8000 0000

0x4000 0000

0x3FFF 8000

0x0000 0000

Stack Pointer

ExceptionVectors

Main Code

Memory Map des NXP LPC2138

Page 5: ESI Lektion 7-8

School ofEngineering

System & User

R0

R1

R2

R3

R4

R5

R6

R7

R8

R9

R10

R11

R12

R13

R14

R15 (PC)

CPSR

FIQ

R0

R1

R2

R3

R4

R5

R6

R7_fiq

R8_fiq

R9_fiq

R10_fiq

R11_fiq

R12_fiq

R13_fiq

R14_fiq

R15 (PC)

CPSR

SPSR_fiq

Supervisor

R0

R1

R2

R3

R4

R5

R6

R7

R8

R9

R10

R11

R12

R13_svc

R14_svc

R15 (PC)

CPSR

SPSR_svc

Abort

R0

R1

R2

R3

R4

R5

R6

R7

R8

R9

R10

R11

R12

R13_abt

R14_abt

R15 (PC)

CPSR

SPSR_abt

IRQ

R0

R1

R2

R3

R4

R5

R6

R7

R8

R9

R10

R11

R12

R13_irq

R14_irq

R15 (PC)

CPSR

SPSR_irq

Undefined

R0

R1

R2

R3

R4

R5

R6

R7

R8

R9

R10

R11

R12

R13_und

R14_und

R15 (PC)

CPSR

SPSR_und

ARM7 Stack Pointer Register

Stack-Pointer

Page 6: ESI Lektion 7-8

School ofEngineeringARM7 Stackpointer im RAM

Page 7: ESI Lektion 7-8

School ofEngineeringCortex-M3 Stackpointer im RAM

MSP

PSP

RAM

Page 8: ESI Lektion 7-8

School ofEngineering

Betriebszustand:FIQIRQSupervisorUserUndefined

F = 1 FIQ disableI = 1 IRQ disable T = 1 Thumb mode

Condition Code Flags:N = NegativeZ = ZeroC = Carry Over V = Overflow (Ergebnis grösser als Platz im Register)

ARM7 Current Processor Status Register (CPSR)

Page 9: ESI Lektion 7-8

School ofEngineering

// Setup Stack for each mode

LDR R0, =Top_Stack

// Enter Undefined Instruction Mode and set its Stack Pointer

MSR CPSR_c, #Mode_UND|I_Bit|F_Bit //Switch to Undefined, disable Interrupt

MOV SP, R0

SUB R0, R0, #UND_Stack_Size

// Enter Abort Mode and set its Stack Pointer

MSR CPSR_c, #Mode_ABT|I_Bit|F_Bit //Switch to Abort, disable Interrupt

MOV SP, R0

SUB R0, R0, #ABT_Stack_Size

// Enter FIQ Mode and set its Stack Pointer

MSR CPSR_c, #Mode_FIQ|I_Bit|F_Bit //Switch to FIQ, disable Interrupt

MOV SP, R0

SUB R0, R0, #FIQ_Stack_Size

ARM7 Initialisieren der Stack Pointer direkt im Startup.s

Page 10: ESI Lektion 7-8

School ofEngineeringARM7 Initialisieren der Stack

Pointer im uVision

Page 11: ESI Lektion 7-8

School ofEngineering

Cortex-M3 Stack Push

● Stack Pointer zeigt immer auf die letzten Daten die abgespeichert wurden

● Wird vor einer Push Operation dekrementiert

Page 12: ESI Lektion 7-8

School ofEngineeringKopieren von mehreren Registern mit

einem Befehl

Abspeichern von mehreren Registern auf den StackSTMFD R13!, {[registers], R14}

Zurückholen der Register vom Stack:LDMFD R13!, {[registers], PC}

Page 13: ESI Lektion 7-8

School ofEngineering

Cortex M3 Interrupt Controller (NVIC)

Page 14: ESI Lektion 7-8

School ofEngineering

Cortex-M3 Blockdiagram

Page 15: ESI Lektion 7-8

School ofEngineering

Exception Type Address Offset Exception Vector

18-255 0x48-0x3FF IRQ #2-239

17 0x44 IRQ #1

16 0x40 IRQ #0

15 0x3C SYSTICK

14 0x38 PendSV

13 0x34 reserved

12 0x30 Debug Monitor

11 0x2C SVC

7-10 0x1C-0x28 Reserved

6 0x18 Usage fault

5 0x14 Bus fault

4 0x10 MemManage fault

3 0x0C Hard fault

2 0x08 NMI

1 0x04 Reset

0 0x00 Starting Value for MSP

Cortex-M3 Exception Vectors

Page 16: ESI Lektion 7-8

School ofEngineering

Cortex-M3 Interrupt Stacking

Page 17: ESI Lektion 7-8

School ofEngineering

Cortex-M3 Stack While Fetch

Page 18: ESI Lektion 7-8

School ofEngineering

Cortex-M3 Interrupt Stacking

Page 19: ESI Lektion 7-8

School ofEngineering

Cortex-M3 Interrupt Stacking

Bei jedem Interrupt werden 8 x 4 Bytes gestacked = 32 Bytes

Page 20: ESI Lektion 7-8

School ofEngineering

Übung1: Stacking

Speicheradresse Daten

0x300000FF 0x11111111

0x300000FB 0x400000FE

0x300000F7 0x12FFFFF8

0x300000F3 0x14FFFFFF

0x300000EF 0x55555555

0x300000EB 0x44444444

0x300000E7 0x33333333

0x300000E3 0x22222222

0x300000DF 0x11111111

0x300000DB 0x5a5a5a5a

pc

lr

r12

r3

r2

r1

r0

Was sind die Inhalte der Coretex-M3 Register unmittelbar nach Rückkehr in das Hauptprogramm?Füllen Sie die Lücken unten aus.Während der Interruptroutine enthielt das Stack Pointer Register den Wert 0x30000000DF

Page 21: ESI Lektion 7-8

School ofEngineering

Übung 1: Stacking - Lösung

Speicheradresse Daten

0x300000FF 0x11111111

0x300000FB 0x400000FE

0x300000F7 0x12FFFFF8

0x300000F3 0x14FFFFFF

0x300000EF 0x55555555

0x300000EB 0x44444444

0x300000E7 0x33333333

0x300000E3 0x22222222

0x300000DF 0x11111111

0x300000DB 0x5a5a5a5a

pc 0x12FFFFF8

lr 0x14FFFFFF

r12 0x55555555

r3 0x44444444

r2 0x33333333

r1 0x22222222

r0 0x11111111

Was sind die Inhalte der Coretex-M3 Register unmittelbar nach Rückkehr in das Hauptprogramm?Füllen Sie die Lücken unten aus.Während der Interruptroutine enthielt das Stack Pointer Register den Wert 0x30000000DF

Page 22: ESI Lektion 7-8

School ofEngineering

Cortex-M3 Interrupt Situationen

● Tail Chaining Interrupts○ Ein Interrupt gleicher oder niedrigerer Priorität folgt

unmittelbar nach einem Interrupt

● Pre Empt Interrupts○ Ein Interrupt höherer Priorität der signalisiert wird,

während ein interrupt niedrigerer Priorität initiiert wird, wird noch vor Ausführung des niedriger priorisierten Interrupts vorgeschoben

● Nested Interrupts○ Ein Interrupt höherer Priorität unterbricht einen

laufenden Interrupt niedrigerer Priorität

Page 23: ESI Lektion 7-8

School ofEngineering

Tail Chaining Situation 1

Interrupt mit gleicher oder niedrigerer Priorität folgt sofort im Anschluss

Cortex-M3

Page 24: ESI Lektion 7-8

School ofEngineering

Tail Chaining Situation 2

Zweiter Interrupt folgt kurz nachdem oder währenddes Abladens des Stacks in die Register

Cortex-M3

Page 25: ESI Lektion 7-8

School ofEngineering

Pre-empt Interrupt

Spät ankommender, höher priorisierter Interrupt kann füherem Interrupt vorgeschoben werden

Cortex-M3

Page 26: ESI Lektion 7-8

School ofEngineering

Cortex-M3 Nested Interrupt

Page 27: ESI Lektion 7-8

School ofEngineering

Übung 2: NVIC Priorität

Die Priorität von drei Interrupt Routinen ist: INT1 = höchste, Int3 = niedrigste

Übung 2a)Der Stackpointer ist vor Eintritt in Interrupt Routine 2 0x300000FFWährend der Ausführung von Routine 2 wird Interrupt 1 aktiviert.Beschreiben Sie was passiert:

Was ist der Wert des Stackpointers während der Ausführung von Interrupt Routine 1 ?

Übung 2b) Der Stackpointer ist vor Eintritt in Interrupt Routine 2 0x300000FFWährend der Ausführung von Routine 2 wird Interrupt 3 aktiviert.Beschreiben Sie was passiert:

Was ist der Wert des Stackpointers während der Ausführung von Interrupt Routine 3 ?

Page 28: ESI Lektion 7-8

School ofEngineering

Übung2: NVIC Priorität - Lösung

Übung 2a)Vor Ausführung von Routine2 werden die Register gestacked,der Stackpointer wird um 32 Bytes dekrementiert.Da Interrupt 1 höhere Priorität hat, wird Interrupt Routine2 unterbrochen, und die Register wieder gestacked, die Stack Adresse wird noch mal um 32 Bytes dekrementiert

SP: 0x300000FF - 2 * 32 Byte = 0x300000BF

Übung 2b)Vor Ausführung von Interrupt 2 wird der Stack um 32 Bytes dekrementiert. Interrupt 3 hat niedrigere Priorität, Interrupt 2 wird nicht unterbrochen.Nach Ausführung von Interrupt2 folgt unmittelbar Interrupt3, es erfolgte keinweiters stacking, da Interrupt 3 im Anschluss kommt.

SP: 0x300000FF - 32 Byte = 0x300000DF

Page 29: ESI Lektion 7-8

School ofEngineering

ARM System Peripherals

Page 30: ESI Lektion 7-8

School ofEngineering

Blockdiagram des NXP LPC2138

CoreTeil

SystemTeil

ARM7 Core

Pulse Width Modulator

A/D – D/AConverter

InterruptController

Real TimeClock

I2C/SPIController

UART

SRAM/Flash

Bus/Systeme

Takt Erzeugung

General Purpose I/O

Page 31: ESI Lektion 7-8

School ofEngineeringInterne Busse im LPC2138

ARM 7

AHB/VPB Bridge

ON Chip Peripherals

Program Code/DataFlash/RAM

Local Bus

Advance High Performance Bus

VLSI Peripheral Bus

Vectored Interrupt Controler

AMBA-Bus

Page 32: ESI Lektion 7-8

School ofEngineeringSpeicherbereichs-Aufteilung

LPC2138

AHB Peripherals

VPB Peripherals

Reserved for External Memory

Boot Block

Reserved for On-Chip Memory

On-Chip Static RAM

Reserved for Special Registers

Reserved for On-Chip Memory

On-Chip Non-Volatile Memory

4.0 GB

3.75 GB

3.5 GB

3.0 GB

2.0 GB

1.0 GB

0.0 GB

0xFFFF FFFF

0xF000 0000

0xE000 0000

0xC000 0000

0x8000 0000

0x4000 0000

0x3FFF 8000

0x0000 0000

Page 33: ESI Lektion 7-8

School ofEngineering

Speicherbereichs-Aufteilung des VPB

Page 34: ESI Lektion 7-8

School ofEngineering

Externe Speicherschnittstellen

Page 35: ESI Lektion 7-8

School ofEngineering

Blockdiagram EBI Atmel AT91SAM7

Page 36: ESI Lektion 7-8

School ofEngineering

Features eines modernen EBI

● Min. 23 Adressleitungen (je nach Konfiguration bis 32 Mbyte adressierbar)

● 16- oder 32-bit Datenbusbreite● Steuert

○ SRAM○ SDRAM○ DDRAM2○ PROM○ EEPROM○ Flash○ Compact Flash○ NAND Flash

● Fehlerkorrekturschaltung eingebaut (ECC)

Page 37: ESI Lektion 7-8

School ofEngineering

Addressaufteilung eines Atmel AT91X40

Page 38: ESI Lektion 7-8

School ofEngineering

Verbinden von 8-bit Speichern

Page 39: ESI Lektion 7-8

School ofEngineeringVerbinden von 16-bit Speichern

Page 40: ESI Lektion 7-8

School ofEngineering

Adressieren von Speichern

AusgegebeneAdresse

A3..A0 Datenbits

D7..D0

0x0006 0b0110 D7..0

0x0005 0b0101 D7..0

0x0004 0b0100 D7..0

0x0003 0b0011 D7..0

0x0002 0b0010 D7..0

0x0001 0b0001 D7..0

0x0000 0b0000 D7..0

AusgegebeneAdresse

A3..A0 Datenbits NWR1Write

Enable

NWR0Write

EnableD15..8 D7..0

0x000c 0b1100 D15..8 D7..0 0 0

0x000a 0b1010 D15..8 D7..0 0 0

0x0008 0b1000 D15..8 D7..0 0 0

0x0006 0b0110 D15..8 D7..0 0 0

0x0004 0b0100 D15..8 D7..0 0 0

0x0002 0b0010 D15..8 D7..0 0 0

0x0000 0b0000 D15..8 D7..0 0 0

Schreiben von 16-bit Datenauf 16-bit externen Bus

Schreiben von 16-bit Datenauf 8-bit externen Bus

Low Aktiv!

Page 41: ESI Lektion 7-8

School ofEngineering

Adressieren von Speichern

AusgegebeneAdresse

A3..A0 Datenbits NWR1Write

Enable

NWR0Write

EnableD15..8 D7..0

0x0006 0b0110 D7..0 D7..0 1 00x0005 0b0101 D15..8 D15..8 0 10x0004 0b0100 D7..0 D7..0 1 00x0003 0b0011 D15..8 D15..8 0 10x0002 0b0010 D7..0 D7..0 1 00x0001 0b0001 D15..8 D15..8 0 10x0000 0b0000 D7..0 D7..0 1 0

Schreiben von 8-bit Daten auf 16-bit externen Bus in little Endian

Low Aktiv!

Page 42: ESI Lektion 7-8

School ofEngineering

Übung3: Bestimmen der Enable Signale

Page 43: ESI Lektion 7-8

School ofEngineering

Übung3: Lösung

Page 44: ESI Lektion 7-8

School ofEngineering

Übung4: Verbinden von Speichern

Page 45: ESI Lektion 7-8

School ofEngineering

Übung4: Lösung

Page 46: ESI Lektion 7-8

School ofEngineering

Speicherzugriffs-Zyklen(Keine Wait States, schnellst möglicher Zugriff)

NWE

NRD

NCS

ADDR

MCKI

ODER

Prozessor gibtAdressen aus

Prozessor speichertDaten

NWE = Low aktives Write Enable

Page 47: ESI Lektion 7-8

School ofEngineering

SRAM Read Cycle

Page 48: ESI Lektion 7-8

School ofEngineeringEin programmierter Wait State

NWE

NRD

NCS

ADDR

MCKI

ODER

1 zusätzlicher Zyklus

Prozessor gibtAdressen aus

Prozessor speichertDaten

min. 6 nsmin. 6 ns

Page 49: ESI Lektion 7-8

School ofEngineering

Externes Wait Signal

NWE

NRD

NCS

ADDR

MCKI

ODER

1 Wait State

Prozessor fügt Wait ein wenn

NWAIT = 0

Prozessor speichertDaten

WAIT

Page 50: ESI Lektion 7-8

School ofEngineering

SRAM Write Cycle

Page 51: ESI Lektion 7-8

School ofEngineeringAufeinander folgende Lese und Schreibzyklen

Page 52: ESI Lektion 7-8

School ofEngineeringEarly Read Cycle

NWE

NRD

NCS

ADDR

MCKI

ODER

1 zusätzlicher Zyklus

Prozessor gibtAdressen aus

Prozessor speichertDaten

Early Read Normal Read

10 ns10 ns

Page 53: ESI Lektion 7-8

School ofEngineeringEBI Steuerregister

Page 54: ESI Lektion 7-8

School ofEngineeringFür jedes Chip Select, gibt es ein Chip Select

Register (Atmel-ARM)

Datenbusbreite10 = 8-bit01 = 16-bit

Number ofWait States

Wait Stateseingeschaltet

Seitengrösse00 = 1 M Byte01 = 4 MByte10 = 16 MByte11 = 64 MByte

Data FloatOutput Time

Chip SelectEnable

Base Address(höchste Bits derBasis Adresse)

Byte WriteAccess Type

Page 55: ESI Lektion 7-8

School ofEngineering

Übung5: EBI Chip Select Register

  CS0 CS1 CS2

Page Size: 16M 16M 16M

Base Address: 0x01000000 0x02000000 0x03000000

Von: 0x01000000 0x02000000 0x03000000

Bis: 0x01FFFFFF 0x02FFFFFF 0x03FFFFFF

  CS0 CS1 CS2

Page Size: 64M 64M 64M

Base Address: 0x10000000

Von:

Bis:

Page 56: ESI Lektion 7-8

School ofEngineering

Übung5-Lsg: EBI Chip Select Register

  CS0 CS1 CS2

Page Size: 16M 16M 16M

Base Address: 0x01000000 0x02000000 0x03000000

Von: 0x01000000 0x02000000 0x03000000

Bis: 0x01FFFFFF 0x02FFFFFF 0x03FFFFFF

  CS0 CS1 CS2

Page Size: 64M 64M 64M

Base Address: 0x10000000 0x14000000 0x18000000

Von: 0x10000000 0x14000000 0x18000000

Bis: 0x13FFFFFF 0x17FFFFFF 0x1BFFFFFF