Tải bản đầy đủ (.pdf) (170 trang)

Embedded systems x

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (3.65 MB, 170 trang )

1 | P a g e

Embedded Systems X
TABLE OF CONTENTS
Table of Contents 1
Table of Figures 6
Table of Tables 8
Table of Programs 9
1 Fundamental Concepts 10
1.1 Embedded Systems 10
1.1.1 Component of an Embedded System: 10
1.1.2 Embedded System Considerations 10
1.1.3 Hardware 11
1.1.4 Real-Time 12
1.1.5 Embedded System Characteristics 13
1.2 Introduction to computers 13
1.3 I/O Ports 16
1.3.1 TM4C123 I/O ports 16
1.3.2 Type of I/O 16
1.4 CPU Registers 17
1.4.1 An ISA must address the following things 17
1.4.2 Popular ISA 17
1.4.3 Registers in ARM ISA 18
1.5 Assembly Language 19
1.5.1 Assembly Language 19
1.5.2 Instruction Format 22
1.5.3 Addressing Modes and Operands 22
1.6 Address Space 28
1.7 Software Development Process 29
1.8 Using Keil 31
2 | P a g e



1.8.1 Debug in simulation mode 31
1.8.2 Debug in real board 31
1.8.3 Troubleshooting 31
2 Introduction to C 34
3 Microcontroller Ports 39
3.1 Introduction – Overview of I/O Ports Mixed Signals 39
3.2 Stellaris LM4F120 and Tiva TM4C123 Launchpad I/O Pins 40
3.3 Basic concept of Input and Output ports 44
3.4 I/O Programming and the Direction Register 46
3.4.1 How to initialize parallel port? E.g. Port F 46
3.4.2 Software to initialize Port F 47
3.4.3 Writing friendly code 48
3.4.4 Bit-specific Addressing 49
3.5 Debugging Monitor Using an LED 51
3.6 Hardware Debugging Tools 52
3.7 Timing in Embedded Systems 52
4 Design and Development Process 53
4.1 Introduction 53
4.2 Product Life Cycle 53
4.2.1 Product life cycle and Requirements 53
4.2.2 Product life cycle – Design considerations 54
4.2.3 Requirements Document 55
4.2.4 Call graph 56
4.3 Successive Refinement 59
4.3.1 Structure programming 59
4.3.2 How to write software 61
5 Switches and LEDS 63
6 Arrays and Functional Debugging 64
6.1 Introduction 64

6.2 Debugging Theory 64
3 | P a g e

6.2.1 Intrusiveness 64
6.2.2 Black-box and White-box Testing 66
6.3 SysTick Timer 67
6.3.1 Working of the SysTick Timer 67
6.3.2 SysTick Initialization 68
6.3.3 Measuring time 70
6.4 Arrays 71
6.5 Strings 71
6.6 Functional Debugging 71
6.6.1 Testing and Debugging 71
6.6.2 Functional Debugging 72
6.6.3 Single Stepping 72
6.6.4 Print statement 73
6.6.5 Debugging dump 74
6.6.6 Safety Critical Situations 75
6.6.7 Debugging using Logic Analyzer 76
6.6.8 Debugging using Instrumentation 76
7 Finite State Machine 79
7.1 Introduction 79
7.2 Phase-Lock-Loop 79
7.2.1 Phase-Lock-Loop PLL 79
7.2.2 Crystal Timing 80
7.2.3 Controlling the clock source 83
7.2.4 Software work 84
7.2.5 Battery powered system 85
7.2.6 Low power design 85
7.3 Accurate Time Delays Using SysTick 86

7.4 Structures 87
7.5 FSMs with Indexed Structures 89
7.5.1 Introduction to FSMs 89
4 | P a g e

7.5.2 FSM concepts 91
7.5.3 Translation from graph to code 95
7.5.4 FSM controller 95
7.5.5 Traffic light demo 97
7.5.6 Advanced Topics 101
7.5.7 Line tracking robot 106
7.6 Stepper Motors 109
8 UART – The Serial Interface 110
8.1 Introduction 110
8.2 I/O Synchronization 110
8.2.1 Blind cycle 112
8.2.2 Busy Wait 112
8.2.3 Interrupt 116
8.2.4 Periodic Polling 117
8.2.5 DMA 117
8.3 Universal Asynchronous Receiver Transmitter – UART 117
8.3.1 How UARTs are used 117
8.3.2 Fundamentals of UART Operations 118
8.3.3 Definitions 119
8.3.4 RS232 120
8.3.5 Serial Transmission 121
8.3.6 Software to transmit and receive 122
8.3.7 TM4C123 UART 123
8.3.8 Setting the baud rate 125
8.3.9 Busy-Wait Software 125

