Full Transcript

ELEC 2520 Embedded Systems I NTRODUCTION Jaedo Park, Ph.D. 1 Brief History of Computers 1.1 Early Computers The concept of machine computation has existed since ancient times. To...

ELEC 2520 Embedded Systems I NTRODUCTION Jaedo Park, Ph.D. 1 Brief History of Computers 1.1 Early Computers The concept of machine computation has existed since ancient times. To go beyond the compu- tational power of the human hands, mankind has used tools for calculation such as the abacus, calculation sticks, and Napier’s bones (Fig. 1). Ancient Greek’s Antikythera Mechanism, which is an orrery to predict astronomical positions and eclipses, is known as the oldest known example of an analog computer (Fig. 1d). (a) (b) (c) (d) (e) (f) Figure 1: Early computers: (a) Roman abacus1. (b) Calculation sticks, (c) Napier’s Bone2. (d) A fragment of the Antikythera mechanism3. (e) Front panel of a 2007 re-creation of Antikythera mechanism4. (f) A small orrery showing Earth and the inner planets5. 0 Kim Traynor, CC BY-SA 3.0, 1 Mike Cowlishaw, CC BY-SA 3.0, 2 Namu, CC BY-NC-SA 2.0 KR, 3 Marasyas, 4 5 CC BY-SA 3.0 Unported, Mogi, CC BY-SA 3.0 Unported, Kaptain Kobold, CC BY 2.0 1 (a) (b) (c) Figure 2: 17th century mechanical calculators: (a) Replica of Schickards calculating machine6 , (b) Pascal’s calculator capable of addition and subtraction (1642)7. (b)Leibnitz’s calculator that can do four arithmetic operations (1671)8. (a) (b) (c) Figure 3: (a) Portion of the calculating machine with a printing mechanism of the analytical engine built by Charles Babbage9. (b)Two types of punched cards used to program the machine. Foreground: ’opera- tional cards’, for inputting instructions; background: ’variable cards’, for inputting10 , (c) Plan diagram of the Analytical Engine from 184011 In 17th century, mechanical calculators were invented including those capable of addition and subtraction (Figs. 2a, 2b: Schickard (1623), Pascal (1642), respectively) and four arithmetic oper- ations (Fig. 2c: Leibnitz, 1672). Charles Babbage’s Analytical Engine (1837, Fig. 3) is known as the ancestor of modern com- puters [2,3]. Babbage designed this mechanical computer after his Difference Engine, a mechanical calculator. Analytic Engine has a central processing unit, arithmetic logic unit, and integrated mem- ory (mechanical, of course) and it was programmable and able to take data input using punch cards. Although both of Babbage’s machines couldn’t be completed because government funding stopped and the engineering technology of the times was insufficient, he established the concept 6 Herbert Klaeren, CC BY-SA 4.0, 7 Rama, CC BY-SA 3.0, 8 Kolossos, CC BY-SA 3.0 9 Magnus Manske, CC 10 11 BY-SA 2.0, Karoly Lorentey, CC BY 2.0 ArnoldReinhold, CC BY 4.0 2 (a) (b) (c) Figure 4: First generation of modern computers: (a) Replica of the Atanasoff–Berry computer12. (b) Elec- tronic Numerical Integrator and Computer (ENIAC), (c) Early computer boards: from left: ENIAC (1945), EDVAC (1949), ORDVAC (1952), BRLESC-I (1962)13. of a programmable general-purpose computing machine. Mechanical computers were widely used until the invention of electronic computers in 1940s. 1.2 Modern Computers First generation of electronic computers were develped in later 1930s and 1940s using vacuum tubes as the primary electronic component for performing calculations and switching operations [4, 5]. These computers were large and occupied entire rooms. First-generation computers were programmed using machine language, which required the manual entry of instructions in binary code through switches or punch cards. Atanasoff–Berry Computer (ABC, 1937, Fig. 4a) and Elec- tronic Numerical Integrator and Computer (ENIAC, 1945, Fig. 4b) is knwon as the first automatic digital computer and the first programmable general-purpose digital computer, respectively. The next generation of computers from the late 1950s to the mid-1960s used transistors tran- sitioning from vacuum tubes, resulting in smaller, faster, and more reliable systems. The de- mand for ICBMs and aerospace systems drove the development of computer technology in this era [6–8]. Until the 1960s, computers were typically either mainframes, mini-computers, or micro- computers, depending on their sizes and computing power. These were central computers shared by users, similar to how we use supercomputers today. Each individual accessed and used the computer using terminals, which are input/output devices at the end of the network. Since then, as the electronic components advanced to integrated chips (ICs), large scale integra- tion (LSI), vastly large scale integration (VLSI) chips, computers became smaller and got higher performance. Apple Computer’s Apple II (Fig. 5a) and IBM’s Personal Computer (IBM PC, Fig. 5b) emerged as highly successful computer products and played pivotal roles in driving the per- sonal computer boom from the late 1970s to the 1980s. Early personal computers used 8- or 16-bit CPUs, floppy disks for program/data storage, and TV or small monochrome CRT (cathod-ray tube) monitor for display. The advent of personal computers was revolutionary as it provided ordinary 11 12 13 Manop, CC BY-SA 3.0, ArnoldReinhold, CC BY 4.0, U.S. Army Photo number 163-12-62 3 (a) (b) (c) Figure 5: Early personal computers: (a) Apple II (1977)14. (b) IBM Personal Computer (1981)15 , (c) Orig- inal IBM Personal Computer motherboard16. (a) (b) (c) Figure 6: Early mobile computers: (a) Osborne 1 (1981), the first commercially successful portable com- puter (24.5lb with 5-inch display)17 , (b) Psion Organiser I (1984), the first “practical pocket computer”18. EPROM is used for data storage, (c) Apple Newton Messagepad (1993) and the first Apple iPhone (2007)19. people with access to computers, previously limited to corporations, institutions, and a few experts. This breakthrough served as a catalyst for the information age we experience today. The increasing number of computer users paved the way for the development and widespread adoption of the Internet. This significant advancement marked the beginning of the mobile com- puting era in the 21st century, characterized by the prominent rise of laptop computers, tablet, and smartphones. These devices became symbolic of the transformative impact of technology on our daily lives. 14 15 Rama, CC BY-SA 2.0 fr, Rama & Musee Bolo, CC BY-SA 2.0 fr, 16 German, CC BY 3.0 17 The Centre for 18 Computing History, Blake Patterson, CC BY-SA2.0 4 2 Embedded Systems? 2.1 Definitions and Characteristics Embedded systems means computing systems for particular purposes, functions, controls, or tasks that are ‘mounted inside’ of a larger system that includes electronic and mechanical hardware. Embedded systems can be easily found in many of areas in our day-to-day life and we are very familiar with them. For example, microcontrollers and associated analog/digital circuits on printed circuit boards (PCBs) and software programs that control hardware and interface users (e.g., taking inputs and display information) in standalone systems such as kiosks, engine control units (ECUs), HVAC systems in vehicles, medical devices, flight control systems in airplanes, GPS, TVs, factory robots, microwaves, DVD players, vending machines, washing machines, and refrigerators can be referred as embedded systems. Embedded systems have a significant share of the microprocessor market, which was about $90.99 billion in 2022 and is forecasted to grow to $128 billion in 2030. On the other hand, a laptop or desktop computer is not an embedded system but a general-pur- pose computing platform running various applications on an operating system, such as Windows and Linux, because it can be used for numerous purposes such as word processing, games, web surfing, and programming. If an x86 processor, the one widely used for PC, is used only for a specific purpose, for example, in one of the Sony’s PlayStations, it can also be called an embedded system as it mainly performs a specific purpose of gaming. Typically, embedded systems are controlled by one or more processing units, which can be im- plemented with microcontrollers or digital signal processors (DSPs). Since an embedded system performs specific tasks only, it is common to store the program in memory permanently and execute it. This executable code stored in non-volatile memory such as flash memory or read-only mem- ory (ROM) is called firmware, compared to software in general. Because microcontrollers used in smaller-scale systems have limited computing power and hardware resources such as memory and storage, it is common for microcontroller-based systems to operate without an operating sys- tem. However, larger embedded systems with many functions can use operating system such as Windows CE or Embedded Linux. Even in these cases, only the applications for specific tasks are installed and executed. Figure 7: An embedded system on a plug-in card with processor, memory, power supply, and external interfaces19. 19 Pe wiki editor, CC BY-SA 3.0. 5 (a) (b) Figure 8: (a) Viatron System 21, 1968. The term “microprocessor” was used first time for its CPU boards [10–12]. (b)Viatron microprocessor board20. As tasks of embedded systems involve electronic and mechanical hardware components in most of cases, computing units of embedded systems, such as microcontroller or microprocessor boards, provide interface to external peripheral hardware, such as digital input/output (I/O), ana- log I/O, serial and parallel communications. However, unlike the higher performance and broader versatility preferred for general-purpose computers, embedded systems are optimized to be just enough for their specific tasks, e.g., minimum computing power and memory size, so that they can be manufactured with the lowest possible cost. Moreover, low power consumption design is an important factor for those operate on battery power. Reducing production costs is critical because many embedded systems are mass-produced in the millions. 3 Configurations and Terminology 3.1 Hardware An embedded system’s hardware typically consists of the following components. Microprocessor: Executes pre-programmed instructions (e.g., arithmetic operations, logic operations, data input/output, execution control) Memory: Stores instructions (i.e., compiled code) to be executed by the microprocessor and data I/O Devices: Transfer data between the outside and the inside of the system Sensors: collect information (e.g., temperature, pressure, humidity, speed, voltage, current) from outside the system The term microprocessor means an integrated chip (IC) that has central processing unit (CPU) of computers built into with micro-scale circuits, compared to those CPUs in early computers 20 Courtesy of UMMR, http://ummr.altervista.org/ 6 (a) (b) (c) (d) Figure 9: (a) Intel 4004, 197121. (b) Texas Instruments, TMS1000, 197422. (c) Intel 4004 architectures23. (d) TMS1000 architectures implemented with discrete components such as vacuum tubes and transistors. It is said that the term was first used in 1968 for the Viatron System 21 (Fig. 8a), although it referred a board (Fig. 8b) not a chip unlike what the term means today [10–12]. However, a microprocessor can be used for a subsystem or auxiliary part of the system, which may not be called as a CPU. Subsequently, microcontrollers were developed for control applications integrating memory and peripheral I/O components in addition to CPU into a single chip. While microprocessors are used for general-purpose computers like PCs with higher computing power, microcontrollers can be found in many embedded systems and optimized for hardware interface and control. Fig. 9 shows the first commercial microprocessor 4-bit Intel 4004 in 1971 and the first com- mercial microcontroller Texas Instrument 8-bit TMS1000 in 1974. Although they look similar, the conceptual difference can be seen in Figs. 9c and 9d, which show the components such as ROM, RAM, keyboard logic and control decoders in TMS1000 in addition to arithmetic logic unit (ALU). Numerous devices from many manufacturers with various features and purposes are available in today’s microprocessor and microcontroller market. For example, microprocessors and micro- 21 LucaDetomi at it.wikipedia, CC BY-SA 3.0, 22 Appaloosa, CC BY-SA 3.0, 23 Christian Bassow, CC BY-SA 4.0 7 Figure 10: Texas Instruments’ microprocessors and microcontrollers24. conroller product lines of Texas Instruments, one of the major industry players, are shown in Fig. 10. Exercise 3.1 Explain the following terms. 1. Embedded system and general-purpose computer 2. CPU, microprocessor, and microcontroller 3. Software and firmware 3.2 Software or Firmware Development 3.2.1 Development Environment As embedded systems are designed for specific functions and purposes, it is not common to directly develop a software in the embedded system itself like we write an application program for PC in a development environment running on PC. It is especially so when it comes to a microcontroller- based embedded systems. 24 Texas Instruments, Microcontrollers (MCUs) & Processors, https://www.ti.com/microcontrollers- mcus-processors/overview.html 8 Typically, the software or firmware for the embedded systems are developed on a PC using a series of tools. The PC that runs the development “environment” and the embedded system’s micro- controller is called host and target system, respectively. The development environment where the host and target system are different (e.g., Windows host PC and TMS320F28069M target) is called a cross development environment. Depending on the used embedded devices, microprocessor/mi- crocontroller, and programming language, various development environment can be implemented for developers. Generally, it is convenient to use the software development kit (SDK) or integrated development environment (IDE) provided by the processing unit manufacturer for embedded sys- tem software development. 3.2.2 Build Procedure and Required Tools Currently C language is dominantly used for embedded systems among other languages such as C++, Python, and Java, because of its compactness, portability, easy access to low-level hardware, and widely available development tools, to name a few [14–16]. Prior to using a high-level lan- guage like C, assembly language was generally used for embedded system firmware, which is a low-level language right above the machine language (i.e., instructions). It is small, fast, and pro- vides even better access to hardware as it is very close to machine language. Although assembly language can be advantageous when high-level of optimization is required, for example, for low performance CPU and limited RAM space or for time-critical systems, its low readability and lack of abstraction makes it difficult for humans to use in general. Furthermore, contemporary compil- ers are generating well-optimized assembly codes, which diminishes the need to directly work on low-level codes. Suppose you are writing a program in C language to run on an embedded system, starting with the following source code in main.c file. 1 int a = 1; 2 3 void main(void) 4 { 5 float b; 6 7 b = (float)a + 0.1; 8 } Listing 1: Initial main.c. Exercise 3.2 Review the following C language topics and explain the code in Listing 1. 1. Main function 2. Function return value 3. Variable types 4. Variable storage classes 5. Variable type casting 9 After you write and save into a file, next step to build an executable binary code is to “com- pile” using a compiler. Compilers translate a source code in one language into another, typically a high-level language to a lower-level one. In our case, it generates lower level assembly code from a high-level C source code. The compiler generates assembly code for the whole source code in a file. For the languages using compilers, such as C, C++, C#, and Java, a right compiler that generates assembly code that is compatible to your target system or microcontroller must be used. For example, if you are using Windows PC to develop firmware for TI’s TMS320F28069M board, the compiler should run on Windows and generate assembly code for TI’s microcontroller. These compilers that compile and generate output code for different target system are called cross com- pilers, compared to native compilers that generate code for the same hardware platform that they are running on. Following listing shows a portion of main.asm that is generated after your main.c is compiled. 1 ;*************************************************************** 2 ;* TMS320C2000 G3 C/C++ Codegen PC v22.6.0.LTS * 3 ;* Date/Time created: Tue Jun 6 14:23:21 2023 * 4 ;*************************************************************** 5.compiler_opts --abi=coffabi --cla_support=cla0 --diag_wrap=off --float_support=fpu32 --... hll_source=on --mem_model:code=flat --mem_model:data=large --object_format=coff --... silicon_errata_fpu1_workaround=on --silicon_version=28 --symdebug:dwarf --... symdebug:dwarf_version=3 --vcu_support=vcu0 6.asg XAR2, FP 7 8 $C$DW$CU.dwtag DW_TAG_compile_unit 9.dwattr $C$DW$CU, DW_AT_name("../main.c") 10.dwattr $C$DW$CU, DW_AT_producer("TI TMS320C2000 G3 C/C++ Codegen PC v22.6.0.LTS Copyright (... c) 1996-2018 Texas Instruments Incorporated") 11.dwattr $C$DW$CU, DW_AT_TI_version(0x01) 12.dwattr $C$DW$CU, DW_AT_comp_dir("C:\Users\Jaedo Park\workspace_v12\test\Debug") 13 ; C:\ti\ccs1220\ccs\tools\compiler\ti-cgt-c2000_22.6.0.LTS\bin\ac2000.exe -@C:\\Users\\JAEDOP¬... 1\\AppData\\Local\\Temp\\{ECA3FE8F-69D0-4534-83EF-6B7F08981462} 14.sect ".text" 15.clink 16.global _main 17 18 $C$DW$1.dwtag DW_TAG_subprogram 19.dwattr $C$DW$1, DW_AT_name("main") 20.dwattr $C$DW$1, DW_AT_low_pc(_main) 21.dwattr $C$DW$1, DW_AT_high_pc(0x00) 22.dwattr $C$DW$1, DW_AT_TI_symbol_name("_main") 23.dwattr $C$DW$1, DW_AT_external 24.dwattr $C$DW$1, DW_AT_TI_begin_file("../main.c") 25.dwattr $C$DW$1, DW_AT_TI_begin_line(0x08) 26.dwattr $C$DW$1, DW_AT_TI_begin_column(0x06) 27.dwattr $C$DW$1, DW_AT_TI_max_frame_size(-6) 28.dwpsn file "../main.c",line 9,column 1,is_stmt,address _main,isa 0 29 30.dwfde $C$DW$CIE, _main 31 32 ;*************************************************************** 33 ;* FNAME: _main FR SIZE: 4 * 34 ;* * 35 ;* FUNCTION ENVIRONMENT * 36 ;* * 37 ;* FUNCTION PROPERTIES * 38 ;* 0 Parameter, 3 Auto, 0 SOE * 39 ;*************************************************************** 40 41 _main: 10 42.dwcfi cfa_offset, -2 43.dwcfi save_reg_to_mem, 26, 0 44 ADDB SP,#4 ; [CPU_ARAU] 45.dwcfi cfa_offset, -6 46 $C$DW$2.dwtag DW_TAG_variable 47.dwattr $C$DW$2, DW_AT_name("b") 48.dwattr $C$DW$2, DW_AT_TI_symbol_name("_b") 49.dwattr $C$DW$2, DW_AT_type(*$C$DW$T$16) 50.dwattr $C$DW$2, DW_AT_location[DW_OP_breg20 -2] Listing 2: First 50 lines of main.asm. Then, the assembler takes the assembly code and translates it to object file (*.obj), which is a binary file readable by machine. An assembler can be a separate application or integrated in a compiler as well. However, object files are still not machine executable by themselves. Another step called linking is required to “link” separate object files from multiple source code files and other libraries into a single executable binary file “main.out”. Machine executable binary file contains list of processor-specific instructions translated from the source codes in binary format. All these executable building steps (Fig. 11) are done in the host Windows PC in our case. Next, we need to download this executable to the target system using a communication link between two systems. The binary file can be executed once it is appropriately placed in the memory of target system. Generally, a compiler, an assembler, a linker, a debugger, standard libraries, and an editor are integrated in a development environment, which provides convenient interface to the functions of build tools and resources. These tools are configurable with many options for customized procedure and outcomes. 3.2.3 Execution There are various ways to execute the binary stored in the memory. Typically, standalone embedded systems permanently store (program, burn, or flash, depending on the types of storage) the binary in non-volatile memory, such as ROM and Flash, which is slow to read and write, then copy it to RAM and execute. This procedure is called bootloading and the “bootloader” runs every time when the system turns on or resets. However, this method would be not suitable when the program is under development because it takes non-trivial amount of time to burn ROM or Flash. It is inefficient to repeat this procedure every time small changes are made in the code for debugging. Instead, most IDEs can directly read from, write to, and execute from RAM through various communication channels, such as JTAG (Joint Test action Group), USB, and UART. Or external emulator can be hooked up. This is commonly used to test and debug embedded systems as it saves a lot of time by bypassing the ROM/Flash programming and bootloading procedure when reset. However, as the binary is written in RAM, it vanished when the power cycles. Exercise 3.3 Explain the following. 1. High-level and low-level programming language 2. Abstraction 11 Figure 11: Executable building sequence. 3. Compiler, assembler, and linker 4. Cross compiler and native compiler 5. *.asm, *.obj, and *.out files 6. Machine executable binary file 4 ELEC2520: Course Outlook In this course, we will use the following microcontroller board and firmware development envi- ronment. Texas Instruments LAUNCHXL-F28069M Texas Instruments Code Composer Studio v12 Using these hardware and software, the following topics will be covered. 1. Hardware 2. Firmware Development Environment 3. Bootloading and Reset 4. Memory Management 5. Interrupts 6. General-Purpose Input/Output (GPIO) 7. Analog-Digital Conversion 8. Universal Asynchronous Receiver-Transmitter (UART) 9. Synchronous Peripheral Interface (SPI) 10. Inter-Integrated Circuit (I2C) 11. Pulse-Width Modulation (PWM) 12. Final project 12 References Wikipedia. Antikythera mechanism. [Online]. Available: https://en.wikipedia.org/wiki/ Antikythera mechanism J. Graham-Cumming. The 100-year leap: Charles Babbage’s Analytical Engine was a century before its time. So why not build it now? [Online]. Available: http: //radar.oreilly.com/2010/10/the-100-year-leap.html Wikipedia. Analygic Engine. [Online]. Available: https://en.wikipedia.org/wiki/Analytical engine T. M. H. of Computing. Stanford encyclopedia of philosophy archive. [Online]. Available: https://plato.stanford.edu/archives/win2017/entries/computing-history/#Flow Wikipedia. Vacuum Tube Computers. [Online]. Available: https://en.wikipedia.org/wiki/ Vacuum-tube computer Engineering and T. H. Wiki. Integrated Circuits and the Space Program and Missile Defense. [Online]. Available: https://ethw.org/Integrated Circuits and the Space Program and Missile Defense C. Vono. ICBMs and the first mass-produced ‘micro’ computers. [Online]. Avail- able: https://www.aerotechnews.com/blog/2021/01/24/icbms-and-the-first-mass-produced- micro-computers/ NASA. Computers in Spaceflight: The NASA Experience. [Online]. Available: https: //history.nasa.gov/computers/Computing.html Precedence Research. Microprocessor market size, share and growth analysis. [Online]. Available: https://www.precedenceresearch.com/microprocessor-market Wikipedia, the free encyclopedia. Viatron. [Online]. Available: https://en.wikipedia.org/wiki/ Viatron Viatron Computer Systems. System 21 is now! [Online]. Available: http://bitsavers.trailing- edge.com/pdf/viatron/ViatronSystem21Brochure.pdf ——. Viatron 21 system description. [Online]. Available: http://bitsavers.org/pdf/viatron/ VCS-21-CR 010 Viatron 2140 2150 GeneralDescr.pdf G. W. Boone and M. J. Cochran, “Variable function programmed calculator,” US Patent 4 074 351, Feb. 1978. D. Munoz. After All These Years, the World is Still Powered by C Programming. [On- line]. Available: https://www.toptal.com/c/after-all-these-years-the-world-is-still-powered- by-c-programming 13 W. G. Wong. Is C the Best Embedded Programming Language? [Online]. Avail- able: https://www.electronicdesign.com/technologies/embedded/article/21806180/is-c-the- best-embedded-programming-language EE Times and Embedded. 2019 Embedded Markets Study. [Online]. Avail- able: https://www.embedded.com/wp-content/uploads/2019/11/EETimes Embedded 2019 Embedded Markets Study.pdf A. W. Burks, “Electronic computing circuits of the ENIAC,” Proceedings of the IRE, vol. 35, no. 8, pp. 756–767, 1947. 14

Use Quizgecko on...
Browser
Browser