Birla Institute Of Technology

  • Uploaded by: Sean Hill
  • 0
  • 0
  • July 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Birla Institute Of Technology as PDF for free.

More details

  • Words: 599
  • Pages: 5
Birla Institute of Technology Deoghar Tutorial 8051 Micro Controller Made By - RAPIER07

Processor used – Atmel 89S52 (based on the 8051 micro controller)

1st topic  Ports and Pins From the figure given below it is apparent that the 89S52 has 4 ports each port having 8 pins (I/O Lines). Hence there are total 32 pins for I/O. Total no. of pins = 40(for a standard 8051) 40 = 4x8 + 2 + 2 + 1 + 1 + 2 4x8 for the I/O lines 2 for the ground and Vcc (pin no. 20 and 40 respectively) 2 for the external oscillator circuit for regulating or generating the clock of the processor (you can skip this since the AVR unlike the 8051 has the oscillator inbuilt) these are pins 18, 19. 1 for reset (pin no. 9)

1+2 (these 3 pins are meant for use of external memory and not the inbuilt EEPROM or RAM). These are pins 29, 30, 31. Just remember that 31 must be set at +5V to tell the controller that internal memory is to be used.

Diagram for the port structure and the pin structure.

2nd Topic  Memory Management 1.

RAM Used to store the variables is a program during the runtime of the program. Only those variables that have been declared as global are there is the RAM permanently. Other local variables are destroyed when they go out of scope. (you must be knowing local and global variables from C). Due to the limited nature of RAM judicious declaration of global and local variables must be done.

2.

EEPROM (Electronically Erasable Programmable Read Only Memory.) Where the program code is stored permanently. Can be compared to the Hard Disk Drive in a PC. Or better to a pen drive.

Memory is in the form of registers. Each register has 8 bits of memory in the 8051. The register is divided in 8 bits from D0 to D7 where D0 denotes the first bit and D7 the last. Each bit can either have 0 or 1 value. The register can have values from 0 - 255(i.e. 2^8 values because it’s an 8bit register). Each bit has a specific address but as we will be programming in a high level language C we do not need to go into the details of addresses and stuff since it will be handled by the compiler itself. If a bigger value than 255 is to be stored more than 1 register is used. (NOTE: A pin on a micro processor I/O pin can have either 0 or 1 value and hence act like a bit. A port has 8 pins and so

is like a register. This is my personal observation and I don’t know whether it has anything to do with actual bits or registers.)

Embedded C Variables: Data Type

Bits

Bytes

Value Range

bit

1

--

0 to1

unsigned char 8

1

0-255

signed char

8

1

-128 to 127

unsigned int

16

2

0-65535

signed int

16

2

-32768-32767

unsigned long 32

4

0-(2^32-1)

signed long

32

4

Figure the math out yourself

Float

32

4

Basically decimals

Easy way to remember the range for unsigned types is 0 to (2^N)-1 where N is the bits occupied by the data type. Hence the range is 2^N. For unsigned divide the range by 2.Equal no. of negative and positive (positive including 0) numbers. Each byte will fit in a register.

Hence data types with size equal to the byte will be processed the fastest by the controller. Larger data types are processed slower.

Constants:

Related Documents


More Documents from ""