A Microcontroller Discussion Board
January 05, 2009, 06:54:05 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: You may have to register before you can post: click the register link below to proceed.
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: INTRODUCTION TO MICROCONTROLLERS..........................BY KSHATRIYA  (Read 2031 times)
0 Members and 1 Guest are viewing this topic.
KSHATRIYA
Great Contributor
Freshy
*****
Posts: 11


Kshatriya ...............The Warrior


View Profile Email
« on: February 22, 2008, 06:45:05 AM »


INTRODUCTION TO MICRO CONTROLLERS(8051)

Microprocessors and micro controller stem from the same idea, are made by the same people, and are sold to the same types same types of system designers and programmers.

Microprocessor's the term has come to be knows to be known is a general-purpose Digital computer central processing unit (CPU). To make the Microprocessor a complete micro computer, one must add memory, usually read-only program memory (ROM) and read and write memory, memory decoders, an oscillator, and a number of input/output devices such parallel and serial data ports. To communicate with external world it needs to have some additional circuitry.

Micro controller, which is a true computer on a chip. The design incorporates all of the features found in a microprocessor CPU: ALU, PC, SP, and registers. It has also has added the other features need make a complete computer. ROM, RAM, parallel I/O, Serial I/O, counters, and a clock circuitry.

To summarize, the microprocessor is concerned with rapid movement of code and data from external addresses to the chip; the micro controller is concerned with rapid movement of bits within the chip. The microcontrollercan function as a computer with addition of no external digital parts; the microprocessor must have man additional parts to be operational.

 Micro controllers are available in N-Channel Metal Oxide Silicon (NMOS) and Complementary Metal Oxide Silicon (CMOS) construction in variety of package types. They are ranging from 8031 to 8751.


Micro controller Features are: -
 
    1.  Internal ROM and RAM
    2.  I/O Ports with programmable pins
    3.  Timers and Counters
    4.  Serial Data Communication



 The 8051 Architecture consists of these specific features:-

   1. Eight-bit CPU with registers A (the accumulator) and B
   2. Sixteen-bit Program Counter (PC) and Data pointer (DPTR).
   3. Eight-bit Program Status Word (PSW).
   4. Eight -bit Stack Pointer (SP).
   5. Internal ROM or EPROM (8751) of (8031) to 4k (8051).
   6. Internal RAM of 128 bytes.
        a. Four register banks, each containing eight registers.
        b. Sixteen bytes, which may be addressed at the bit level.
        c. Eighty bytes of general-purpose data memory.
  7. Thirty-two input/output pins arranged as four 8-bit ports: P0 - P3.
  8. Two 16 bit Timers/Counters: T0 and T1.
  9.  Full duplex serial data Receiver/Transmitter: SBUF.
  10. Control registers: TCON, TMOD, SCON, PCON, IP and IE.
  11. Two external and three internal interrupt sources.
  12. Oscillator and clock circuits.
   
8051 is a collection of 8 and 16 bit registers and 8 bit memory locations. These registers and memory locations can be made to operate using the software instructions.

The program instructions control the registers and digital data paths that are contained inside the 8051,as well as memory locations that are located outside the 8051.

  Micro controller is same as Microcomputer but there is some special purpose registers. Most of registers have specific function. They are specify by symbolic name, such as A or TH0 or PC.

  Each register has an internal 1-byte address assigned to it. Some registers are both byte and bit addressable. That is, the entire byte of data or bit s at such register address may be read or altered.

 Software instructions are generally able to specify a register by its address, its symbolic name or both.  Many of the pins are used for more than one function. Not at the same time.


LIST  OF SPECIAL FUNCTION REGISTERS IN 8051:-

SYMBOL REGISTER    ADDRESS    BIT ADDRESSABLE          RESET     
               
ACC   Accumulator      E0h   Yes (Function)         00h

B   B register      F0h   Yes (Function)         00h

DPTR   Data Pointer               
DPH   Data Pointer high   83h                  00h
 DPL   Data Pointer low   82h                  00h

IE   Interrupt enables   A8h   Yes (Function)            0x000000B
IP   Interrupt priority   B8h   Yes (Function)            xx000000B
P0   Port 0         80h   Yes    (Function)         FFh
P1   Port 1         90h   Yes    (Function)         FFh
P2   Port 2         A0h   Yes    (Function)         FFh
P3   Port 3         B0h   Yes    (Function)         FFh

