Tuesday, June 26, 2012

MicroController Part(2)





                                              Microcontroller  Overview
                                                    Part (2)

Intro:
Microcontroller part (1) deals with the definition of microcontroller (what it is ) and some basic components of the microcontroller (ports,register and rom).
This blog will explain some other elements of the micro controller.

Elements of Micro Controller (continue ...)

RAM : Random Access Memory 

Register , As we see in my  the blog micro-controller-part-1 , a small memory unit which has a faster access by the CPU. Where these register resides? 
RAM is a temporary memory storage of microcontroller, usaully in size of Kbytes which hold the program temporary data ,the results comes from arithmetic logic unit etc. It contains the general purpose register and special function register 
RAM is volatile memory unit , means whenever the power goes off it will lost it contents. The memory will be cleared. 

Program Memory :


The program which will be save somewhere inside the micro controller is called program memory. every micro controller has internal program memory. But if the program is too long reference to program memory it is possible to add external program memory. 

Program Counter :

Program counter is a special register which hold the instruction address of  program memory that will fetch next.The value of this register will be incremented automatically each time when a instruction will be executed. Working procedure of the program counter is like that , CPU will call for next instruction that will be executed. The address of the instruction  is obtained from the program counter and It will be incremented. 
Instruction will be placed into Instruction Register for most of the micro processor and micro controller.

Fig: Program Counter
Program counter register and instruction register ins typically involve for the instruction fetching. After the early production of 8051 Micro controller , most of the micro controller contain program memory which is a internal memory block that hold the instruction for the CPU. Instruction fetching involve typically to obtain the appropriate address of the program memory which hold the appropriate instruction that should be executed now and execute the instruction.
Instruction Register
Instruction register is a register that will store instruction. Operation code is extracted from the instruction set and it will executed in processing unit.
                       
Stack Pointer


A block of memory storage is called stack that will store temporary storage of data.To save data of general-purpose register during execution of a subroutine (function) or when an interrupt is serviced. Push and Pop mechanism is use to save the content of a register and to retrieve data into register. Stack is use for the faster access by the CPU.


Central Processor Unit (CPU)
CPU is unit that actually deals with the data , perform some operation and gives some output . CPU unit consist of the following units
a) Instruction Decoder :
Each and every instruction has opcode (operation code) that must be parsed and executed.
Instruction decoder is a electronics components that will take the opcode from the instruction and regenerate code so that the electronics components can execute it.
b)Arithmetical Logical Unit (ALU)
The arithmetic logic unit (ALU) is the most sophisticated components of any processing unit. It performs the entire integer arithmetic and bit-wise logical operations of the microprocessor.
Operation bit can be 8 bit arithmetic , 16 bit arithmetic or 32 bit arithmetic.
c) Accumulator is an SFR closely related to the operation of ALU. It is a kind of working desk used for storing all data upon which some operations should be executed (addition, shift etc.). It also stores the results ready for use in further processing. One of the SFRs, called the Status Register, is closely related to the accumulator, showing at any given time the "status" of a number stored in the accumulator (the number is greater or less than zero etc.).


Saturday, June 16, 2012

Micro-Controller part (1)




Intro:
Whenever we are talking about a micro controller we eventually talk about some lump of silicon inside a chip and of course programmable.
So, Micro controller is just a chip having having lots of logical gates which perform some arithmetic operation.Most of the micro controller actually execute some predefined assembly level operation  such as increment,move , copy , add etc.As an example most of the pic (vendor microchip) based micro controller execute only 30 instructions.
so, technically a micro controller can be define as a single chip having a processing unit (microprocessor), a define size of memory (that will depend on the device model) and a sort of peripheral interfaces (IO port,ADC,Serial etc).Firmware is the program that run inside a micro controller.

Depending on how to accesses the program memory hardware structure is defined by two possible architectures 
(1) Von Neumann, and 
(2) Harvard.
It will be describe later in the next blogs..


Elements of Micro Controller:

Fig: MicroController Structure


PORT:
When a device need to communicate out side the world, it need some structural interface through that it can communicate. Port is the physical interface through that it communicate with peripheral devices or outside of the world i.e with sensor.The communication can be done in bidirectional way means micro controller exchange some information as a passing out some information and taking in some information .(I/O ).So, 
these input output communication peripheral are called PORT which are use to receive some inputs from the outside world (port is configured for input )and manipulate data within inside the processing unit and give the output through PORT (port is configured for output )

REGISTER:

Fig: Register(D-FlipFlop)


Register is a digital electronic memory where 8bit (for 8 bit MCU)  data is saved.Data saved into register is volatile means whenever the microcontroller rebooted register will be cleared. Register is part of Central Processing Unit of the micro controller that means CPU has faster access to the register data.
Perhaps before any operation (before enter to the arithmetic logic unit ALU)
data are placed into register.

According to the functional definition registers are two types 
1. Register 
2.Special Function Register (SFR)

Register :
I always consider it is as an general type register because of it is a register (by definition) and its function is not defined. It eventually used to store some data and program may use those data for further processing according to the programmer. As an example PORTA register

SFR :
Unlike register , it also temporary save data but their functional behavior is defined by the manufacturer.Every bits of the SFR register has a defined function when ever it holds some bits (0 or 1 ) it will perform some function. It is a controller register.
As a example TRISA register is a SFR register associated to the PORTA register. But every bits of TRISA register means something special which is defined.For PIC based micro controller TRISA register can contain 0 or 1. 
but if TRISA contain 0 corresponding PORTA register bit will be configured as a OUTPUT pin and if it is 1 corresponding PORTA register bit will be configured as a INPUT pin

ROM :
ROM stand for read only memory which is a structured array of memory.The data which is written into the memory is not volatile.

the structure of the ROM is organised into three modules 
1) An array of memory with a fixed size 
2) A address decoder 
3) A buffer


The address decoder is use to decode the address of the memory block 
As an example we have 1024x8 block of memory array.So there are 1024 row and 8 column in the memory array. Memory array contain the memory cells i.e TTL Memory cell.The word size of the block memory that we are considering guess that it is 8 bit long. So, to address the column cells only 3 bit Colum address decoder is need to address the memory array.on the other hand to select 1024 bit of the row cells 10 bit row address decoder is sufficient. When the row and column decoder decode an address (i.e row 512, column 1 , row 512 colum 2 ) associated data which reside inside the memory is place into the buffer. Then the data is available to the data bus in the next clock cycle. 

ROM



The whole operation need some time to complete. This is know as a ROM speed.

according to it programming (data write inside the memory , the way we put data into the ROM memory cell)  ROM can defined as 
1. Mask Programmed ROM

The programming is done on manufacturer side according the customer demands. Once it is done it can not be modified.We known term is OTP ( one time programming.)

2.Programmable ROM 
The programming is done on customer side. It is like burn the memory cell to have value 0 / 1 but once it is done it can not be reprogrammed.

3.Erasable Programmable ROM
(nonvolatile read/write, re programmable )
The programming is done on customer. It can be reprogrammed. The programming is done by ultra violet ray or electrically (EEPROM , in-circuit electrical erasability ).

4.Flash 

re programmable memories are high density. it combines the low cost and high density features of an UV EPROM /EEPROM.It is called a flash memory because of its rapid erase and write times.
Most flash memory devices use a ‘bulk erase’ operation in which all the memory cells on the chip are erased simultaneously. Some flash memory devices offer a ‘sector erase’ mode in which specific sectors of the memory device can be erased at a time .