Digital Code Lock

Will be uploaded very soon...

DTMF based device switching

Will be uploaded very soon..

DTMF based robot controll

Will be uploaded soon..

Monday, January 21, 2013

About Microcontrollers

What is microcontroller..?

        Microcontroller is a small size miniature computer that we find in all kind of gizmos. There are two words one is microprocessors and other one is microcontroller. 

Microprocessor:

          In microprocessor there is only CPU which includes ALU for perform arithmetic and logic operations, some registers for data storage and control unit which control over all operation of chip. It needs to interface with some external peripherals like RAM, ROM, Timer etc to be functional it.


Microcontroller:

          In microcontroller all this required peripherals like RAM, ROM, Timer etc are integrated in single unit. All you need is to connect crystal, and power supply with chip to be functional it.


Manufacturer of Microcontroller:

          There are so many company which manufactures microcontrollers. They are available in 8-bit, 16-bit and 32-bit. Some of manufactures are listed below...

ARM
Intel
Atmel
NXP
Texas
Dallas
Toshiba

Types of CPU:

      Today, lots of microcontrollers are available with different types of CPU. Most popular CPUs for microcontroller are 8051, AVR and PIC. Some of microcontrollers have inbuilt analog to digital and digital to analog converter in a single unit.

     We must need to program microcontrollers as per our requirement. For programming purpose of microcontrollers many softwares are available like keil, Mikroc, SDCC, Bascom etc.

Application of Microcontrollers:

      Microcontrollers can be used in automobile industry, control and automation, robotics, Home appliances, industrial appliances, electronics gadgets, communication equipment and count is continue...

8051 architecture and features

8051 is also known as a MCS-51 which is developed by Intel in 1980. It has 8-bit CPU, memory, timers, counters, interrupt controller and serial I/O are highly integrated on single chip. It is a 40-pin IC. It has 4 byte input-output port, EEPROM of 4KB and RAM of 128 bytes. Pin diagram and architecture of 8051 is shown below.




Memory Space:

There are five memory spaces in 8051 which are...

1) Program memory
2) Internal data memory
3) External data memory
4) Special function registers
5) Bit memory

Program memory space is addressed by the 16-bit program counter register which holds the address of memory location from where instruction code is need to be fetched. It can also be addressed by the 16-bit DPTR (data pointer register) using few instruction. It primarily stores instruction code, constant data, constant tables and string.

Internal memory space stores all the variables and data structure which is directly operated by the program. It is functionally the most important data memory space. It contains four bank of general purpose registers and program counter.

External data memory space contains those data which can't fits on the chip. It addressed by the DPTR register. It can also be accessed by the first two general purpose register R0 and R1. This memory space is only accessed by the indirect addressing mode.

Special function registers space contains on chip peripheral I/O registers as well as some special registers which must be programmed to control and perform particular task. This SFRs can only be accessed by direct addressing mode.

Bit memory space is used for storing flags and bit variable. There is some specific instruction by which bit memory space can be accessible. It can also be addressed by direct addressing mode. This memory space is mostly used with decision making process.

Features of 8051:

1) 8-bit Arithmetic and logic unit
2) 8-bit data and 16-bit data address bus.
3) Capability of address 64kb memory location
4) 128bytes on chip RAM i.e data memory
5) 4kb on chip ROM i.e program memory
6) Four 8-bit input/output port
7) Serial port (UART)
8) Two level interrupt priorities
9) Two 16-bit Timers/Counters

Disadvantage of 8051:

1) Limited on chip program and data memory 4kb and 128bytes respectively
2) No watchdog timer
3) It does not support ISP i.e in system programming

To over come this problems some company manufactures wide variety of chip which has 80c51 CPU as a heart (or i would say mind). For best chip which has 80c51 CPU click here...

Please share this with your friend...

P89v51XX- extended feature controller with 8051 CPU

Before some day i posted about 8051 CPU and as you all know it has many disadvantages. Currently lots different chips are available in the market which has 8051 as a CPU. All these chips have different features and characteristics.

Main problem with 80c51 is it does not support ISP and IAP, It has limited size of on chip ROM and RAM. So what will you do if the size of your machine code is more than 4Kb and it requires more RAM to process on data. One Possible solution is you can interface external memory but this required one more external chip and you have to reserve some pins for interfacing or for communication with with memory chip.

So how you feel if you get more memory space on a single chip...??? Here i am going to talk about P89v51xx family. There are main three chips are available in this family...

