EEE111A/B Microprocessors
|
|
- Ursula Davis
- 6 years ago
- Views:
Transcription
1 EEE111A/B Microprocessors Lecture 10: C for Microcontroller Programmers 1 Objectives To understand the differences between a high-level language and assembly language. To review the elements of programming in C. To be able to write simple routines in C to run on a PIC Microcontroller. 2 Revision In Lecture 9 we described the need to be able to write to or read from an external peripheral using built-in parallel ports. In more detail: The PIC16F84 has two integral parallel ports which connect to the external world via pins on the IC. Port A has five bits connected to pins RA4 RA0 corresponding to bits 5 through 0 of File 05. Port B has eight bits connected to pins RB7 RB0 corresponding to bits 7 through 0 of File 06. Any pin can be set up in software to be either an input (can be read by software as the corresponding bit in the port) or an output (can be twiddled by changing the corresponding bit in the port). Each port has a shadow Data Direction register in Bank 1, called a TRIS register. Each bit in a TRIS register controls the configuration of it s corresponding pin, with a 0 for Output and 1 for Input. TRISA is located at File h 85 in Bank 1 and controls the function of pins RA4 RA0. TRISB is located at File h 86 in Bank 1 and controls the function of pins RB7 RB0. For example to make pin RA0 an output and the rest of the Port A pins to be an input, we have: bsf STATUS,RP0 ; Switch to Bank1 movlw b ; Bit settings for RA0 to be Output movwf TRISA ; Copy to Direction A register bcf STATUS,RP0 ; Back to Bank0 1
2 Where a pin is configured as an input, you can read if its state is low (logic 0) or high (logic 1) by checking the corresponding bit in the appropriate port. For example: CHECK btfss PORTA,4 ; Check thestateof pin RA4. IF set THEN skip goto CHECK ; ELSE go to CHECK Where a pin is configured as an output, you can write to it making it low (logic 0) or high (logic 1) by clearing or setting the corresponding bit in the appropriate port. For example: PULSE bsf PORTA,0 ; Bring pin RA0 high. bcf PORTA,0 ; Bring pin RA0 low. goto PULSE ; and repeat forever! 3 High Level Languages All the programs we have written up to the moment have been in the natural language of the machine itself; in this case of the mid-range PIC family. Whilst assembly-level software is a quantum step up from pure binary machine-level code nevertheless there is still a oneto-one relationship between machine and assembly-level instructions. This means that the programmer is forced to think in terms of the computing machine s internal structure that is of registers and memory rather than in terms of the problem itself. What is this difficulty with machine-oriented language? In order to improve the effectiveness, quality and reusability of a program, the coding language should be independent of the underlying processor s architecture and should have a syntax more oriented to problem-solving. The difficulty in coding large programs in a computer s native language was clearly appreciated within a few years of the introduction of commercial systems. Apart from anything else, computers quickly became obsolete with monotonous regularity, and programs needed to be rewritten for each model introduction. Large applications programs, even at that time, required many thousands of lines of code. Programmers were as rare as hen s teeth and worth their weight in gold. It was quickly deduced that for computers to be a commercial success, a means had to be found to preserve the investment in scarce programmers time. In developing a universal language, independent of the host hardware, the opportunity would be taken to allow the programmer to express the code in a more natural syntax related to problem-solving rather than in terms of memory, registers and flags. Of course there are many different classes of problem tasks which have to be coded, so a large number of languages have been developed since. 1 Amongst the first were Fortran (FORmula TRANslation) and COBOL (COmmon Business Oriented Language) in the early 1950s. 1 A popular definition of a computer scientist is one who, when presented with a problem to solve, invents a new language instead! 2
3 The former has a syntax that is oriented to scientific problems and the latter to business applications. Despite being around for over 40 years, the inertia of the many millions of lines of code written has made sure that many applications are still written in these antique languages. Other popular languages include Algol (ALGOrithmic Language), BASIC, Pascal, Modula, Ada, C, C++ and Java. Although writing programs in a high-level language may be easier and more productive for the programmer, the process of translation from the high-level source code to the target machine code is much more complex than the assembly process you have used in the laboratory and we covered in Lecture 4 Figure 8 of which is reproduced below as Fig. 1 on page 12. The translation package for this a high-level language is called a compiler and the process compilation. This means that your computer doing this translation process needs to be more powerful and the compiler software will, obviously, cost more! Figure 2 on page 12 shows the process in a somewhat simplified manner. With today s powerful personal computers, the problem of computing resources is not an issue anymore; but the cost of compilers may be. Typically a compiler running on a PC which will convert to PIC code costs between 100 up to 1,500 although this may include other debugging tools. The choice of a high-level language for embedded targets is crucial. Of major importance is the size of the machine code generated by a high-level language task implementation as compared with the equivalent assembly-level solution. Most embedded MCU circuitry is lean and mean, such as the code in the MCU in your smart card. Lean translates to physically small and mean maps to low processing power and memory capacity and cost! Most low-cost MCUs have a low-capability processor with a few hundred bytes of RAM and a few kilobytes of ROM Program store at best. Thus to be of any use the high-level language and the compiler must generate code that, if not as efficient as assembly-level (low-level), at least is in the same ball park. By far the most common high-level language used to source code for embedded micro circuitry is C. Historically C was developed as a language for writing operating systems. At its simplest level, an operating system (OS) is a program which makes the detailed hardware operation of the computer s terminals, such as keyboard and disk organisation, invisible to the operator. As such, the writer of an OS must be able to poke about the various registers and memory of the computer s peripherals and easily integrate with assembly-level driver routines. As conventional high-level languages and their compilers were profligate with resources, depending on a rich and fast environment, assembly language was mandatory up to the early 1970s, giving intimate machine contact and tight fast code. However, the sheer size of such a project means that it is likely to be a team effort, with all the difficulties in integrating the code and foibles of several people. A great deal of self-discipline and skill is demanded of such personnel, as is attention to documentation. Even with all this, the final result cannot be easily transplanted to machines with other processors, needing a nearly complete rewrite. Apart from its use as the language of choice for embedded micro circuits, C (together with its C++ and Java object-oriented offspring) is without doubt the most popular generalpurpose programming language at the time of writing. It has been called by its detractors a high-level assembler. However, this closeness of C to assembly-level code, together with the ability to mix code based on both levels in the one program, is of particular benefit for 3
4 embedded targets. The main advantages of the use of high-level language as source code for embedded targets are: It is more productive, in the sense that it takes around the same time to write, test and debug a line of code irrespective of language. By definition, a line of high-level code is equivalent to several lines of assembly code. Syntax is more oriented to human problem-solving. This improves productivity and accuracy, and makes the code easier to document, debug, maintain and adapt to changing circumstances. Programs are easier to port to different hardware platforms, although they are rarely 100% portable. Thus they are likely to have a longer productive life, being relatively immune to hardware developments. As such code is relatively hardware-independent, the customer base is considerably larger. This gives an economic impetus to produce extensive support libraries of standard functions, such as mathematical and communication modules, which can be reused in many projects. Of course there are disadvantages as well, specifically when code is being produced to run in poorly resourced micro-based circuitry. The code produced is less space-efficient and often runs more slowly than native assembly code. The compiler is much more expensive than an assembler. A professional product will often cost several thousand. Debugging can be difficult, as the actual code executed by the target processor is the generated assembler code. The processor does not execute high-level code directly. Products that facilitate high-level debugging are, again, very expensive. The majority of code now written for micros is now written in C or in a mixture of C and assembler languages. No matter what high-level language we use, the road from human thought to the summit of binary code that the machine can understand is shown in a rather diagrammatic form in Fig. 3 on page Human thought analyses the problem and devises a process to solve the problem; that is an algorithm. 2. Algorithm is converted to high-level language and typed in as source code. 3. A compiler is used to translate from high-level source syntax to low-level assembler syntax. 4. Assembler code is then added to other material, such as mathematics libraries, to give the machine code which the hardware will execute. 4
5 4 The C Language PIC Enhanced C compilers for micros usually use the standard C language, but with additions to make more easy use of the features that micros have; such as port pins. These additions also try and make the nasty realities of the hardware, such as bank switching and configuring pins, either invisible or at least easy to use. Any PIC-specific syntax below is that of the CCS compiler 2 which you will be using next year. This is not the place to learn a new language; you all are doing/have done an introductory module in C, so here we will just look at the very bare bones of the language. 4.1 Program Structure A typical skeleton structure of a C program looks like table 1. #include <header> /* Header files typically gives some info on library functions */ #byte /* Tell the compiler the location of a special purpose register */ #bit /* Givea bit in a Filea name */ function declarations;/* Any function besides main() should be named here with details */ global variables; /* Variables defined here are known throughout the program */ main() /* All C programs must havea main function */ /* Begin */ local variables /* Variables defined here are known only inside main() */ setup-up PIC ports /* For example, configure the port pins */ do this; /* Various statements */ call that; /* and interspaced with calls to other functions */ do the other; /* More statements */ etc; /* End */ /* Secondary functions. Any other functions are defined here */ function1() /* They havethesamestructureas main() and can becalled from */ /* main() or from other functions */ local variables; /* Variables defined here are known only inside function1() */ do this; call that; etc; function2() Local variables; /* Variables defined here are known only inside function2() */ do this; call that; etc; Table 1: Program structure. 2 Go to for more details. 5
6 #include This is a directive which allows the programmer to include header files, which typically give the compiler some information regarding library functions, such as the input/output (e.g. printf(), scanf()). In the case of the CCS PIC compiler, headers are used to give the compiler some information regarding the type of PIC; e.g. #include<16f84.h>. #byte A directive peculiar to the CCS compiler allowing the programmer to give a fixed File location a name; e.g. #byte FUEL = 6 /* Fuel is read at File 06; i.e. Port B */ where the /* bla bla */ pair is used by C to denote a comment. #bit A directive peculiar to the CCS compiler allowing the programmer to give a specified bit in any File location a name; e.g. #bit RED_LED = 5.0 /* TheRed LED is bit0 of File05 (or Port A) */ Global Variables Variables are defined as either integral (whole numbers) or floating-point (fractional-numbers). The former are of more use with microcontrollers and come in short, long, signed and unsigned varieties. If variables are named and defined in the preamble, then they are known everywhere in the program. Function Declarations Any user function, besides main() should be named in the preamble giving the type of variables being passed to the function and the type being returned. For example: /* count_of_ones is a function expecting a long int and returning an int */ int count_of_ones(long int); Main function All C programs have a main() function. Local Variables Variables used in a function should normally be defined at the beginning, before any executable code. Such variables will only be known inside the function. Executable Code After local variable definitions the body of a function consists of statements and calls to other functions. Secondary Functions Any functions besides the obligatory main() function are defined outside the main() function. They have the same structure as main() and can be called from main() or from themselves. Any local variables defined inside these secondary functions are known only within the function itself. 6
7 4.2 Selection Structures A selection structure is a way to make a decision. For example to increment a variable called number1 provided it is less than six or else to zero it, we have: if(number1 >= 5) number1 = 0; else number1++; where we are using the if-else structure to do the first statement if the outcome in the brackets following the if operator is true. The optional else gives a default action if the outcome is false. There doesn t have to be an if outcome. Note the use of the >= operator to denote Greater Than or Equivalent. Similar operators are == for Equivalent,!= for Not Equivalent, > for Greater Than, <= for Less Than or Equivalent and < for plain Less Than. Note that statements always are terminated with a semicolon ;. Actions can be compound statements with multiple statements enclosed in parenthesis; for example: if(fuel < 20) alarm = 0; lamp = 1; Multiple decisions can be made using a series of if-else-if tests. For example: if(fuel > 20) GREEN_LED = 1; RED_LED = 0; AMBER_LED = 0; BUZZER = 0; else if((fuel < 20) && (fuel >= 14)) GREEN_LED = 0; RED_LED = 0; AMBER_LED = 1; BUZZER = 0; else if((fuel < 15) && (fuel >= 8)) GREEN_LED = 0; RED_LED = 1; AMBER_LED = 0; BUZZER = 0; else GREEN_LED = 0; RED_LED = 1; AMBER_LED = 0; BUZZER = 1; As soon as a true test outcome is found, the adjacent statement is executed and the program jumps out of the if-else chain. In our example, if nothing is true the final else is executed. 7
8 4.3 LoopConstructions while The while loop structure is the fundamental method used to create a loop to do something a number of times, or even forever. For example find the integer square of a variable called number we have: i = 1; /* i is a number that is going to increment each loop pass*/ while(i < number) number = number - i; i = i + 2; root = i» 1;/* Notetheuseof» 1 to shift right once*/ where the program loops inside the Begin and End parenthesis until the test i < number fails. Execution then jumps to the first statement after the End parenthesis. Note that you can use the instruction break to prematurely jump completely out of the loop before time and the instruction continue to stop processing inside the loop and return to the top do-while This is similar to a plain while but the loop test for exit is done at the end of the loop. This means that the code inside the loop will always be executed at least once. For example: #bit RA0 = 5.0 /* Definepin RA0 as bit0 of File5 */ #bit RB7 = 6.7 /* Definepin RB7 as bit7 of File6 */ do RA0 = 1; /* Bring pin RA0 high */ RA0 = 0; /* Bring pin RA0 low */ while(rb7 == 1); /* as long as pin RB7 is high */ will keep pulsing pin RA0 as long as pin RB7 remains high. But even if pin RB7 is low, one pulse will be generated for The for loop constructor is really an enhanced while loop, which allows an initialisation on entry and an action at the end of each loop. For example to repeat the while example above: 8
9 for(i = 1; i < number; i = i + 2) number = number - i; root = i» 1 5 Examples 5.1 Example 1 To repeat Example 2 from Lecture 9 continually pulsing pin RB7 high and low every 6 µs. /* Preamble */ #include <16f84.h> /* Tell compiler to generate code for PIC16F84 */ #use delay(clock = ) /* Tell compiler clock is 4 MHz for delay functions*/ /* Main function */ main() set_tris_b(0x7f); /* Built-in function to set up TRIS regs. 0x7F = b */ while(true) /* Goes forever as TRUE is always TRUE */ output_high(pin_b7); /* Built-in function to bring a named pin high */ delay_us(3); /* Built-in function to delay microseconds */ output_low(pin_b7); /* Built-in function to bring a named pin low */ delay_us(3); Note the use of the built-in function set_tris_x() (known through the library header 16f84.h) to set up the TRISB register appropriately. The standard C prefix 0x denotes hexadecimal. Also there are a range of delay functions available to the programmer to give a fixed number of instructions (delay_cycles(n)), or number of milliseconds (delay_ms(n)) with n up to 65,535. Thus delay_ms(1000) will give a delay of a second. Also the built-in functions output_high(pin) and output_low(pin) know pins by their name. There is also an input(pin) function. Actually the program above is not very accurate, as the delay of the output_low(pin) and output_high(pin) functions take some time to execute. 5.2 Example 2 Repeat Example 4 of Lecture 9 to monitor the petrol reserve with a dashboard display. 9
10 #include<16f84.h> #byte FUEL = 06 /* Read Fuel at Port B (File 6) */ #bit RED_LED = 5.0 /* The Red LED is connected to bit0 of Port A (RA0) */ #bit GREEN_LED = 5.1 /* The Green LED is connected to bit1 of Port A (RA1) */ #bit BUZZER = 5.2 /* The Buzzer is connected to bit2 of Port A (RA2) */ main() set_tris_a(0xf8); /* b sets bottom 3 pins of Port A as Outputs*/ if(fuel > 10) GREEN_LED = 1; BUZZER = 0; RED_LED = 0; else if(fuel > 5) GREEN_LED = 0; BUZZER = 0; RED_LED = 1; else GREEN_LED = 0; BUZZER = 1; RED_LED = 0; The program says it all. In fact self documentation is one of the more important advantages of using a high-level language. Self Assessment Questions 1. Alter Example 1 to give a nominal 1 khz pulse rate. How would you alter your program if the clock rate were 20 MHz? 2. Based on the above, add code that will only commence this pulsing if the state of Port B is above decimal Modify Example 2 above with an Amber LED connected to pin RA3. This Amber LED is to light if the Fuel level is between 8 and 10 litres. 4. A digitally controlled oscillator is to be based on a PIC16F84 microcontroller. The period of the pulse from pin RA0 is to be in multiples of 100 µs, proportional to the reading from Port B. Thus, for example, if the Port B reading is 05 then the total period is to be 500 µs. Assume that the crystal clock is 20 MHz. 10
11 6 Key Concepts Assembly language C language A symbolic representation with a one-to-relationship to machine code. High-level language Machine code L A T E X2ε eee111_10.tex Version S.J. Katzen April 10,
12 Source code Assembler Machine code incf COUNT,f movf COUNT,w addlw 6 btfsc STATUS,DC movwf COUNT Translate return Figure 1: Conversion from assembly-level source code to machine code. while(n>0) sum = sum + n; --n; (a) First, compile to assembly-level code. Compile L28 movf _n,f btfsc STATUS,Z goto L41 movf _n,f addwf _sum,f btfsc STATUS,C incf _sum+1,f decf _n,f goto L28 L41 L28 movf _n,f btfsc STATUS,Z goto L Assemble movf _n,f addwf _sum,f btfsc STATUS,C incf _sum+1,f decf _n,f goto L L (b) Second, assemble-link to machine code. Figure 2: Conversion from high-level C source code to machine code. 12
13 Figure 3: Onion skin view of the steps leading to an executable program. 13
EEE111A/B Microprocessors
EEE111A/B Microprocessors Revision Notes Lecture 1: What s it all About? Covers the basic principles of digital signals. The intelligence of virtually all communications, control and electronic devices
More informationEmbedded Systems. PIC16F84A Sample Programs. Eng. Anis Nazer First Semester
Embedded Systems PIC16F84A Sample Programs Eng. Anis Nazer First Semester 2017-2018 Development cycle (1) Write code (2) Assemble / compile (3) Simulate (4) Download to MCU (5) Test Inputs / Outputs PIC16F84A
More informationLesson 14. Title of the Experiment: Introduction to Microcontroller (Activity number of the GCE Advanced Level practical Guide 27)
Lesson 14 Title of the Experiment: Introduction to Microcontroller (Activity number of the GCE Advanced Level practical Guide 27) Name and affiliation of the author: N W K Jayatissa Department of Physics,
More informationPIC PROGRAMMING START. The next stage is always the setting up of the PORTS, the symbol used to indicate this and all Processes is a Rectangle.
PIC PROGRAMMING You have been introduced to PIC chips and the assembly language used to program them in the past number of lectures. The following is a revision of the ideas and concepts covered to date.
More informationTOPIC 3 INTRODUCTION TO PIC ASSEMBLY LANGUAGE. E4160 Microprocessor & Microcontroller System. Prepared by : Puziah Yahaya JKE, POLISAS / DEC 2010
TOPIC 3 INTRODUCTION TO PIC ASSEMBLY LANGUAGE Prepared by : Puziah Yahaya JKE, POLISAS / DEC 2010 E4160 Microprocessor & Microcontroller System Learning Outcomes 2 At the end of this topic, students should
More informationWeek1. EEE305 Microcontroller Key Points
Week1 Harvard Architecture Fig. 3.2 Separate Program store and Data (File) stores with separate Data and Address buses. Program store Has a 14-bit Data bus and 13-bit Address bus. Thus up to 2 13 (8K)
More informationCONNECT TO THE PIC. A Simple Development Board
CONNECT TO THE PIC A Simple Development Board Ok, so you have now got your programmer, and you have a PIC or two. It is all very well knowing how to program the PIC in theory, but the real learning comes
More information16.317: Microprocessor Systems Design I Fall 2013 Exam 3 Solution
16.317: Microprocessor Systems Design I Fall 2013 Exam 3 Solution 1. (20 points, 5 points per part) Multiple choice For each of the multiple choice questions below, clearly indicate your response by circling
More informationUNIVERSITY OF ULSTER UNIVERSITY EXAMINATIONS : 2001/2002. Semester 2. Year 2 MICROCONTROLLER SYSTEMS. Module Code: EEE305J2. Time allowed: 3 Hours
UNIVERSITY OF ULSTER UNIVERSITY EXAMINATIONS : 2001/2002 Semester 2 Year 2 MICROCONTROLLER SYSTEMS Module Code: EEE305J2 Time allowed: 3 Hours Answer as many questions as you can. Not more than TWO questions
More informationExplanation of PIC 16F84A processor data sheet Part 1: overview of the basics
Explanation of PIC 16F84A processor data sheet Part 1: overview of the basics This report is the first of a three part series that discusses the features of the PIC 16F94A processor. The reports will refer
More informationAPPLICATION NOTE Wire Communication with a Microchip PICmicro Microcontroller
Maxim > App Notes > 1-Wire DEVICES BATTERY MANAGEMENT Keywords: 1-wire, PICmicro, Microchip PIC, 1-Wire communication, PIC microcontroller, PICmicro microcontroller, 1 wire communication, PICs, micros,
More informationPIC 16F84A programming (II)
Lecture (05) PIC 16F84A programming (II) Dr. Ahmed M. ElShafee ١ Introduction to 16F84 ٣ PIC16F84 belongs to a class of 8-bit microcontrollers of RISC architecture. Program memory (FLASH) EEPROM RAM PORTA
More informationUNIVERSITY OF ULSTER UNIVERSITY EXAMINATIONS : 2001/2002 RESIT. Year 2 MICROCONTROLLER SYSTEMS. Module Code: EEE305J1. Time allowed: 3 Hours
UNIVERSITY OF ULSTER UNIVERSITY EXAMINATIONS : 2001/2002 RESIT Year 2 MICROCONTROLLER SYSTEMS Module Code: EEE305J1 Time allowed: 3 Hours Answer as many questions as you can. Not more than TWO questions
More information1 Introduction to Computers and Computer Terminology Programs Memory Processor Data Sheet Example Application...
Overview of the PIC 16F648A Processor: Part 1 EE 361L Lab 2.1 Last update: August 19, 2011 Abstract: This report is the first of a three part series that discusses the features of the PIC 16F684A processor,
More informationSOLUTIONS!! DO NOT DISTRIBUTE!!
THE UNIVERSITY OF THE WEST INDIES EXAMINATIONS OF FEBRUARY MID-TERM 2005 Code and Name of Course: EE25M Introduction to Microprocessors Paper: Date and Time: Duration: One Hour INSTRUCTIONS TO CANDIDATES:
More informationME 6405 Introduction to Mechatronics
ME 6405 Introduction to Mechatronics Fall 2006 Instructor: Professor Charles Ume Microchip PIC Manufacturer Information: Company: Website: http://www.microchip.com Reasons for success: Became the hobbyist's
More informationUniversity of Jordan Faculty of Engineering and Technology Department of Computer Engineering Embedded Systems Laboratory
University of Jordan Faculty of Engineering and Technology Department of Computer Engineering Embedded Systems Laboratory 0907334 6 Experiment 6:Timers Objectives To become familiar with hardware timing
More informationLecture (04) PIC16F84A (3)
Lecture (04) PIC16F84A (3) By: Dr. Ahmed ElShafee ١ Central Processing Unit Central processing unit (CPU) is the brain of a microcontroller responsible for finding and fetching the right instruction which
More informationMechatronics and Measurement. Lecturer:Dung-An Wang Lecture 6
Mechatronics and Measurement Lecturer:Dung-An Wang Lecture 6 Lecture outline Reading:Ch7 of text Today s lecture: Microcontroller 2 7.1 MICROPROCESSORS Hardware solution: consists of a selection of specific
More informationDept. of Computer Engineering Final Exam, First Semester: 2016/2017
Philadelphia University Faculty of Engineering Course Title: Embedded Systems (630414) Instructor: Eng. Anis Nazer Dept. of Computer Engineering Final Exam, First Semester: 2016/2017 Student Name: Student
More informationSOLUTIONS!! DO NOT DISTRIBUTE PRIOR TO EXAM!!
THE UNIVERSITY OF THE WEST INDIES EXAMINATIONS OF APRIL MID-TERM 2005 Code and Name of Course: EE25M Introduction to Microprocessors Paper: MidTerm Date and Time: Thursday April 14th 2005 8AM Duration:
More informationLaboratory Exercise 5 - Analog to Digital Conversion
Laboratory Exercise 5 - Analog to Digital Conversion The purpose of this lab is to control the blinking speed of an LED through the Analog to Digital Conversion (ADC) module on PIC16 by varying the input
More informationFlow Charts and Assembler Programs
Flow Charts and Assembler Programs Flow Charts: A flow chart is a graphical way to display how a program works (i.e. the algorithm). The purpose of a flow chart is to make the program easier to understand.
More informationLAB WORK 2. 1) Debugger-Select Tool-MPLAB SIM View-Program Memory Trace the program by F7 button. Lab Work
LAB WORK 1 We are studying with PIC16F84A Microcontroller. We are responsible for writing assembly codes for the microcontroller. For the code, we are using MPLAB IDE software. After opening the software,
More information1 Introduction to Computers and Computer Terminology Programs Memory Processor Data Sheet... 4
Overview of the PIC 16F648A Processor: Part 1 EE 361L Lab 2.1 Last update: August 1, 2016 Abstract: This report is the first of a three part series that discusses the features of the PIC 16F648A processor,
More informationMobile Computing Professor Pushpendra Singh Indraprastha Institute of Information Technology Delhi Java Basics Lecture 02
Mobile Computing Professor Pushpendra Singh Indraprastha Institute of Information Technology Delhi Java Basics Lecture 02 Hello, in this lecture we will learn about some fundamentals concepts of java.
More information16.317: Microprocessor-Based Systems I Summer 2012
16.317: Microprocessor-Based Systems I Summer 2012 Exam 3 Solution 1. (20 points, 5 points per part) Multiple choice For each of the multiple choice questions below, clearly indicate your response by circling
More informationMICROPROCESSORS A (17.383) Fall Lecture Outline
MICROPROCESSORS A (17.383) Fall 2010 Lecture Outline Class # 03 September 21, 2010 Dohn Bowden 1 Today s Lecture Syllabus review Microcontroller Hardware and/or Interface Programming/Software Lab Homework
More informationControl Structures. Code can be purely arithmetic assignments. At some point we will need some kind of control or decision making process to occur
Control Structures Code can be purely arithmetic assignments At some point we will need some kind of control or decision making process to occur C uses the if keyword as part of it s control structure
More informationECE Test #1: Name
ECE 376 - Test #1: Name Closed Book, Closed Notes. Calculators Permitted. September 23, 2016 20 15 10 5 0
More informationAssembly Language Instructions
Assembly Language Instructions Content: Assembly language instructions of PIC16F887. Programming by assembly language. Prepared By- Mohammed Abdul kader Assistant Professor, EEE, IIUC Assembly Language
More informationEECE.3170: Microprocessor Systems Design I Summer 2017 Homework 5 Solution
For each of the following complex operations, write a sequence of PIC 16F1829 instructions that performs an equivalent operation. Assume that X, Y, and Z are 16-bit values split into individual bytes as
More informationCENG 336 INT. TO EMBEDDED SYSTEMS DEVELOPMENT. Spring 2006
CENG 336 INT. TO EMBEDDED SYSTEMS DEVELOPMENT Spring 2006 Recitation 01 21.02.2006 CEng336 1 OUTLINE LAB & Recitation Program PIC Architecture Overview PIC Instruction Set PIC Assembly Code Structure 21.02.2006
More informationWhen JP1 is cut, baud rate is Otherwise, baud rate is Factory default is that JP1 is shorted. (JP1 is jumper type in some model)
ELCD SERIES INTRODUCTION ALCD is Serial LCD module which is controlled through Serial communication. Most of existing LCD adopts Parallel communication which needs lots of control lines and complicated
More informationPIC Discussion. By Eng. Tamar Jomaa
PIC Discussion By Eng. Tamar Jomaa Chapter#2 Programming Microcontroller Using Assembly Language Quiz#1 : Time: 10 minutes Marks: 10 Fill in spaces: 1) PIC is abbreviation for 2) Microcontroller with..architecture
More informationThe University of Texas at Arlington Lecture 5
The University of Texas at Arlington Lecture 5 CSE 3442/5442 LCD Discussed in Chapter 12 RS, R/W, E Signals Are Used to Send/Receive Data on D0-D7 2 PIC PROGRAMMING IN C CHAPTER 7 Chapter 7 discusses the
More informationME 515 Mechatronics. A microprocessor
ME 515 Mechatronics Microcontroller Based Control of Mechanical Systems Asanga Ratnaweera Department of Faculty of Engineering University of Peradeniya Tel: 081239 (3627) Email: asangar@pdn.ac.lk A microprocessor
More informationChapter 4 Sections 1 4, 10 Dr. Iyad Jafar
Starting to Program Chapter 4 Sections 1 4, 10 Dr. Iyad Jafar Outline Introduction Program Development Process The PIC 16F84A Instruction Set Examples The PIC 16F84A Instruction Encoding Assembler Details
More informationChapter 3: Further Microcontrollers
Chapter 3: Further Microcontrollers Learning Objectives: At the end of this topic you will be able to: recall and describe the structure of microcontrollers as programmable assemblies of: memory; input
More informationPhysics 335 Intro to MicroControllers and the PIC Microcontroller
Physics 335 Intro to MicroControllers and the PIC Microcontroller May 4, 2009 1 The Pic Microcontroller Family Here s a diagram of the Pic 16F84A, taken from Microchip s data sheet. Note that things are
More informationCENG-336 Introduction to Embedded Systems Development. Timers
CENG-336 Introduction to Embedded Systems Development Timers Definitions A counter counts (possibly asynchronous) input pulses from an external signal A timer counts pulses of a fixed, known frequency
More informationMicro II and Embedded Systems
16.480/552 Micro II and Embedded Systems Introduction to PIC Microcontroller Revised based on slides from WPI ECE2801 Moving Towards Embedded Hardware Typical components of a PC: x86 family microprocessor
More informationUnit. Programming Fundamentals. School of Science and Technology INTRODUCTION
INTRODUCTION Programming Fundamentals Unit 1 In order to communicate with each other, we use natural languages like Bengali, English, Hindi, Urdu, French, Gujarati etc. We have different language around
More informationLearning Objectives:
Topic 5.2.1 PIC microcontrollers Learning Objectives: At the end of this topic you will be able to; Recall the architecture of a PIC microcontroller, consisting of CPU, clock, data memory, program memory
More informationBIL 104E Introduction to Scientific and Engineering Computing. Lecture 1
BIL 104E Introduction to Scientific and Engineering Computing Lecture 1 Introduction As engineers and scientists why do we need computers? We use computers to solve a variety of problems ranging from evaluation
More informationEE 367 Introduction to Microprocessors Homework 6
EE 367 Introduction to Microprocessors Homework 6 Due Wednesday, March 13, 2019 Announcements: Midterm on March 27 th The exam will cover through Lecture notes, Part 6; Lab 3, Homework 6, and readings
More informationInterfacing PIC Microcontrollers. ADC8BIT2 Schematic. This application demonstrates analogue input sampling
Interfacing PIC Microcontrollers ADC8BIT2 Schematic This application demonstrates analogue input sampling A manually adjusted test voltage 0-5V is provided at AN0 input A reference voltage of 2.56V is
More informationC and Embedded Systems. So Why Learn Assembly Language? C Compilation. PICC Lite C Compiler. PICC Lite C Optimization Results (Lab #13)
C and Embedded Systems A µp-based system used in a device (i.e, a car engine) performing control and monitoring functions is referred to as an embedded system. The embedded system is invisible to the user
More informationIntroduction. Embedded system functionality aspects. Processing. Storage. Communication. Transformation of data Implemented using processors
Input/Output 1 Introduction Embedded system functionality aspects Processing Transformation of data Implemented using processors Storage Retention of data Implemented using memory Communication Transfer
More informationFigure 1: Pushbutton without Pull-up.
Chapter 7: Using the I/O pins as Inputs. In addition to working as outputs and being able to turn the I/O pins on and off, these same pins can be used as inputs. In this mode the PIC is able to determine
More informationALU and Arithmetic Operations
EE25M Introduction to microprocessors original author: Feisal Mohammed updated: 6th February 2002 CLR Part IV ALU and Arithmetic Operations There are several issues connected with the use of arithmetic
More informationHow Stuff Works: Processors
How Stuff Works: Processors Principles and Examples Joe Finney joe@comp.lancs.ac.uk Aims Today we re going to Discuss the purpose for Assembly Language Review the common principles on which Assembly Languages
More informationWeekly Report: Interactive Wheel of Fortune Week 4 02/014/07-02/22/07 Written by: Yadverinder Singh
Work Completed: Weekly Report: Interactive Wheel of Fortune Week 4 02/014/07-02/22/07 Written by: Yadverinder Singh Last week started with the goal to complete writing the overall program for the game.
More informationDHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING. EE Microcontroller Based System Design
DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING EE6008 - Microcontroller Based System Design UNIT III PERIPHERALS AND INTERFACING PART A 1. What is an
More informationChapter 5 Sections 1 6 Dr. Iyad Jafar
Building Assembler Programs Chapter 5 Sections 1 6 Dr. Iyad Jafar Outline Building Structured Programs Conditional Branching Subroutines Generating Time Delays Dealing with Data Example Programs 2 Building
More informationTimer2 Interrupts. NDSU Timer2 Interrupts September 20, Background:
Background: Timer2 Interrupts The execution time for routines sometimes needs to be set. This chapter loops at several ways to set the sampling rate. Example: Write a routine which increments an 8-bit
More informationA microprocessor-based system
7 A microprocessor-based system How simple can a microprocessor-based system actually be? It must obviously contain a microprocessor otherwise it is simply another electronic circuit. A microprocessor
More information16.317: Microprocessor-Based Systems I Spring 2012
16.317: Microprocessor-Based Systems I Spring 2012 Exam 3 Solution 1. (20 points, 5 points per part) Multiple choice For each of the multiple choice questions below, clearly indicate your response by circling
More informationCSc 10200! Introduction to Computing. Lecture 1 Edgardo Molina Fall 2013 City College of New York
CSc 10200! Introduction to Computing Lecture 1 Edgardo Molina Fall 2013 City College of New York 1 Introduction to Computing Lectures: Tuesday and Thursday s (2-2:50 pm) Location: NAC 1/202 Recitation:
More informationIntroduction. A. Bellaachia Page: 1
Introduction 1. Objectives... 2 2. Why are there so many programming languages?... 2 3. What makes a language successful?... 2 4. Programming Domains... 3 5. Language and Computer Architecture... 4 6.
More informationProgramming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur
Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture 04 Programs with IO and Loop We will now discuss the module 2,
More informationJordan University of Science and Technology Electrical Engineering Department Microcontrollers and Embedded Systems Spring 2011
Jordan University of Science and Technology Electrical Engineering Department Microcontrollers and Embedded Systems Spring 2011 Microcontrollers andembedded Systems and and EE445 Embedded Embedded Microcontrollers
More informationD:\PICstuff\PartCounter\PartCounter.asm
1 ;********************************************************************** 2 ; This file is a basic code template for assembly code generation * 3 ; on the PICmicro PIC16F84A. This file contains the basic
More informationIntroduction to PIC Programming
Introduction to PIC Programming Programming Baseline PICs in C by David Meiklejohn, Gooligum Electronics Lesson 3: Using Timer 0 As demonstrated in the previous lessons, C can be a viable choice for programming
More informationLaboratory: Introduction to Mechatronics. Instructor TA: Edgar Martinez Soberanes Lab 2. PIC and Programming
Laboratory: Introduction to Mechatronics Instructor TA: Edgar Martinez Soberanes (eem370@mail.usask.ca) 2015-01-12 Lab 2. PIC and Programming Lab Sessions Lab 1. Introduction Read manual and become familiar
More informationwhich means that writing to a port implies that the port pins are first read, then this value is modified and then written to the port data latch.
Introduction to microprocessors Feisal Mohammed 3rd January 2001 Additional features 1 Input/Output Ports One of the features that differentiates a microcontroller from a microprocessor is the presence
More informationCHAPTER 6 CONCLUSION AND SCOPE FOR FUTURE WORK
134 CHAPTER 6 CONCLUSION AND SCOPE FOR FUTURE WORK 6.1 CONCLUSION Many industrial processes such as assembly lines have to operate at different speeds for different products. Process control may demand
More informationCourse Outline Introduction to C-Programming
ECE3411 Fall 2015 Lecture 1a. Course Outline Introduction to C-Programming Marten van Dijk, Syed Kamran Haider Department of Electrical & Computer Engineering University of Connecticut Email: {vandijk,
More informationBefore Class Install SDCC Instructions in Installing_SiLabs-SDCC- Drivers document. Solutions to Number Systems Worksheet. Announcements.
August 15, 2016 Before Class Install SDCC Instructions in Installing_SiLabs-SDCC- Drivers document Install SiLabs Instructions in Installing_SiLabs-SDCC- Drivers document Install SecureCRT On LMS, also
More informationSOLAR TRACKING SYSTEM USING PIC16F84A STEPPER MOTOR AND 555TIMER
SOLAR TRACKING SYSTEM USING PIC16F84A STEPPER MOTOR AND 555TIMER Amey Arvind Madgaonkar 1, Sumit Dhere 2 & Rupesh Ratnakar Kadam 3 1. Block diagram International Journal of Latest Trends in Engineering
More informationC Language Programming
Experiment 2 C Language Programming During the infancy years of microprocessor based systems, programs were developed using assemblers and fused into the EPROMs. There used to be no mechanism to find what
More informationLesson 7 Multiple Precision Arithmetic
Elmer 160 Lesson 7 Overview Lesson 7 In this section The PIC stores data as 8-bit bytes. Up until now, we have only used values of 8 bits or less. But what if we have a greater range of values? In this
More informationArithmetic,logic Instruction and Programs
Arithmetic,logic Instruction and Programs 1 Define the range of numbers possible in PIC unsigned data Code addition and subtraction instructions for unsigned data Perform addition of BCD Code PIC unsigned
More information3 The L oop Control Structure
3 The L oop Control Structure Loops The while Loop Tips and Traps More Operators The for Loop Nesting of Loops Multiple Initialisations in the for Loop The Odd Loop The break Statement The continue Statement
More informationEmbedded System Design
ĐẠI HỌC QUỐC GIA TP.HỒ CHÍ MINH TRƯỜNG ĐẠI HỌC BÁCH KHOA KHOA ĐIỆN-ĐIỆN TỬ BỘ MÔN KỸ THUẬT ĐIỆN TỬ Embedded System Design : Microcontroller 1. Introduction to PIC microcontroller 2. PIC16F84 3. PIC16F877
More informationLaboratory 10. Programming a PIC Microcontroller - Part II
Laboratory 10 Programming a PIC Microcontroller - Part II Required Components: 1 PIC16F88 18P-DIP microcontroller 1 0.1 F capacitor 3 SPST microswitches or NO buttons 4 1k resistors 1 MAN 6910 or LTD-482EC
More informationInput/Output Ports and Interfacing
Input/Output Ports and Interfacing ELEC 330 Digital Systems Engineering Dr. Ron Hayne Images Courtesy of Ramesh Gaonkar and Delmar Learning Basic I/O Concepts Peripherals such as LEDs and keypads are essential
More informationExperiment 9: Using HI-TECH C Compiler in MPLAB
University of Jordan Faculty of Engineering and Technology Department of Computer Engineering Embedded Systems Laboratory 0907334 9 Experiment 9: Using HI-TECH C Compiler in MPLAB Objectives The main objectives
More informationPrinciple of Complier Design Prof. Y. N. Srikant Department of Computer Science and Automation Indian Institute of Science, Bangalore
Principle of Complier Design Prof. Y. N. Srikant Department of Computer Science and Automation Indian Institute of Science, Bangalore Lecture - 20 Intermediate code generation Part-4 Run-time environments
More informationHardware Interfacing. EE25M Introduction to microprocessors. Part V. 15 Interfacing methods. original author: Feisal Mohammed
EE25M Introduction to microprocessors original author: Feisal Mohammed updated: 18th February 2002 CLR Part V Hardware Interfacing There are several features of computers/microcontrollers which have not
More informationC Programming Language. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff
C Programming Language 1 C C is better to use than assembly for embedded systems programming. You can program at a higher level of logic than in assembly, so programs are shorter and easier to understand.
More informationPART TWO LISTING 8 PROGRAM TK3TUT8 MOVF PORTA,W ANDLW B ADDWF COUNT,F MOVF COUNT,W MOVWF PORTB GOTO LOOP
EPE PIC TUTORIAL V2 JOHN BECKER PART TWO Quite simply the easiest low-cost way to learn about using PIC Microcontrollers! EPE PIC TUTORIAL In this part we play with switches, make noises, count times,
More informationCHAPTER 1 - World of microcontrollers
CHAPTER 1 - World of microcontrollers One Time Programmable ROM (OTP ROM) One time programmable ROM enables you to download a program into it, but, as its name states, one time only. If an error is detected
More informationElements of Computers and Programming Dr. William C. Bulko. What is a Computer?
Elements of Computers and Programming Dr. William C. Bulko What is a Computer? 2017 What is a Computer? A typical computer consists of: a CPU memory a hard disk a monitor and one or more communication
More informationEmbedded Systems Programming and Architectures
Embedded Systems Programming and Architectures Lecture No 10 : Data acquisition and data transfer Dr John Kalomiros Assis. Professor Department of Post Graduate studies in Communications and Informatics
More informationCREATED BY M BILAL & Arslan Ahmad Shaad Visit:
CREATED BY M BILAL & Arslan Ahmad Shaad Visit: www.techo786.wordpress.com Q1: Define microprocessor? Short Questions Chapter No 01 Fundamental Concepts Microprocessor is a program-controlled and semiconductor
More informationPerformance & Applications
EE25M Introduction to microprocessors original author: Feisal Mohammed updated: 15th March 2002 CLR Part VI Performance & Applications It is possible to predict the execution time of code, on the basis
More informationA Fast Review of C Essentials Part I
A Fast Review of C Essentials Part I Structural Programming by Z. Cihan TAYSI Outline Program development C Essentials Functions Variables & constants Names Formatting Comments Preprocessor Data types
More information16.317: Microprocessor Systems Design I Fall Exam 3 December 15, Name: ID #:
16.317: Microprocessor Systems Design I Fall 2014 Exam 3 December 15, 2014 Name: ID #: For this exam, you may use a calculator and one 8.5 x 11 double-sided page of notes. All other electronic devices
More informationLecture 05 I/O statements Printf, Scanf Simple statements, Compound statements
Programming, Data Structures and Algorithms Prof. Shankar Balachandran Department of Computer Science and Engineering Indian Institute of Technology, Madras Lecture 05 I/O statements Printf, Scanf Simple
More informationCSE 452: Programming Languages. Outline of Today s Lecture. Expressions. Expressions and Control Flow
CSE 452: Programming Languages Expressions and Control Flow Outline of Today s Lecture Expressions and Assignment Statements Arithmetic Expressions Overloaded Operators Type Conversions Relational and
More informationIECD Institute for Entrepreneurship and Career Development Bharathidasan University, Tiruchirappalli 23.
Subject code - CCP01 Chapt Chapter 1 INTRODUCTION TO C 1. A group of software developed for certain purpose are referred as ---- a. Program b. Variable c. Software d. Data 2. Software is classified into
More informationGame keystrokes or Calculates how fast and moves a cartoon Joystick movements how far to move a cartoon figure on screen figure on screen
Computer Programming Computers can t do anything without being told what to do. To make the computer do something useful, you must give it instructions. You can give a computer instructions in two ways:
More informationSKILL AREA 304: Review Programming Language Concept. Computer Programming (YPG)
SKILL AREA 304: Review Programming Language Concept Computer Programming (YPG) 304.1 Demonstrate an Understanding of Basic of Programming Language 304.1.1 Explain the purpose of computer program 304.1.2
More informationThe C Programming Language Guide for the Robot Course work Module
The C Programming Language Guide for the Robot Course work Module Eric Peasley 2018 v6.4 1 2 Table of Contents Variables...5 Assignments...6 Entering Numbers...6 Operators...7 Arithmetic Operators...7
More informationFeatures of C. Portable Procedural / Modular Structured Language Statically typed Middle level language
1 History C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C was originally first implemented on the DEC
More information3.1 Description of Microprocessor. 3.2 History of Microprocessor
3.0 MAIN CONTENT 3.1 Description of Microprocessor The brain or engine of the PC is the processor (sometimes called microprocessor), or central processing unit (CPU). The CPU performs the system s calculating
More information/ 40 Q3: Writing PIC / 40 assembly language TOTAL SCORE / 100 EXTRA CREDIT / 10
16.317: Microprocessor-Based Systems I Summer 2012 Exam 3 August 13, 2012 Name: ID #: Section: For this exam, you may use a calculator and one 8.5 x 11 double-sided page of notes. All other electronic
More informationPreview from Notesale.co.uk Page 6 of 52
Binary System: The information, which it is stored or manipulated by the computer memory it will be done in binary mode. RAM: This is also called as real memory, physical memory or simply memory. In order
More informationFigure 1.1: Some embedded device. In this course we shall learn microcontroller and FPGA based embedded system.
Course Code: EEE 4846 International Islamic University Chittagong (IIUC) Department of Electrical and Electronic Engineering (EEE) Course Title: Embedded System Sessional Exp. 1: Familiarization with necessary
More information