Monday, 1 December 2014

Toggle and control LED by 8051 and keil

LED Lighting / Control LED / Interfacing two LED / LED blinking / Toggle two LED by 8051 and keil
In this topic I shall discuss about the code to control two LED in 8051 and keil. Now I will show you how to interface LED with AT89c51. The code is like that….

//////////////////////////////////////////////////////////////////////////////////////////////////////////////

 //LED blinking//
#include <REG52.H>
sbit LED1=P1^0;
sbit LED2=P1^2;


void delay_ms(int milisec)
{
        int i,j,k;
        for(j=0;j<milisec;j++);
        {
      for(k=0;k<20;k++)    
                for(i=0;i<4898;i++);
        }
}

void main(void)
{
        P1=0x00;                               //Set P1 port in O/P mode
        while(1)
        {
        LED1=1;
        LED2=0;
                delay_ms(500);              //delay of 500 ms
        LED1=0;
        LED2=1;
  delay_ms(500);
 }
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
Here I have used Atmel AT89c51 microcontroller, but you can use this code for any AT89xxx family.
The circuit is given below/…..


In this circuit the value of crystal is 12
If you cannot understand the above code you can see this…………….

Sunday, 30 November 2014

How to make hex file in keil

How to make .hex file by keil 
In the previous topic I had discuss about how to use keil compiler to code for 8051. In this topic I shall show you how to make a hex file to simulate or run your code in simulator like proteus.
Proteus is a strong simulator have various type of ICs and electronic gadgets. By this software you can test your code. Is your code working in hardware or not you can see by this software. If you want to test your code in simulator like this you have to make your code in hex format then you can put your hex formatted code into the specific microcontroller by this type simulator.

when your code is ready to test I mean when you see the 0 error and 0 warnings in the output message of keil, then click on Flash from menu bar. Then click on Configure Flash Tools… ,

Then a window will appear named Option From Target ‘Target1’. Now click on Target from the menu bar of that window.

Now you can see a combo box named Xtal (MHz). In this combo box the initial value is written is 33.0. Now you have to change your value. The value should be the exact value of oscillator frequency of your chosen microcontroller. I have taken Atmel AT89s52. The oscillator frequency of that microcontroller is 11.0592. So I have to write 11.0592 in the place of 33.0 .
After doing so you have to click on Output. Then you can see this..

In this window you have to tick in the Creat HEX File check box. Now you have done your settings portion. Now click ok.
Now you have to run your code by clicking Build all icon, which should be right side of Build icon.

After clicking on build all icon, in the output window you can see a extra line Creating hex file from” your project name”

Now a .hex file should be added in your project window. You can use it for simulator like Proteus.
In the next episode I will discuss about different types of interfacing in 8051 and keil, so keep viewing my blog.
Thank you for visiting my blog, if you have any question about this topic or you want say something about this topic please comment…..



Friday, 28 November 2014

8051 coding using keil

8051 Coding using keil
For coding 8051 microcontroller in C language, I use Keil, because it is freeware and easy to use. In Keil you can code in C and assembly both languages. So let’s start coding with Keil compiler.
You can download the latest Keil ide by this link…………………………
In this link C51 is for 8051. So click on C51. After clicking C51 this page will appear…..


In this above page fill all the information what is asking for. If you do not have any company name then write any name. If you cannot find your state in the state combo box, the select any state from the list. After filling this form click on submit button and you will see this page…….


In this page click on C51V953.EXE 
Then your download will begin. Download it and install it.
After installing it open Keil. If you want to code for a new project, then open Keil. Then …..
1>     Click on Project
2>     Then click on New Project….or New uVersion Project


3>     After clicking that a new window will be appeared (creat new project)


In this window at save combo box you have to select the folder where you want to save your project. After selecting your project file write a project name in the file name combo box. Then click on save button.
After clicking on save a new window will be appeared named Select Device For Target ‘Traget1’


In this window you have to select your device. Suppose you want Atmel AT89s52. Then first you have to click on Atmel. Then select your device. In this practice session I am selecting AT89s52.
So click on AT89s52.


After selecting your chosen device click on ok button.
After clicking OK  button a new window will be appeared. It is a discretional window containing YES and NO  button click on YES button.


After clicking Yes button the project window will be appeared. But at this moment you can not write your code.
Now from the menu bar click on File  and then click on New (ctrl+N). Like that…


Now you can see a folder named “terget1” . Left side of that Target1 folder a “+” sign is visible. Click on that + sign


Now you can see a folder named Source Group1. Right click on that folder (not on the + sign ). After right clicking on that folder you can see many options like build target, rebuild target, etc.  click on  Add Files to Group ‘Source Group1’ .Then a window will be appeared  like that;;


In this window at File Name combo box write a name (like code.c), then click on Add button. After clicking on Add button click on close button.
Now you have done all the hard work. Now you can write your code on the text pad.


Now write your code in textpad. When you think you have finished your code writing then find Build icon and click on that.


It will compile your code whether your code is right or wrong, if wrong then in which line of that code is wrong and  what is the thing you have made wrong.


When your code will  100% correct the message will show you that your code  have o-errors and 0-warnings.

Then you can use it for microcontroller.


If you cannot understand or there is some problem, please comment, I will answer your question within 24 hours.…..

Basics of 8051

Microcontroller VS Microprocessor
In Embedded System field the question which often arise in our mind, that what is the difference between Microcontroller and Microprocessor?

Microprocessor is meant the general-purpose microprocessor like x86 family (8086, 80286, 80386, 80486, and the Pentium) or Motorola’s 680x0 family (68000, 68010, 68020, 68030, 68040, etc.). These microprocessors contain no RAM, no ROM, and no I/O ports on the chip itself. For this reason, they are commonly referred to as general-purpose microprocessors.
A system designer using general-purpose microprocessors such as Pentium or the 68040 have to add RAM, ROM, I/O ports, and system timers externally to make them functional. Although the addition of external RAM, ROM, I/O ports makes these systems bulkier and much more expensive, they have the advantages of versatility such that the designer can decide the amount of RAM, ROM, and I/O ports needed to fit the task at hand.
But a Microcontroller has a CPU (a microprocessor) in addition to a fixed amount of RAM, ROM, I/O ports, and timers all in a single chip.
Now come to 8051 Microcontroller, which is the well-known microcontroller in educational and industrial field. If we want to learn Embedded System, then first we have to learn 8051 very carefully and consciously. Let’s start……………………………………………………………

8051 Microcontroller



History of 8051
In 1981, Intel Corporation introduced an 8-bit microcontroller called the 8051.This microcontroller had….

RAM à 128 bytes
On-Chip RAM à 4K
No. of Timers à 2
No. of serial ports à 1 (each 8-bits wide)
Total No. of I/O Ports à 4 (each port have 8 pins)
Total No. of pins à 40
Interrupt sources à 6

Although the 8051 can have a maximum of 64K bytes of on-chip ROM, many manufacturers have put only 4K bytes on the chip. This will be discussed in more detail later…..
There are many members in 8051 family like 8052, 8031, etc. but in this we will discuss about 8051 only..
There are so many chips in 8051 series like AT89c51, AT89s52, AT89c2051 etc. , they have different values of RAM, ROM and have different numbers of pins and ports.
In the next topic we will discuss about coding. How to code for a microcontroller.
                If you have any doubt about this topic, don’t hesitate to comment. See you in next topic…


Wednesday, 26 November 2014

Embedded system basics

Embedded System Basics

In electronics field there are two main streams.One is VLSI and another is Embedded System.You all know the basic overview of those field. In this blog I will discuss about the basics of Embedded System.
The meaning of Embedded System is to create a small computer for a specific work.Suppose WOTER LEVEL INDICATOR  - robot or a SMOKE DETECTOR-robot like that.
Now we are going to the main portion of Embedded System field.In this field one have to program a microcontroller (like 8051,PIC,ARM etc to specify which pin of that microcontroller will operate in which mode and when it will stop operating something like that) using a computer language(like C,C++,UNIX,).There are different types of languages in our hand to program the microcontroller like midlevel languages like C,C++  etc or languages like Assembly language.In the collages we studies the microcontroller in Assembly language but in industry C,C++,UNIX(Linux) languages are preferable and they mostly mostly use those type of languages.The main disadvantages of Assembly language is that  suppose if we make a project in 8051 in Assembly language and want to make the same project in PIC microcontroller then we can not use the code of that previous projet.Every time we have to write codes differently.And most of all the Assembly language of different microcontroller is different,there is no similerites between any microcontroller Assembly languages.
For this reason in this blog we will discuss about Embedded System in C language.
I am a Professional Embedded Developer and I am working in C language.
Now Lets Begin the EMBEDDED SYSTEM BASIC TUTORIAL .

In our study first we should be acknowledge about the gadgets or electronic materials and softwares.
If you want to do your lab work in hardware  the you need
1.       Bread Board

2.       Microcontroller


3.       LCD




4.       Programmer(which is very essential and without this we cannot convert mid level language to machine code and program to the microcontroller )

Like many more electronics gadgets we have to require to test all in hard ware.But it will be very costly for a student to practice in his home.
But if you use simulator like Proteus , Multisim then you don’t have to need those electronics gadgets.You have to just write code in any compiler , create a hex file of this code and simulate in those simulator.In those simulator there are large amount of electronics devices.You have to just drag and drop those devices in your project page and run it.
In the later topics I will show you how to use simulator but today I will discuss about some topic on 8051.


                                

Embedded system basics

                                                Embedded system basics