Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
References
Textbook
Joseph Yiu, The Definitive Guide to the ARM Cortex-M3, Elsevier Newnes, 2007
Websites
www.arm.com www.st.com www.ti.com
B mn K Thut in T - HBK
2/19/2012
B mn K Thut in T - HBK
B mn K Thut in T - HBK
2/19/2012
B mn K Thut in T - HBK
B mn K Thut in T - HBK
2/19/2012
LPC1754FBD80
AT91SAM7S64-AU
STM32F103RCT6
LM3S3749
7
B mn K Thut in T - HBK
Harvard architecture
separate instruction bus and data bus share the same memory space difference length of code and data
Endian mode
both little Endian and big Endian are supported (setup at the time of core reset) In most cases, Cortex-M3-based microcontrollers will be little endian. Instruction fetches are always in little endian PPB accesses are always in little endian.
B mn K Thut in T - HBK
8
2/19/2012
B mn K Thut in T - HBK
Special Registers
Program Status Registers (PSRs) Interrupt Mask Registers (PRIMASK, FAULTMASK, BASEPRI) Control Register (CONTROL)
B mn K Thut in T - HBK
10
2/19/2012
B mn K Thut in T - HBK
11
B mn K Thut in T - HBK
12
2/19/2012
B mn K Thut in T - HBK
13
When using the register name R13, you can only access the current stack pointer
B mn K Thut in T - HBK
14
2/19/2012
B mn K Thut in T - HBK
15
2/19/2012
B mn K Thut in T - HBK
17
2/19/2012
Control[1] = 1: Thread Level Uses Process Stack and Handler Uses Main Stack
B mn K Thut in T - HBK
19
B mn K Thut in T - HBK
20
10
2/19/2012
B mn K Thut in T - HBK
21
To get the best of both worlds, many applications have mixed ARM and Thumb codes Advantages over traditional ARM processor of ARM Cortex M3
No state switching overhead, saving both execution time and instruction space No need to separate ARM code and Thumb code source files easier to write software, because there is no need to worry about switching code between ARM and Thumb
B mn K Thut in T - HBK
22
11
2/19/2012
B mn K Thut in T - HBK
23
The number of external interrupt inputs is defined by chip manufacturers. A maximum of 240 external interrupt inputs can be supported
B mn K Thut in T - HBK
24
12
2/19/2012
Questions
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. What are differences among Cortex- A, -R, and -M series? What is Harvard architecture? How many general purpose registers in Cortex-M3 are there? How many special registers in Cortex-M3 are there? What are difference between little endian and big endian? How many allowed operation modes in Cortex-M3 are there? What is functions of control register in Cortex-M3? What are features of NVIC in Cortex-M3? What is the maximum memory space of Cortex-M3? What is the size of memory space for external RAM? Can program code can be executed from an external RAM region? Does Cortex-M3 support ARM code? Why is Thumb-2 instruction set more advanced than previous?
B mn K Thut in T - HBK
25
Using C
easier for implementing complex operations larger memory size able to include assembly code (inline assembler) Tools: RealView Development Suite (RVDS), KEIL RealView
Microcontroller Development Kit
B mn K Thut in T - HBK
26
13
2/19/2012
B mn K Thut in T - HBK
27
Start
loop
deadloop
B mn K Thut in T - HBK
14
2/19/2012
B mn K Thut in T - HBK
29
B mn K Thut in T - HBK
30
15
2/19/2012
function1 BX LR ; Return
B mn K Thut in T - HBK
32
16
2/19/2012
ASP can be changed by using MSR instruction, but EPSR and IPSR are readonly
MRS MRS MRS MSR MRS MSR r0, APSR r0, IPSR r0, EPSR APSR, r0 r0, PSR PSR, r0 ; Read Flag state into R0 ; Read Exception/Interrupt state ; Read Execution state ; Write Flag state ; Read the combined program status word ; Write combined program state word
B mn K Thut in T - HBK
33
B mn K Thut in T - HBK
34
17
2/19/2012
B mn K Thut in T - HBK
35
B mn K Thut in T - HBK
36
18
2/19/2012
B mn K Thut in T - HBK
37
B mn K Thut in T - HBK
38
19
2/19/2012
B mn K Thut in T - HBK
39
B mn K Thut in T - HBK
20
2/19/2012
Start
loop
deadloop
MyData1 MyData2
B mn K Thut in T - HBK
B mn K Thut in T - HBK
42
21
2/19/2012
22
2/19/2012
Assignments
1. 2. 3. 4. 5. Write a program to move 10 words from 0x20000000 to 0x3000000. Write a program to read STATUS register and write to 0x20000004 Write a program to write a value in 0x30000000 to CONTROL register Write a subroutine to perform a function 40*X + 50 Write a subroutine to convert data of 10 words form big endian to little endian. 6. Write a program as pseudo code below: if (R0 equal R1) then { R3 = R4 + R5 R3 = R3 / 2 } else { R3 = R6 + R7 R3 = R3 / 2 }
B mn K Thut in T - HBK
45
23