Training Report
Training Report
An
electronic device with a programmable component which is not easily accessible to user is called Embedded System. Today, Embedded Systems are a part of human lives. We are surrounded and being helped by this embedded systems in our day to day activities. Fields where embedded systems are being used are Mobile communication, mobile computing devices, home appliances, music Systems, automobiles etc. Often the terms microcontroller and microprocessor are confusing. A microcontroller is actually has more features than microprocessors. Besides the processor it also has I/O ports, internal timers/counters, internal RAM and ROM. Microcontrollers are programmed using assembly and high level languages. Assembly languages are controller specific and machine friendly but the program written in assembly languages are quite lengthy. At the same time, high level languages such as C and Java are also being used to program microcontrollers. High level languages are user friendly and eliminate redundancy
from the programs written in assembly languages. Despite its relatively old age, the 8051 is one of the most popular microcontrollers in use today. Many derivative microcontrollers have since been developed that are based on--and compatible with--the 8051. Thus, the ability to program an 8051 is an important skill for anyone who plans to develop products that will take advantage of microcontrollers. The 8051 has three very general types of memory. To effectively program the 8051 it is necessary to have a basic understanding of these memory types.
LARGE
32 to 64 bit micro processor or micro controllers are used in this category. Programming languages used are Assembly, C, J2ME and VC++.
SCALE:
SOPHISTICATED:
32 to 64 bit micro processor or micro controllers are used in this category. It is supported by RTOS (Real Time Operating System).
MICROCONTROLLER 8051
ALU CU
ROM 4KB
8051 Architecture:
memory location where stack is located. Stack is automatically used in microcontroller whenever a subroutine is called. The location at which controller has to return after execution of subroutine is stored in stack. The total range of the RAM is from 00H to 7FH. Within this bit addressable RAM is there which ranges from 20H to 2FH.
Addressing Modes
It
is a method of accessing data from a location. There are five addressing modes supported by 8051. Immediate Addressing Mode Register Addressing Mode Direct Addressing Mode Register indirect Addressing Mode Indexed Addressing Mode
Timer/Counter
Whenever
you need to control any event timer is required. As the timer expires, flag are set/reset. Thus in microcontroller flags are used to indicate that any event is over. There two timers T0, T1. Both are 16 bit timers and there maximum values are FFFFH.
Stop bit
TH0
TL0
Flag bit
TF0 TR0
T0:
T1:
TH1
TL1
TF1
TR1
Where TH0 and TH1 are the higher byte of T0 and T1 Where TL0 and TL1 are the lower byte of T0 and T1.
TMOD Register:
LCD Interfacing
LCD Backgorund
Frequently, an 8051 program must interact with the outside world using input and output devices that communicate directly with a human being. One of the most common devices attached to an 8051 is an LCD display. Some of the most common LCDs connected to the 8051 are 16x2 and 20x2 displays. This means 16 characters per line by 2 lines and 20 characters per line by 2 lines, respectively. Fortunately, a very popular standard exists which allows us to communicate with the vast majority of LCDs regardless of their manufacturer. The standard is referred to as HD44780U, which refers to the controller chip which receives data from an external source (in this case, the 8051) and communicates directly with the LCD.
44780 BACKGROUND
The 44780 standard requires 3 control lines as well as either 4 or 8 I/O lines for the data bus. The user may select whether the LCD is to operate with a 4-bit data bus or an 8-bit data bus. If a 4-bit data bus is used the LCD will require a total of 7 data lines (3 control lines plus the 4 lines for the data bus). If an 8-bit data bus is used the LCD will require a total of 11 data lines (3 control lines plus the 8 lines for the data bus). The three control lines are referred to as EN, RS, and RW. The EN line is called "Enable." This control line is used to tell the LCD that you are sending it data. To send data to the LCD, your program should make sure this line is low (0) and then set the other two control lines and/or put data on the data bus. When the other lines are completely ready, bring EN high (1) and wait for the minimum amount of time required by the LCD datasheet (this varies from LCD to LCD), and end by bringing it low (0) again.
The RS line is the "Register Select" line. When RS is low (0), the data is to be treated as a command or special instruction (such as clear screen, position cursor, etc.). When RS is high (1), the data being sent is text data which sould be displayed on the screen. For example, to display the letter "T" on the screen you would set RS high. The RW line is the "Read/Write" control line. When RW is low (0), the information on the data bus is being written to the LCD. When RW is high (1), the program is effectively querying (or reading) the LCD. Only one instruction ("Get LCD status") is a read command. All others are write commands--so RW will almost always be low. Finally, the data bus consists of 4 or 8 lines (depending on the mode of operation selected by the user). In the case of an 8-bit data bus, the lines are referred to as DB0, DB1, DB2, DB3, DB4, DB5, DB6, and DB7.
ADC Interfacing
ADC0804 Pinout and Typical Connections
As shown in the typica circuit, ADC0804 can be interfaced with any microcontroller. You need a minimum of 11 pins to interface ADC0804, eight for data pins and 3 for control pins. As shown in the typical circuit the chip select pin can be made low if you are not using the microcontroller port for any other peripheral (multiplexing). There is a universal rule to find out how to use an IC. All you need is the datasheet of the IC you are working with and take a look at the timing diagram of the IC which shows how to send the data, which signal to assert and at what time the signal should be made high or low etc. Note: Keep this in mind that whenever you are working with an IC and you want to know how to communicate with that IC, then simply look into the timing diagram of that IC from its datasheet. It gives you complete information that you need regarding the communication of IC.
The above timing diagrams are from ADC0804 datasheet. The first diagram (FIGURE 10A) shows how to start a conversion. Also you can see which signals are to be asserted and at what time to start a conversion. So looking into the timing diagram FIGURE 10A. We note down the steps or say the order in which signals are to be asserted to start a conversion of ADC. As we have decided to make Chip select pin as low so we need not to bother about the CS signal in the timing diagram. Below steps are for starting an ADC conversion. I am also including CS signal to give you a clear picture. While programming we will not use this signal. 1. 2. 3. 4. Make chip select (CS) signal low. Make write (WR) signal low. Make chip select (CS) high. Wait for INTR pin to go low (means conversion ends).
Once the conversion in ADC is done, the data is available in the output latch of the ADC. Looking at the FIGURE 10B which shows the timing diagram of how to read the converted value from the output latch of the ADC. Data of the new conversion is only available for reading after ADC0804 made INTR pin low or say when the conversion is over. Below are the steps to read output from the ADC0804. 1. 2. 3. 4. 5. Make chip select (CS) pin low. Make read (RD) signal low. Read the data from port where ADC is connected. Make read (RD) signal high. Make chip select (CS) high.
PROGRAMMS:
Delay of 1 sec.:
ORG 00H MOVR2, #8 H3: MOVR1, #250 H2: MOVR0, #250 H1: DJNZR0, H1 DJNZR1, H2
DJNZR2, H3 END
SJMP B1
T100: MOV TH0, #9BH B2: SETB P2.0 ACALL DELAY CLR P2.0 ACALL DELAY SJMP B2 T150: MOV TH0, #69H B3: SETB P2.0 ACALL DELAY CLR P2.0 ACALL DELAY SJMP B3 T200: MOV TH0, #37H B4: SETB P2.0 ACALL DELAY CLR P2.0 ACALL DELAY SJMP B4 DELAY: SETB TR0 WAIT: JNB TF0, WAIT CLR TR0 CLR TF0 RET END
Counting program:
ORG 00H MOV TMOD, #50H RESTART: MOV TH1, #00H MOV TL1, #00H
SETB TR1
KG: MOV P1, TH1 MOV P0, TL1 JNB TF1, KG CLR TR1 CLR TF1 SJMP RESTART END
When interrupt is there in between the flow of data then Led must glow for 1 sec.:
ORG 00H LJMP MAIN ORG 003H SETB P0.0 ACALL DELAY CLR P0.0 RETI ORG 0030H MAIN: MOV IE, #81H MOV P1, #0FFH BACK: MOV A, P1 MOV P2, A SJMP BACK DELAY: MOVR2, #8 H3: MOVR1, #250 H2: MOVR0, #250 H1: DJNZR0, H1
Today the simplest of the equipments have microcontroller inside them. From mobiles to computers, the microcontrollers have reached everywhere. Thats why the Microcontroller class was one of the most precious of the gains we had. Here we studied the microcontrollers, particularly AT89C51 from the Atmel family. In addition to this, we were taught the assembly language programming of this microcontroller, which we practically tested on the computer using the software Keil. Also we learnt to program the microcontroller by interfacing it to the computer. Thus, looking at the shortness of the training period we had a comprehensive know-how of the AT89C51.