1) P89v51RB2
2) P89v51RC2
3) P89v51RD2

Memory Space:

Chip
Size of ROM
(kB)
Size of RAM
(kB)
Range of frequency
(MHz)
P89v51RB2
16
1
Up to 40MHz
P89v51RC2
32
1
Up to 40MHz
P89v51RD2
64
1
Up to 40MHz

Pin diagram and architecture:


Mode of Operation:

P89v51 family supports two mode of operation in first mode i.e X1, chip is operates in simple 80c51 clock  rate which is 12 clocks per machine cycle. and in second mode i.e X2, chip is operates in 6 clocks per machine cycle.

Features of P89v51XX:

1) CPU: 80c51
2) Power supply: 5V
3) Operating frequency: up to 40MHz
4) Three high current ports (16mA)
5) Three 16-bit timers and counter
6) Eight interrupt sources with four priority level
7) Two DPTR register
8) Support ISP and IAP
9) Brownout detection
10) Watchdog timer

This chip can be programmed by using "Flash Magic tool" which is easy and freeware to use. Click here for how to program P89v51XX using Flash Magic...

Download Datasheet  

Brown Out in Controller

There are so many circuits inside the chip. All these different circuits require different voltage levels. So when the supply voltage fall down from the minimum voltage level due to electrical noise or any other reason performance of these circuits goes out of control.


So chip has in built reset functionality to get overcome from this problem. This brown out usually occurs when supply gets turns off. So when supply voltage fall below the minimum required voltage level then there is automatically chip get restarted.

Please share this with your friend...

Understanding Intel Hex file

Intel hex file is a file which contains binary data values to program micro-controllers, EEPROMs,  and other chips. Compiler converts source code into machine code and outputs it into hex file. This hex file then burned into chip using burner for make chip functional.

Typical look of hex file is...


Now each line has six different meaningful parts and these parts are...

1) Starting Code
2) Byte Count
3) Memory Address
4) Record Type
5) Data
6) Checksum


1) Start Code: It is a single character an ASCII code of colon(":"). Every line of hex file is starts with colon. It indicates the new line in hex file.

2) Byte Count: It consist of two hex character and it represents the length of data bytes in the record.

3) Memory Address: It consist of 4-digit memory location that represent the starting address of subsequent data in the record. Data starts storing from this memory location and its increments after storing of each data byte.

4) Record type: It consists of two hex digits. There are six types of records. This field has only five possible values which are from 00 to 05.

=> 00 = Data record; which contains data and 16-bit address.

=> 01 = End of file records; every hex file must be end with end of file record type for that record type field must contains "01". End of file records always has following format.


=> 02 = Extended segment address records; it is also known as HEX86. Extended segment record must have two data bytes. Absolute 32-bit address is generated using addition of extended segment address's data field and data record's address field.

=> 04 = Start segment address record; this is for 80x86 processors. it specifies the initial contents of code segment and instruction pointer. Here 1st two values (bytes) of data field are for code segment and other two are for instruction pointer.

=> 05 = Start linear address records; This is for 80386 and higher CPU. Contents of data field that is of 32-bit are loaded into the EIP register.

5) Data Field: This field contents data byte and address as well. Content of record field differentiate whether it is data or an address.

6) Checksum: This is two hex digits appears at the end of each line. For calculating this number 1st add every hex number of line not include ":" and checksum field it self then perform 2's compliment of least significant byte.

Please share this with your friend...

Generating Hex file using Keil

Earlier i posted about Intel hex file and different components in it. And now here i am posting about how to generate hex file using Keil software. Keil is the all in one simulator which is most popular in embedded lovers as well as in industry. By using keil you can develop your source code in both the languages that is assembly language and C language but the hex file is common for both.

So first make sure that there is no error in your source code and if there is any then make it solve. Now just follow the below steps use screenshot if you find any difficulty.

Step-1: In menu bar navigate to Project >> Options to target and click on it or in project workspace window right click on Target1 >> Options for target and new window appears on your desktop.



Steps-2: In Options for Target window go to Target tab and enter the value of your crustal frequency in Xtal field. Make sure that you enter this in MHz.



Steps-3: Now go to Output tab and just tick mark the Create HEX file check box and hit ok.


Now just rebuild your target and you are done. your hex file is generated in the same folder in which your project file is located.

Important Note: Keil does not provide any path selection option for storing generated hex file. it is automatically store it in the same folder which contains your project file.

Now you can burn this hex file into ROM of micro-controller..

Please share this with your friend...