8.4 Conversion 128
8.4.1 Conversion 128
8.4.2 Output decimal number 131
8.5 Distributed System 133
8.5.1 Topology 133
5 | P a g e

8.5.2 Distributed Systems 134
8.5.3 Chat tool program 135
8.5.4 Interfacing the Nokia 5110 using a Synchronous Serial Port 137
9 Interrupts 143
9.1 Introduction 143
9.2 Interrupt concepts 143


6 | P a g e

TABLE OF FIGURES
Figure 1: The basic components of a von Neumann computer include processor, memory
and I/O. 14
Figure 2: Harvard architecture of an ARM® Cortex-M-based microcontroller. 14
Figure 3: Architecture of TM4C123 microcontroller. 16
Figure 4: Registers on the ARM® Cortex-M processor. 18
Figure 5: The program status register of the ARM® Cortex-M processor. 19
Figure 6: An example of immediate addressing mode, data is in the instruction. 23
Figure 7: An example of indexed addressing mode, data is in memory. 24
Figure 8: An example of indexed addressing mode with offset, data is in memory. 25
Figure 9: Indexed addressing using R1 as a register pointer to access memory. Data is
moved into R0. Code space is where we place programs and data space is where we place
variables. 26

Figure 10: Memory map of the TM4C123. 29
Figure 11: Assembly language or C development process. 30
Figure 12: Flowchart symbols. 35
Figure 13: Flowchart showing the basic building blocks of structured programming. 36
Figure 14: Flowchart illustrating the process of making toast. 36
Figure 15: Flowchart illustrating the process waiting for four events. 37
Figure 16: I/O port pins for the LM4F120H5QR / TM4C123GH6PM microcontrollers 41
Figure 17: I/O Pin configuration 42
Figure 18: Switch and LED interfaces on the Tiva LaunchPad Evaluation Board. The zero
ohm resistors can be removed so the corresponding pin can be used for its regular purpose
43
Figure 19: Interface connectors on the Tiva LM4F120/TM4C123 LaunchPad Evaluation
Board 44
Figure 20: A read only input port allows the software to sense external digital signals 44
Figure 21: A readable output port allows the software to generate external digital signals
45
Figure 22: A bidirectional port can be configured as a read-only input port or a readable
output port 46
Figure 23: Product life cycle 54
Figure 24: A data flow graph showing how the position signal passes through the system.
56
Figure 25: A call graph for a simple position measurement system. 57
Figure 26: We can decompose a task using the building blocks of structured programming.
60
Figure 27: Successive refinement 62
7 | P a g e

Figure 28: Block diagram of the main clock tree on the LM4F/TM4C including the PLL. 81
Figure 29: A current sense amplifier can be used to measure instantaneous current to the
target. The blue trace shows the current path from supply to target. 85

Figure 30: Instantaneous current measured on a battery powered system. 86
Figure 31: A structure collects elements of different sizes and/or types into one object. 88
Figure 32: System's schematic which can be abstracted as an FSM 89
Figure 33: FSM Graph of bit 1 recognizing System 91
Figure 34: The output in a Moore depends just on the state. In a Mealy the output depends
on state and input 93
Figure 35: Traffic light interface with two sensors and 6 lights 97
Figure 36: Graphical form of a Moore FSM that implements a traffic light 98
Figure 37: A vending machine interfaced to a microcontroller 102
Figure 38: This Moore FSM implements a vending machine 103
Figure 39: Synchronization Mechanisms 111
Figure 40: The output device sets a flag when it has finished outputting the last data 112
Figure 41: The software must wait for the input device to be ready (I/O bound input
interface) 114
Figure 42: The software must wait for the output device to finish the previous operation
(I/O bound) 115
Figure 43: A FIFO queue can be used to pass data from a producer to a consumer. At any
given time there can be a variable number of elements stored in the FIFO. The order in
which data are removed is the same as the order the data are entered 115
Figure 44: UART usages on the LaunchPad 118
Figure 45: Basic UART operations 118
Figure 46 A serial data frame with 8-bit data, 1 start bit, 1 stop bit, and no parity bit 119
Figure 47: Hardware interface implementing an asynchronous RS232 channel. The
TM4C123 has eight UART ports 121
Figure 48: Flowcharts of InChar and OutChar using busy-wait synchronization 126
Figure 49: Successive refinement method for the iterative solution 132
Figure 50: A simple ring network with three nodes, linked using the serial ports 133
Figure 51: Distributed processing places input, output and processing at multiple locations
connected together with a network 134
Figure 52: Distributed using two LaunchPads connected together by the UARTs 136