PCON   Power control      87h             (Function)         0xxxxxxxB
PSW   Pgm status word   D0h   Yes (Function)         00h
SBUF   Serial data buffer   99h                   xxxxxxxxB
SCON   Serial controller   98h   Yes (Function)         00h

SP   Stack pointer      81h                  07h

TCON   Timer control      88h   Yes (Function)      
TH0   Timer high 0      8Ch                   00h
TH1   Timer high 1      8Dh                  00h

TL0   Timer low 0      8Ah                  00h
TL1   Timer low 1      8Bh                  00h

TMOD   Timer mode      89h          (Function)                  00h

Port 1: (#1-#8) Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. Port 1 pins that have 1s written to them are pulled high by the internal pull-ups, and in that state can be used as inputs. As inputs, port 1 pins that are externally being pulled low will source current because of the internal pull-ups.

RST: (#9) Reset. A high on this pin for two machine cycles while the oscillator is running, resets the device. An internal diffused resistor to Vss permits a power-on reset using only an external capacitor to Vcc.

Port 3: (#10-#17) Port 3 is an 8-bit bi-directional I/O port with internal pull-ups. It also serves the functions of various special features of the 80C51 Family as follows:

Port Pin   Pin #      Alternate Function

P3.0      10      RXD (serial input port)
P3.1      11      TXD (serial output port)
P3.2      12      INT0\ (external interrupt 0)
P3.3      13      INT1\ (external interrupt 1)
P3.4      14      T0 (timer 0 external input)
P3.5      15      T1 (timer 1 external input)
P3.6      16      WR\ (external data memory write strobe)
P3.7      17      RD\ (external data memory read strobe)

XTAL2: (#18) Output from the inverting oscillator amplifier.

XTAL1:(#19) Input to the inverting oscillator amplifier.

Vss: (#20) Circuit ground potential

Port 2: (#21-#28) Port 2 is an 8-bit bi-directional I/O port with internal pull-ups. Port 2 emits the high-order address byte during accesses to external memory that use
16-bit addresses. In this application, it uses the strong internal pullups when emitting 1s. More About the Ports

pSEN\Sad#29) Program Store Enable is the read strobe to external Program Memory.

ALE/PROG:(#30) Address Latch Enable output pulse for latching the low byte of the address during accesses to external memory. ALE is emitted at a constant rate of 1/6 of the oscillator frequency, for external timing or clocking purposes, even when there are no accesses to external memory. (However, one ALE pulse is skipped during each access to external Data Memory.) This pin is also the program pulse input (PROG) during EPROM programming.

EA\ /Vpp: (#31) When EA\ is held high the CPU executes out of internal Program Memory (unless the Program Counter exceeds 0FFFh in the 80C51). Holding EA\ low forces the CPU to execute out of external memory regardless of the Program counter value. In the 80C31, EA\ must be externally wired low. In the EPROM devices, this pin also receives the programming supply voltage (Vpp) during EPROM programming.

Port 0: (#39-#32) Port 0 is an 8-bit open drain bi-directional port. As an open drain output port, it can sink eight LS TTL loads. Port 0 pins that have 1s written to them float, and in that state will function as high impedance inputs. Port 0 is also the multiplexed low-order address and data bus during accesses to external memory. In this application it uses strong internal pull-ups when emitting 1s. Port 0 emits code bytes during program verification. In this application, external pull-ups are required.

Vcc: (#40) Supply Voltage.

TIMERS AND COUNTERS:-

The 80C51 has two 16-bit Timer/Counter registers: Timer 0 and Timer 1. Both can be configured to operate either as timers or event counters. In addition to the "Timer" or "Counter" selection, Timer 0 and Timer 1 have four operating modes from which to select.

Timer 0 & Timer 1:-
Control bits C/T in the Special Function Register TMOD select the "Timer" or "Counter" function. These two Timer/Counters have four operating modes, which are selected by bit-pairs (M1,M0) in TMOD. Modes 0, 1, and 2 are the same for both Timers/Counters. Mode 3 is different.
Mode 0:-
   In this mode, the Timer register is configured as a 13-bit register. As the count rolls over from all 1s to all 0s, it sets the Timer interrupt flag TFx. The counted input is enabled to the Timer when TRx=1 and either GATE=0 or INTx\=1. Rx is a control bit in the Special Function Register TCON. GATE is in TMOD.
The 13-bit register consists of all 8 bits of THX and the lower 5 bits of TLx. The upper 3 bits of TLx are indeterminate and should be ignored.

Mode 1:-
   Mode 1 is the same as Mode 0, except that the Timer register is being run with all 16 bits.

Mode 2:-
   Mode 2 configures the Timer register as an 8-bit Counter (TLx) with automatic reload. Overflow from TLx not only sets TFx, but also reloads TLx with the contents of THx, which is preset by software. The reload leaves THx unchanged.
Mode 2 operation is the same for both Timer/Counters.

Mode 3:-
   Timer 1 in Mode 3 simply holds its count. The effect is the same as setting TR1=0.Timer 0 in Mode 3 establishes TL0 and TH0 as two separate counters. TL0 uses the Timer 0 control bits: C/T, GATE, TR0, INT0, and TF0. TH0 is locked into a timer function (counting machine cycles) and takes over the use of TR1 and TF1 from Timer 1. Thus, TH0 now controls the "Timer 1" interrupt.
Mode 3 is provided for applications requiring an extra 8-bit timer on the counter. With Timer 0 in Mode 3, an 80C51 can look like it has three Timer/Counters. When Timer 0 is in Mode 3, Timer 1 can be turned on and off by switching it out of and into its own Mode 3, or can still be used by the serial port as a baud rate generator, or in fact, in any application not requiring an interrupt.

DETAILS ABOUT SFR'S
USED FOR TIMER/COUNTER MANIPULATIONS:-


TCON: Timer/Counter Control Register. Bit Addressable.

 

TF1      Timer 1 overflow flag. Set by hardware when the Timer/Counter 1
             overflows.   Cleared by hardware as processor vectors to the interrupt   
service routine.
TR1   Timer 1 run control bit. Set/cleared by software to turn Timer/Counter 1 ON/OFF.
TF0   Timer 0 overflow flag. Set by hardware when the Timer/Counter 0 overflows.    Cleared by hardware as processor vectors to the service routine.
TR0   Timer 0 run control bit. Set/cleared by software to turn Timer/Counter 0 ON/OFF.




IE1      External Interrupt 1 edge flag. Set by hardware when External Interrupt edge
Is ducted. Cleared by hardware when interrupt is processed.
IT1      Interrupt 1 type control bit. Set/cleared by software to specify falling edge/low     level triggered External Interrupt.
IE0   External Interrupt 0 edge flag. Set by hardware when External Interrupt edge
 Is detected. Cleared by hardware when interrupt is processed.
IT0   Interrupt 0-type control bit. Set/cleared by software to specify falling
edge/low  level triggered External Interrupt.

TMOD: Timer/Counter Mode Control Register. Not Bit Addressable.

 
              Timer 1                 Timer 0


GATE      When TRx (in TCON) is set and GATE=1, Timer/CounterX will run
                         only while INTx pin is high (hardware control). When GATE=0,            Timer/CounterX will run only while TRx=1 (software control).
C/T      Timer or Counter selector. Cleared for Timer operation (input from       internal system clock). Set for Counter operation
(input from TX input   pin).
M1      Mode selector bit.
M0      Mode selector bit.

M1   M0      Mode   Operating Mode
0   0      0   13-bit Timer (8048 compatible)
0   1      1   16-bit Timer/Counter
1   0      2   8-bit Auto-Reload Timer/Counter
1   1      3   (Timer 0) TL0 is an 8-bit Timer/Counter controlled by                      the standard Timer 0 control bits. TH0 is an 8-bit Timer
And is    controlled by Timer 1 control bits.
1   1      3   (Timer 1) Timer/Counter 1 stopped.
SERIAL PORT SET-UP IN 8051: -

The serial port is full duplex, meaning it can transmit and receive simultaneously. It is also receive-buffered, meaning it can commence reception of a second byte before a previously received byte has been read from the register. (However, if the first byte still hasn't been read by the time reception of the second byte is complete, one of the bytes will be lost.) The serial port receive and transmit registers are both accessed at Special Function Register SBUF. Writing to SBUF loads the transmit register, and reading SBUF accesses a physically separate receive register.






DATA TRANSMISSION: -

     Transmission of serial data bits begins anytime data is written to sbuf. " TI "  (SCON) set to 1 when data has been transmitted and signifies that " SBUF " is empty and that another data byte can be sent.

DATA RECEPTION: -

     Reception of serial data will begin if the receive enable bit (REN) in SCON is set to ' 1 ' for all modes. For mode ' 0 ' only RI must be cleared to 0. Receiver interrupt flag ' RI ' (in SCON) is set after data has been received in all modes. Setting of
 ' REN ' bit  is a direct program control that limits the reception of unexpected data.

The serial port can operate in 4 modes:

Mode 0: -
Serial data enters and exits through RXD. TXD output the shift clock. 8 bits are transmitted/received (LSB first). The baud rate is fixed at 1/12 the oscillator frequency.
Mode 1:-
10 bits are transmitted (through TxD) or received (through RxD): a start bit (0), 8 data bits (LSB first), and a stop bit (1). On receive, the stop bit goes into RB8 in Special Function Register SCON. The baud rate is variable.

Mode 2:
11 bits are transmitted (through TXD) or received (through RXD): start bit (0), 8 data bits (LSB first), a programmable 9th data bit, and a stop bit (1). On Transmit, the 9th data bit (TB8 in SCON) can be assigned the value of 0 or 1. Or, for example, the parity bit (P, in the PSW) could be moved into TB8. On receive the 9th data bit goes into RB8 in Special Function Register SCON, while the stop bit is ignored. The baud rate is programmable to either 1/32 or 1/64 the oscillator frequency.

Mode 3:11 bits are transmitted (through TxD) or received (through RxD): a start bit (0), 8 data bits (LSB first), a programmable 9th data bit, and a stop bit (1). In fact, Mode 3 is the same as Mode 2 in all aspects except baud rate. The baud rate in Mode 3 is variable

GUYS IF ANYONE HAS BEEN BENEFITTED BY MY POST PLEASE POST THE REPLY ..........
IT WILL GIVE IMMENSE SATISFACTION TO ME................THANK U

...................................KSHATRIYA............................................
Logged
A Microcontroller Discussion Board
« on: February 22, 2008, 06:45:05 AM »

 Logged
Doug
Administrator
Jr. Member
*****
Posts: 83



View Profile WWW
« Reply #1 on: February 22, 2008, 08:05:02 PM »

Welcome again KSHATRIYA. It's a nice tutorial. Thanks for sharing to our community.


LET HERE BE YOUR WORLD!!!


Cheer!
Logged

Microcontroller Weblog
http://www.mcuprogramming.com/
KSHATRIYA
Great Contributor
Freshy
*****
Posts: 11


Kshatriya ...............The Warrior


View Profile Email
« Reply #2 on: February 23, 2008, 04:51:09 AM »

THANK U VERY MUCH.......DOUG FOR UR VALUABLE SUPPORT

.................................KSHATRIYA.......
Logged
mohan
Newbie
*
Posts: 1



View Profile Email
« Reply #3 on: October 10, 2008, 11:39:58 AM »

thanks good job Smiley
Logged
sebarex
Newbie
*
Posts: 1



View Profile Email
« Reply #4 on: October 22, 2008, 02:35:57 PM »

Today microcontrollers also include Analog-to-digital converters, DACs, Analog Comparators, Hardaware multiplier, supply voltage supervisor and several gp registers.

TI MSP430 is an example, and is my favourite microcontroller.
Logged
A Microcontroller Discussion Board
   

 Logged
Pages: [1]
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Introduction to 8051 Micrcontroller Tutorials mcuprogrammer 0 710 Last post October 27, 2007, 10:41:03 PM
by mcuprogrammer
Introduction to SDCC: Small Device C Compiler Tutorials mcuprogrammer 0 570 Last post October 27, 2007, 10:51:02 PM
by mcuprogrammer
Microcontrollers and the GNU Public License (GPL) Tutorials mcuprogrammer 0 621 Last post October 27, 2007, 11:42:14 PM
by mcuprogrammer
microcontrollers which one??? Announcements a.mlw.walker 1 288 Last post January 19, 2008, 02:33:56 PM
by Doug
Welcome KSHATRIYA Announcements mcuprogrammer 0 166 Last post February 11, 2008, 05:14:18 PM
by mcuprogrammer
Powered by MySQL Powered by PHP Powered by SMF 1.1.7 | SMF © 2006-2008, Simple Machines LLC | Sitemap Valid XHTML 1.0! Valid CSS!