《毕业设计说明书外文文献及翻译.doc》由会员分享,可在线阅读,更多相关《毕业设计说明书外文文献及翻译.doc(20页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、外文文献:Embedded Systems Design using the TI MSP430 Series(selection)This book is intended for the embedded engineer who is new to the field, and as an introduction and reference for those experienced with micro-controller development, but are new to the MSP430 family of devices. I have assumed that th
2、e reader has some experience with microcontroller-based design, either professionally or academically. As an example, the book de- scribes interrupt functionality in detail, but assumes that you, the reader, already know what an interrupt is and how to use it. It is also important to note that, whil
3、e much of the information in this book is identical to that which is available from the TI documentation, this book is intended to supplement, not replace that valuable source of information. The Users Guides and Application Notes together offer a depth and breadth of technical information that woul
4、d be difficult to replicate in a single source. The intent of this book is to highlight some of the most commonly used information, along with some helpful suggestions and rules of thumb.The MSP430 FamilyThe MSP430 family is a broad family of low power, feature rich 16-bit microcontrollers from Texa
5、s Instruments. They share a common, RISC-type, Neumann CPU core. The 430 is competitive in price with the 8-bit controller market, and supports both 8 and 16-bit instructions, allowing migration from most similarly sized platforms.The family of devices ranges from the very small (1k ROM, 128 bytes f
6、or RAM, sub-dollar) up to larger (60k ROM, 2k RAM, with prices in the $10 range) devices. Currently, there are at least 40 flavors available, with more being added regularly. The devices are split into three families: the MSP430x3xx, which is a basic unit, the MSP430x1xx, which is a more feature-ric
7、h family, and the MSP430x4xx, which is similar to the 1xx, with a built in LCD driver. You will find these referred to as 1xx, 3xx, and 4xx devices throughout this book.Part Numbering ConventionPart numbers for MSP430 devices are determined based on their capabilities. All device part numbers follow
8、 the following template:MSP430Mt Fa F bMcM: Memory TypeC: ROMF: FlashP: OTPE: EPROM (for developmental use. There are few of these.)F a, F b: Family and Features10, 11: Basic12, 13: Hardware UART14: Hardware UART, Hardware Multiplier31, 32: LCD Controller33: LCD Controller, Hardware UART, Hardware M
9、ultiplier41: LCD Controller43: LCD Controller, Hardware UART44: LCD Controller, Hardware UART, Hardware MultiplierMc: Memory Capacity0: 1kb ROM, 128b RAM1: 2kb ROM, 128b RAM2: 4kb ROM, 256b RAM3: 8kb ROM, 256b RAM4: 12kb ROM, 512b RAM5: 16kb ROM, 512b RAM6: 24kb ROM, 1kb RAM7: 32kb ROM, 1kb RAM8: 48
10、kb ROM, 2kb RAM9: 60kb ROM, 2kb RAMExample: The MSP430F435 is a Flash memory device with an LCD controller, a hardware UART, 16 kb of code memory, and 512 bytes of RAM.The part numbering scheme described above is a bit fragmented. There are common features not consistently represented (type of ADC,
11、number of timers, etc), and there are some other inconsistencies (for example, the 33 family has the multiplier, but the 13 and 43s do not). I would recommend against selecting parts based on their numbering scheme. Rather, once you have a vague idea of your requirements, go to the TI website (www.T
12、I.com), and use their parametric sort feature.Architecture: CPU and MemoryAs discussed in chapter 1, the MSP430 utilizes a 16-bit RISC architecture, which is capable of processing instructions on either bytes or words. The CPU is identical for all members of the 430 family. It consists of a 3-stage
13、instruction pipeline, instruction decoding, a 16-bit ALU, four dedicated-use registers, and twelve working (or scratchpad) registers. The CPU is connected to its memory through two 16-bit busses, one for addressing, and the other for data. All memory, including RAM, ROM, information memory, special
14、function registers, and peripheral registers are mapped into a single, contiguous address space.This architecture is unique for several reasons. First, the designers at Texas Instruments have left an awful lot of space for future development. Almost half the Status Register remains available for fut
15、ure growth, roughly half of the peripheral register space is unused, and only six of the sixteen available special function registers are implemented.Second, there are plenty of working registers. After years of having one or two working registers, I greatly enjoyed my first experience with the twel
16、ve 16-bit CPU scratchpads. The programming style is slightly different, and can be much more efficient, especially in the hands of a programmer who knows how to use this feature to its fullest.Third, this architecture is deceptively straightforward. It is very flexible, and the addressing modes are
17、more complicated than most other small processors. But, beyond that, this architecture is simple, efficient and clean. There are two busses, a single linear memory space, a rather vanilla processor core, and all peripherals are memory-mapped.CPU FeaturesThe ALUThe 430 processor includes a pretty typ
18、ical ALU (arithmetic logic unit). The ALU handles addition, subtraction, comparison and logical (AND, OR, XOR) operations. ALU operations can affect the overflow, zero, negative, and carry flags. The hardware multiplier, which is not available in all devices, is implemented as a peripheral device, a
19、nd is not part of the ALU (see Chapter 6).Working RegistersThe 430 gives the developer twelve 16-bit working registers, R4 through R15. (R0 through R3 are used for other functions, as described later.) They are used for register mode operations (see Addressing Modes, Chapter 8), which are much more
20、efficient than operations which require memory access. Some guidelines for their use:Use these registers as much as possible. Any variable which is accessed often should reside in one of these locations, for the sake of efficiency.Generally speaking, you may select any of these registers for any pur
21、pose, either data or address. However, some development tools will reserve R4 and R5 for debug information. Different compilers will use these registers in different fashions, as well. Understand your tools.Be consistent about use of the working registers. Clearly document their use. I have code, wr
22、itten about 8 months ago, that performs extensive operations on R8, R9, and R15. Unfortunately, I dont know today what the values in R8, R9 and R15 represent. This was code I wrote to quickly validate an algorithm, rather than production code, so I didnt document it sufficiently. Now, it is relative
23、 gibberish. Dont let this happen to you. No matter how obvious or trivial register use seems, document it anyway.Constant GeneratorsR2 and R3 function as constant generators, so that register mode may be used instead of immediate mode for some common constants. (R2 is a dual use register. It serves
24、as the Status Register, as well.) Generated constants include some common single-bit values (0001h, 0002h, 0004h, and 0008h), zero (0000h), and an all 1s field (0FFFFh). Generation is based on the W(S) value in the instruction word, and is described by the table below.W(S) value in R2 value in R300
25、0000h 01 (0) (absolute mode) 0001h10 0004h 0002h11 0008h 0FFFFhProgram CounterThe Program Counter is located in R0. Since individual memory location addresses are 8-bit, but all instructions are 16 bit, the PC is constrained to even numbers (i.e. the LSB of the PC is always zero). Generally speaking
26、, it is best to avoid direct manipulation of the PC. One exception to this rule of thumb is the implementation of a switch, where the code jumps to a spot, dependent on a given value. (I.e., if value=0, jump to location0, if value=1, jump to location1, etc.) This process is shown in Example 3.1.Exam
27、ple 3.1 Switch Statement via Manual PC ControlMov value,R15 ;put the switch value into R15Cmp R15,#8 ;range checkingJge outofrange ;if R157,do not use PC switchCmp #0,R15 ;more range checkingJn outofrange ;Rla R15 ;multiply R15 by two,since PC is always evenRla R15 ;double R15again,since symbolic jm
28、p is 2 words longAdd R15,PC ;PC goes to proper jumpJmp value0Jmp value1Jmp value2Jmp value3Jmp value4Jmp value5Jmp value6Jmp value7OutofrangeJmp RangeErrorThis is a relatively common approach, and most C compilers will implement switch statements with something similar. When implementing this manual
29、ly (i.e., in assembly language), the programmer needs to keep several things in mind:Always do proper range checking. In the example, we checked for conditions outside both ends of the valid range. If this is not performed correctly, the code can jump to an unintended location.Pay close attention to
30、 the addressing modes of the jump statements. The second doubling of R15, prior to the add statement, is added because the jump statement requires two words when symbolic mode addressing is used.Be careful that none of your interrupt handlers have the potential to affect your value register (R15 in
31、the example). If the interrupt handler needs to use one of these registers, the handler needs to store the value to RAM first. The most common procedure is to push the register to the stack at the beginning of the ISR, and to pop the register at the end of the ISR. (See Example 3.2.)Example 3.2 Push
32、/Pop Combination in ISRTimer_A_Hi_Interrupt Push R12 ;We will use R12 Mov P1IN,R12 ;use R12 as we please Rla R12Rla R12Mov R12&BAR ;Done with R12Pop R12 ;Restore previous value to R12Reti ;return from interruptORG 0FFF0hDW Timer_A_Hi_InterruptStatus RegisterThe Status Register is implemented in R2,
33、and is comprised of various system flags. The flags are all directly accessible by code, and all but three of them are changed automatically by the processor itself. The 7 most significant bits are undefined. The bits of the SR are: The Carry Flag (C) Location: SR(0) (the LSB) Function: Identifies w
34、hen an operation results in a carry. Can be set or cleared by software, or automatically. 1=Carry occurred 0=No carry occurred The Zero Flag (Z) Location: SR(1) Function: Identifies when an operation results in a zero. Can be set or cleared by software, or automatically. 1=Zero result occurred0=Nonz
35、ero result occurred The Negative Flag (N) Location: SR(2) Function: Identifies when an operation results in a negative. Can be set or cleared by software, or automatically. This flag reflects the value of the MSB of the operation result (Bit 7 for byte operations, and bit 15 for word operations). 1=
36、Negative result occurred 0=Positive result occurred The Global Interrupt Enable (GIE)Location: SR(3)Function: Enables or disables all maskable interrupts. Can be set or cleared by software, or automatically. Interrupts automatically reset this bit, and the reti instruction automatically sets it.1=In
37、terrupts Enabled0=Interrupts Disabled The CPU off bit (CPUOff)Location: SR(4)Function: Enables or disables the CPU core. Can be cleared by software, and is reset by enabled interrupts. None of the memory, peripherals, or clocks are affected by this bit. This bit is used as a power saving feature.1=C
38、PU is on0=CPU is off The Oscillator off bit (OSCOff)Location: SR(5)Function: Enables or disables the crystal oscillator circuit (LFXT1). Can be cleared by software, and is reset by enabled external interrupts. OSCOff shuts down everything, including peripherals. RAM and register contents are preserv
39、ed. This bit is used as a power saving feature.1=LFXT1 is on0=LFXT1 is off The System Clock Generator (SCG1,SCG0)Location: SR(7),SR(6)Function: These bits, along with OSCOff and CPUOff define the power mode of the device. The Overflow Flag (V)Location: SR(8)Function: I dentifies when an operation re
40、sults in an overflow. Can be set or cleared by software, or automatically. Overflow occurs when two positive numbers are added together, and the result is negative, or when two negative numbers are added together, and the result is positive. 1=Overflow result occurred0=No overflow result occurredFou
41、r of these flags (Overflow, Negative, Carry, and Zero) drive program control, via instructions such as cmp (compare) and jz (jump if Zero flag is set). You will see these flags referred to often in this book, as their function represents a fundamental building block. The instruction set is detailed
42、in Chapter 9, and each base instruction description there details the interaction between flags and instructions. As a programmer, you need to understand this interaction.Stack PointerThe Stack Pointer is implemented in R1. Like the Program Counter, the LSB is fixed as a zero value, so the value is
43、always even. The stack is implemented in RAM, and it is common practice to start the SP at the top (highest valid value) of RAM. The push command moves the SP down one word in RAM (SP=SP-2), and puts the value to be pushed at the new SP. Pop does the reverse. Call statements and interrupts push the
44、PC, and ret and reti statements pop the value from the TOS (top of stack) back into the PC. I have one simple rule of thumb for the SP: leave it alone. Set the stack pointer as part of your initialization, and dont fiddle with it manually after that. As long as you are wary of two stack conditions,
45、the stack pointer manages itself. These two conditions are:Asymmetric push/pop combinations. Every push should have a pop. If you push a bunch of variables, and fail to pop them back out, it will come back to haunt you. If you pop an empty stack, the SP moves out of RAM, and the program will fail.St
46、ack encroachment. Remember, the stack is implemented in RAM. If your program has multiple interrupts, subroutine calls, or manual pushes, the stack will take up more RAM, potentially overwriting values your code needs elsewhere.Memory StructureSpecial Function RegistersSpecial function registers are
47、, as you might have guessed, memory-mapped registers with special dedicated functions. There are, nominally, sixteen of these registers, at memory locations 0000h through 000Fh. However, only the first six are used. Locations 0000h and 0001h contain interrupt enables, and locations 0002h and 0003h contain interrupt flags. These are described in Chapter 3.Locations 0004h and 0005h contain module enable flags. Currently, only two bits are implemented in each byte. Th