Figure 53: Optional Nokia 5110 LCD. Notice the PCB gives the signal names. Use the signal
names not the pin numbers when connecting 138


8 | P a g e

TABLE OF TABLES
Table 1: Condition code suffixes used to optionally execution instruction. 21
Table 2: Address offsets used to specify individual data port bits 50
Table 3: Base Addresses for bit-specific addressing of ports A-F 50
Table 4: SysTick registers. 68
Table 5: Main clock registers (RCC2 in LM4F/TM4C only). 81
Table 6: Tabular form of a Moore FSM that implements a traffic light 99
Table 7: The commonly-used signals on the EIA-574 protocol 120
Table 8: Some UART registers. Each register is 32 bits wide. Shaded bits are zero 124


9 | P a g e

TABLE OF PROGRAMS
Program 1: Initialization of SysTick. 70
Program 2: Use of SysTick to measure elapsed time. 70
Program 3: Instrumentation dump. 75
Program 4: Instrumentation dump with filter 75
Program 5: Instrumentation to record the first 49 time differences. 76
Program 6: Instrumentation to count the number of mistakes. 77
Program 7: Inappropriate Delay function for the real board. 78
Program 8: Appropriate Delay function for the real board. 78
Program 9: Activate the LM4F/TM4C with a 16 MHz crystal to run at 80 MHz (C10_PLL.zip).
83

Program 10: Use of SysTick to delay for a specified amount of time (C10_SysTick_Wait).
87
Program 11: A function that accesses a structure. 89
Program 12: Data Structure Realization of a FSM of Bit 1 recognizing System 95
Program 13: FSM controller 96
Program 14: Linked data structure implementation of the traffic light controller 100
Program 15: Low-level input/output functions for the vending machine 104
Program 16: Vending machine controller 105
Program 17: Tracking robot controller 108
Program 18: Low level I/O functions for tracking robot 109
Program 19: Device driver functions that implement serial I/O (CC11_UART and
C11_Network): 127
Program 20: Unsigned ASCII string to decimal conversion 128
Program 21: Input an unsigned decimal number 129
Program 22: Print the voltage value to an output device (0≤n≤999) 130
Program 23: Unsigned decimal to ASCII string conversion 130
Program 24: Print unsigned 32-bit decimal number to an output device 131
Program 25: Iterative implementation of output decimal: 133
Program 26: High-level communication network (C11_Network) 137
Program 27: I/O port connections and the Nokia display: 140
Program 28: Some of the prototypes for LCD 141

10 | P a g e

1 FUNDAMENTAL CONCEPTS
1.1 EMBEDDED SYSTEMS
An embedded system is a microcomputer with mechanical, chemical, or electrical devices
attached to it, programmed for a specific dedicated purpose, and packaged up as a
complete system.
1.1.1 Component of an Embedded System:

It has a computer inside, and is embedded in many things:

Automotive


Bodies


Toys


Consumer Electronics


Home


Military


Cell phones


Industry



Computer: hidden inside of devices

x86: PC



ARM: A-series in Handheld devices



ARM computer:

A-series: in handheld devices


M-series: microcontrollers


R-series: Real-time

Inside of a computer:

Memory


I/O interface: connect components together, including hardware and software

1.1.2 Embedded System Considerations

Testing & Verifications


Profit: Market share + Cost



Power


Size


Time: correct answer + right response time

-->

Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×