A micro-controller, in simple words, is a miniature computer with a central processing unit and some peripherals integrated into a single integrated circuit package. The central processing unit can can execute some instructions resulting in some outcomes. This instructions define the architecture of the controllers central processor in a macro scale. This gives rise to the a major classifications in processor architecture as.
|Published (Last):||13 November 2010|
|PDF File Size:||1.13 Mb|
|ePub File Size:||18.15 Mb|
|Price:||Free* [*Free Regsitration Required]|
A micro-controller, in simple words, is a miniature computer with a central processing unit and some peripherals integrated into a single integrated circuit package. The central processing unit can can execute some instructions resulting in some outcomes. This instructions define the architecture of the controllers central processor in a macro scale.
This gives rise to the a major classifications in processor architecture as. To learn about controllers, processors and architectures in a general and abstract manner is tedious, time consuming and at-times dry.
When studying any electronic device or part, the bible is its datasheet. Download it and keep it for further reference throughout the tutorial. An assembly language program will look something like the snippet given below. The above snippet is to add two numbers and does what the algorithm below does.
The second form is easier to understand and manipulate from a programmers point of view. But to learn the architecture and functionality of the micro controller, we have to deal with the assembly language programming.
Since it gives a clear cut idea as to what is happening inside the device — i. A software that can simulate the internal working of the PIC micro controller and the datasheet of the device. The data sheet is the document in which the device vendor release with the product. It will have all the device details and specifications for end users.
Once we are familiar with the basic concepts of microcontrollers, we can explore the data sheet on our own and discover newer tricks. Shown above is a simplified processor architecture. The firmware program resides in the program memory. Once the processor is reset and ready to go, the program counter, which is simply a counter that acts as a pointer to the program instructions points to the initial location of the program memory.
The execution unit fetches the program instruction in this first location. These instructions are stored in the program memory in an encoded fashion. It will be a binary number that has encoded information relevant to the instruction. The task of the execution unit, in simple words, is to fetch the instructions pointed to by the program counter PC , understand it Decode and execute it. These tasks vary from micro controller to micro controller. A user side view of these tasks can be obtained by analyzing the instruction set of the specific device we are planning to use.
RAM is the volatile memory integrated within the controller package. It provides working space for the data manipulation during the command execution. The amount of RAM available is an important metric as the speed of operation and instruction set for a micro controller. Scratch pad memory registers are high speed memory registers which are integral to the processing center architecture. The concept is from processor architecture, since the external memory access which will be much slower can be a bottleneck to the high speed operations within the processor.
Microcontrollers usually have one or two such registers only. Based on the memory organization, processor architectures can be divided into two as. Our point of interest here is that the Von Neumann architecture has a common bus for program memory and data memory RAM , where as the Havard architecture maintains separate buses. We will analyze the architecture in light of the general introduction in the previous section.
The blocks are identified below. The instructions are encoded and stored in the non-volatile Flash Program memory. This point is the reset vector and contains the first instruction of the steps that are to be done once the controller is reset.
Details of the actual reset mechanism and other details will be dealt with later on. Under regular circumstances, the program counter increments by one every execution cycle explained later, as of now, consider it as each clock. This new location is used by the execution unit to fetch the next instruction. When the execution unit receive jump or loop instructions, it stores the current program counter value to the stack and loads the new program location to go to into the PC.
Thus these instructions take two execution cycles to complete. Again, the immediate next PC 08 is pushed into the stack. Here we utilized two levels of the stack.
This will corrupt the firmware. Operations resulting from the execution of instructions can all be considered as manipulation of data in different parts of the micro controller. It may be data in the RAM or in other special registers with designated purpose.
Before the transfer the appropriate bank is also to be selected. The table of selection values is given below. It resides outside the RAM register block. Every data transfer in or out of the RAM register has to go through the W reg. The code for the same will look like this. Once this is done, the value remains in the location until either it is changed by another instruction or the micro controller is reset or powered off.
A microcontroller is a synchronous digital device. This is the most popular method of clock generation for its accuracy. Other methods are also available, which will be discussed later. The clocking signal derived from the crystal is internally divided by four. This is to provide synchronization timing and clock signals to all parts of the micro controller.
However, the division of master clock is primarily to establish an instruction pipeline. The single cycle instructions execute at this speed. Consider a laundry with one washing and one drying machine. This is like fetching, decoding and executing instructions only once the previous instruction is completely finished. But, while the first set is being dried, if the second set is put to wash, the operations are carried out parallel, thereby saving net time.
This is the case of instruction execution with pipelining. When one instruction is being executed, the next instruction is fetched and decoded, making it ready for execution. This is illustrated below.
All the data manipulation and operations that are done within the microcontroller ultimately manifests as output signals through the ports. To make the concept clear, let us consider an air conditioning system built around a microcontroller.
The temperature sensors measure the room temperature and gives it as input to the microcontroller through the ports. The data coming in through the ports will be stored in some GPR by the microcontroler. The data in this GPR will be compared against a set temperature. If the external temperature reported by the sensor is higher that the threshold, the microcontroller switches on the air conditioning mechanism.
This is done by switching on the corresponding port pin. Physically, ports are some of the pins that are seen in the IC package. As it can be seen from the pin diagram, the port pins are bi-directional and and most of them are multiplexed in function.
This module is integrated into the PIC package and can be configured using firmware instructions. Exact way of doing this will be discussed later. Therefore , when we are referring to switching a port pin on as in tha air conditioner, it is actually writing data into the corresponding port register. Similarly, receiving data from the registers is actually, reading the data stored in the corresponding data register. Along with the data holding port registers, there is a set of configuration registers associated with the ports.
Note that the port pins can also be individually configured, i. Now, we are going into the actual program writing process. If not , this is the point of time to do so. Go through the explanation of each and every instruction. Any task to be accomplished with the device is to be split up and written in terms of the defined instruction set. This is because the ALU of the microcontroler has no provision to do it.
Therefore , if we have to do the multiplication, we have to write a routine out of the available looping, counting and addition instructions that are available.
Writing routines in the native instruction set is called assembly language programming. This method will give the most optimized firmware, but required a great deal of skill and is hard to debug, especially as the system size grows and advanced concepts like multi-tasking, resource sharing etc comes into picture. However, assembly language programming is the most effecient way of learning the architecture of the system and is also fun.
This is dome by the assembler software. Most of the device vendors provide a free asembler for their parts. So is the case with microchip. A simulator is a software that simulates the working of the device in detail. Using a simulator, we can simulate the loading of a program, execute it step by step, analyze the effect of each instructions in different registers of the controller and thereby debug and fine-tune the firmware. It is also easier for us to keep track of our files this way. The IDE is an environment which integrates different simulation tools and compilers to provide a single window solution to development and debugging.
In case any of the components are not correctly pointed correctly, a red cross mark appears near the component. Now, browse to the location where the project files are to be stored and give your project a name.
Did you use this instructable in your classroom? Add a Teacher Note to share how you incorporated it into your lesson. It would be great if you could replicate these steps using Free and Open source Software and Hardware. Everything works fine except that the LED blinks every 2 seconds.
PIC16F873 Microcontrollers. Datasheet pdf. Equivalent