esi lektion 7-8
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 PresentationTRANSCRIPT
School ofEngineering
ESI Lektion 7-8
School ofEngineering
ESI – Lektion 7-8
● ARM Stacks
● Cortex Interrupt System
● Systemperipherie eines ARM basierenden Microcontrollers
○ ARM Busse
○ Externe Speicherschnittstelle
School ofEngineering
ARM Stacks
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
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
School ofEngineeringARM7 Stackpointer im RAM
School ofEngineeringCortex-M3 Stackpointer im RAM
MSP
PSP
RAM
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)
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
School ofEngineeringARM7 Initialisieren der Stack
Pointer im uVision
School ofEngineering
Cortex-M3 Stack Push
● Stack Pointer zeigt immer auf die letzten Daten die abgespeichert wurden
● Wird vor einer Push Operation dekrementiert
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}
School ofEngineering
Cortex M3 Interrupt Controller (NVIC)
School ofEngineering
Cortex-M3 Blockdiagram
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
School ofEngineering
Cortex-M3 Interrupt Stacking
School ofEngineering
Cortex-M3 Stack While Fetch
School ofEngineering
Cortex-M3 Interrupt Stacking
School ofEngineering
Cortex-M3 Interrupt Stacking
Bei jedem Interrupt werden 8 x 4 Bytes gestacked = 32 Bytes
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
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
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
School ofEngineering
Tail Chaining Situation 1
Interrupt mit gleicher oder niedrigerer Priorität folgt sofort im Anschluss
Cortex-M3
School ofEngineering
Tail Chaining Situation 2
Zweiter Interrupt folgt kurz nachdem oder währenddes Abladens des Stacks in die Register
Cortex-M3
School ofEngineering
Pre-empt Interrupt
Spät ankommender, höher priorisierter Interrupt kann füherem Interrupt vorgeschoben werden
Cortex-M3
School ofEngineering
Cortex-M3 Nested Interrupt
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 ?
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
School ofEngineering
ARM System Peripherals
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
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
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
School ofEngineering
Speicherbereichs-Aufteilung des VPB
School ofEngineering
Externe Speicherschnittstellen
School ofEngineering
Blockdiagram EBI Atmel AT91SAM7
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)
School ofEngineering
Addressaufteilung eines Atmel AT91X40
School ofEngineering
Verbinden von 8-bit Speichern
School ofEngineeringVerbinden von 16-bit Speichern
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!
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!
School ofEngineering
Übung3: Bestimmen der Enable Signale
School ofEngineering
Übung3: Lösung
School ofEngineering
Übung4: Verbinden von Speichern
School ofEngineering
Übung4: Lösung
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
School ofEngineering
SRAM Read Cycle
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
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
School ofEngineering
SRAM Write Cycle
School ofEngineeringAufeinander folgende Lese und Schreibzyklen
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
School ofEngineeringEBI Steuerregister
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
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:
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