14
Microcontrollers Lab 1 INTRODUCTION TO THE CONTROLLER AT89C51 (8051)

Micro c lab1(intro to 8051)

  • Upload
    mashood

  • View
    38

  • Download
    3

Embed Size (px)

Citation preview

Page 1: Micro c lab1(intro to 8051)

MicrocontrollersLab 1

INTRODUCTION TO THE CONTROLLER AT89C51 (8051)

Page 2: Micro c lab1(intro to 8051)

Objectives of the LabTo learn the functionality of different ports and pins of 8051

µcontroller.

To discuss the circuits that make 8051 works.

To learn the ‘KEIL’ software to create a ‘HEX’ file for the

8051 controller.

Page 3: Micro c lab1(intro to 8051)

Pins and Ports of 8051

Use withcaution

If EA high

Page 4: Micro c lab1(intro to 8051)

Internal Block Diagram of 8051

Page 5: Micro c lab1(intro to 8051)

Once Around the PinsPower: VCC,VSS (GND)Reset:RSTCrystal:XTAL1,2External Device Interfacing: EA,ALE,PSEN,WR,RDI/O Port: P0-P3 [7:0]P3: Shared with control lines: Serial RxD TxD, Counter

control T0, T1, External Interrupts INT0, INT1P0 and P2 are multiplexed with data bus.P1 can only be used as I/O port.

Page 6: Micro c lab1(intro to 8051)

Circuits that make 8051 work

2 mc

Page 7: Micro c lab1(intro to 8051)

Crystal Frequency and Machine CycleCrystal Frequency used is 11.0592MHz or 11059200 Hz.The oddball frequency is used to synchronize the serial baud

rates.At this frequency, the time period of one wave will be

1/11059200 seconds.The ‘time unit’ for 8051 is known as Machine Cycle.And one machine cycle equals 12 waves of crystal frequency.So the time period of 1 machine cycle will be 12 times the

time-period of one wave i.e. 12/11059200 secThis comes out to be approximately 1.085 µs.

Page 8: Micro c lab1(intro to 8051)

Logic Levels & Ports for I/O OperationAlways write ‘high’ to ports for input

Page 9: Micro c lab1(intro to 8051)

Program Structure (Directives)org 00h

Coding instructions here

delay: ;subroutine

ret

end

Page 10: Micro c lab1(intro to 8051)

Registers (Naming) Normally UsedAccumulator (A or ACC) Base (B)Ports (P0,P1,P2,P3 & Px.y) PSW (For Flags & Register Banks)R0,R1,…,R7 SP(Stack Pointer)DPTR(Data Pointer) Timer RegistersSerial Port Registers Interrupt RegistersPCON (Power Control Register)

IP (Instruction Pointer)

Legend:* Frequently used* Special Functions* Occasionally* Used automatically

Page 11: Micro c lab1(intro to 8051)

How to work with ‘KEIL’1. Locate the ‘Keil uVision2’ icon on the screen.

2. Run the program and go to Project>Close Project if a previous project file

is open otherwise go to Project> New Project.

3. The program will ask for the file name. Give any location in the directory

and write any program name you like. (Remember: Create a folder before

creating program)

4. After step 3, another window will open namely ‘Select Device for Target’.

Expand Atmel and click ‘AT89c51’. Also check ‘ Use extended linker

LX51 instead of BL51’ and click ‘OK’

Page 12: Micro c lab1(intro to 8051)

How to work with ‘KEIL’5. Now create a new file. Go to File>New.

6. Save this file by any name but give the extension

‘.asm’ e.g. firstprog.asm.

7. On the leftmost side, expand ‘Target1’ to ‘Source

Group 1’. Right click on ‘Source Group1’ and select

‘Add files to Group’. A window will appear. Select

file type ‘Asm Source File’ and add the just made file

and close the window.

Page 13: Micro c lab1(intro to 8051)

How to work with ‘KEIL’9. Now go to Project>Options for Target. A new window will

appear. On the ‘Target tab’, modify the xtal frequency to

11.0592. Then go to ‘Output tab’ and check ‘Create HEX File’.

10. Then write the code for the program. After writing code, save

it. Then go to Project>Build Target. In the lower box, if there

are no errors in the file, ‘creating hex file’ will be written. This

means the HEX file is created.

Page 14: Micro c lab1(intro to 8051)

Lab TaskCreate HEX file of a blank program.