Documente Academic
Documente Profesional
Documente Cultură
3.1: INTRODUCTION:
The p89v51RD2 is an 8051 microcontroller which is having a 64KB flash memory and 1KB of data RAM.A type characteristics of the p89v51RD2 is its X2 mode option. Actually the engineers designed to run the application with the predictable clock rate or select the X2mode to attain two times the throughput at the similar clock frequency. To meet the performance of this feature reduce the clock frequency to half this radically reduces the EMI. In system programming the flash program memory supports both parallel and serial programming. AT high speed this parallel programming modes offer gang programming which reduces programming cost and market time. By using software control the ISP allows a device to reprogrammed the end product. The application firmware has the capability to field in the wide range of application possible. In application programmable the p89v51RD2 allows the flash program memory to be rearranged while the application is running. 3.1.1: Features: The 8051 microcontroller has 80C51 central processing unit. Which operated at 5V operating voltage from 0 to 40 MHZ. 64 kB of on-chip Flash program memory with ISP (In-System Programming) and IAP (In-Application Programming). Supports 12-clock (default) or 6-clock mode selection via software or ISP. SPI (Serial Peripheral Interface) and enhanced UART. PCA (Programmable Counter Array) with PWM and Capture/Compare functions. Four 8-bit I/O ports with three high-current Port 1 pins (16 mA each). Three 16-bit timers/counters. Programmable Watchdog timer (WDT). Eight interrupt sources with four priority levels. Second DPTR register. Low EMI mode (ALE inhibit). TTL- and CMOS-compatible logic levels.
UART SPI
TIMER 0TIMER1
Port0
Crystal ( Or)Resonator
Oscillator
Symbol
PIN
TYPE
DESCRIPTION
DIP40
TQFP44
PLCC44
Port 2: Port 2 is a 8-bit bidirectional P2.0 to p2.7 21-28 18-25 24-31 I/O internal pull-up I/O port with
with internal pull-ups. Port 2 pins are pulled HIGH by the internal pull-ups when 1s are written to them and can be used as inputs in this states. As inputs, port2 pins that are externally pulled LOW will source current (IIL) because of the internal pull-ups. Port 2 sends highorder address byte during
fetches from external program memory and accesses s external Data Memory that use 16-bit address (MOVX@DPTR). In this application, it uses strong internal pull-ups when transitioning to 1s. Port 2 also receives some control signals and a partial of high-order address bits during the external host mode programming and verification.
P3.0 to p3.7
10-17
5,7-13
11,13-19
I/O
with Port 3: Port 3 is a 8-bit internal pull-ups. When 1s are written to port 3 then its pins are pulled HIGH by the internel pull-ups and can be used as inputs in this states. As inputs, port2 pins will source current (IIL) because of the internal pullups only when port 2 pins are externally pulled LOW. During the external host mode
signals and a partial of high order address bits. P3.0 P3.1 10 11 5 7 11 13 I O RXD:RXD is a serial input port. TXD: TXD is a serial output port
P3.2
12
14
P3.3
13
15
INT
1:External
interrupt
taken as a input.
P3.4
14
10
16
P3.5
15
11
17
T1: T1 is a External count input to Timer/Counter 1. WR: WR is a External data memory write strobe.
P3.6
16
12
18
P3.7
17
13
19
RD: RD is a External data memory read strobe. Program Store Enable: For the
PSEN
29
26
32
I/O
external
program
memory
PSEN is act as a read strobe. PSEN get inactive When device is executed from internal PSEN is
program
memory.
executing code from external program memory, except that two PSEN activations are
device enter into the external host mode programming only when forced HIGH-to-LOW
Reset: Whenever the oscillator RST 9 4 10 I is running, the device will reset by having the HIGH logic state on Reset pin for two machine cycles. If the PSEN pin driven by HIGH-to-LOW input transition if the RST input pin held HIGH, the device will enter the external host mode, else the device will enter into the normal operation mode. External Access Enable: To EA 31 29 35 I fetch Code from external program memory EA must be connected to VSS. For internal program execution EA must be strapped to VDD. Security lock level 4 disable EA, and program execution is possible only from internal program memory. It can tolerate upto 12 V. Address Latch Enable: ALE is ALE/PROG 30 27 33 I/O act as a output signal when latching the low byte of the address during an access to external memory. ALE is also the programming pulse input (PROG) to the flash programming. Normally the ALE can be used for external timing and clocking. One ALE
pulse is skipped only when each access to external data memory happened. ALE is disabled only when AO is set as 1.
NC
6, 17, 28, 39
1, 12, 23, 34
I/O
NC means No Connect
Crystal 1:XTAL1 is a Input for XTAL1 19 15 21 I inverting oscillator amplifier as well as to the internal clock
generator circuits. Crystal 2:XTAL2 is a Output XTAL2 18 14 20 O from the inverting oscillator amplifier.
VDD
40
38
44
VSS
20
16
22
ALE loading issue: When ALE pin experiences higher load (>30 pF) while reset, the microcontroller may enter into other modes rather than normal working mode. This can be avoided by adding a pull-up resistor of 3 khz to 50 Khz to VDD. e.g., for ALE pin.
Special Function Registers (SFRs) are restricted in accessing in the following ways:
In Undefined SFR locations User must not attempt to access. Accesses to any defined SFR locations must be strict for the functions for the SFRs.
SFR bits labelled as follows: 1. - It must written 0 Unless otherwise specified, but can return any value when read. It is a reserved bit and may be used in future derivatives. 2. 0 must be written with 0, and will return a 0 when read. 3. 1 must be written with 1, and will return a 1 when read.
Lower 4 bits are used to indicate Timer0 and Upper 4 bits are used to indicateTimer1. GATE bit is used for either internal or external control. GATE=0 then it indicates internal control, start and stop are controlled by software and GATE=1 then it indicates external control, start and stop are controlled by software and and external source. C/T specify either timer or counter. M0 and M1 bits are used to set timer mode (the same for Timer0 and Timer1) Table 3.2 : 8051 delivers 4 timer modes M1 0 0 1 1 M0 0 1 0 1 Mode Mode 0 Mode 1 Mode 2 Mode 3 Description 13 bit timer 16 bit timer 8 bit auto reload Split timer mode
It is a 8 bit- addressable register in which 4 upper bits are used to indicate timers/counters shown below.
TF1
TR1
TF0
TR0
IE1
IT1
IE0
IT0
If TR set then timer turn on otherwise it turn off. TR=0 turn off, TR=1 turn on.TF0 and TF1 are Timer Flags informing about overflow, If TF=1 then interrupt could be activate, and it should be cleaned.
Equivalent instructions for TCON: Timer0: SETB TR0 CLR TR0 = = = = SETB TCON.4 CLR TCON.4
TH0 and TL0 are upper and lower registers of Timer0, TH1 and TL1 are upper and lower registers of Timer1. They help to set initial value of timer/counter.
3.5.1Timer mode 0:
In this mode Timer 0 is a 13-bit timer, which consists all 8 bits of TH0 and the lower 5 bits of TL0. As a result, the Timer 0 uses only 13 bits out of 16 bits.
8-bit timer or counter. The TL0 timer turns into timer 0, while the TH0 timer turns into timer 1.
to select the serial port and baud rate.Because of its simple understandings serial data transmit is nothing but writing to the SBUF register, while data receive represents reading the same register. The microcontroller will take care of not making any error while data transmission.
SM2 bit4
REN bit3
TB8 bit2
RB8 bit1
TI
RI bit0
SM0 - Serial port mode bit 0 is used for serial port mode selection. SM1 - Serial port mode bit 1. SM2 - Serial port mode 2 bit, It is also known as multiprocessor communication enable bit. When SM2 set, it activates multiprocessor communication in mode 2 ,mode 3 and mode 1. It should be cleared in mode 0.
REN When Reception Enable bit is 1 then it activates serial reception. When it is reset, serial reception is deactivate. TB8 TB8 is a Transmitter bit 8. Because all registers are 8-bit length, this bit gives solution to the problem of transmitting the 9th bit in modes 2 and 3. In the 9th bit TB8 is set to transmit logic 1.
RB8 RB8 is a Receiver bit 8 or the 9th bit received in modes 2 and 3.If the 9th bit received is a logic 1 then RB8 is set by software,. If the 9th bit received is a logic 0 then RB8 is cleared by hardware.
TI TI is a Transmit Interrupt flag it is set automatically when the last bit of a sent byte occurs. TI is a signal to the processor that the line is available for a new byte transmit. It must be cleared from the software.
RI RI is a Receive Interrupt flag, which is set automatically when one byte received. It signals that byte which is to be received should be read quickly before being replaced by a new data. This bit is also cleared from the software.
As seen, serial port mode is selected by combining the SM0 and SM2 bits. SM0 0 SM1 0 MODE 0 DESCRIPTION 8bit shift register BAUD RATE 1/12th of the
quartz frequency 0 1 1 8bit UART Determined timer 1 1 0 2 9bit UART 1/32th of the by
3.7 Reset:
A system reset is a function which is to be used to initializes the MCU and starts the program execution from memory location 0000H. The reset input for device is the RST pin. To reset the device a logic level high is to be applied to the RST pin for at least two machine cycles (24 clocks), after the oscillator becomes stable. While reset ALE, PSEN are weakly pulled high. During reset, ALE and PSEN output a high level for perform a proper reset. External element cant going to affect this level. While the system is running a system reset will not affect the 1 Kbyte of on-chip RAM memory, however, the contents of the on-chip RAM during power up are indeterminate.
EX1 - bit enables or disables external 1 interrupt: 0 - change of the pin INT0 logic state cannot generate an interrupt. 1 - enables an external interrupt on the pin INT0 state change.
0 - change of the INT1 pin logic state cannot generate an interrupt. 1 - enables an external interrupt on the pin INT1 state change.
3.9.1 Idle mode Upon the IDL bit of the PCON register is set, the microcontroller turns off the greatest power consumer- CPU unit while peripheral units such as serial port, timers and interrupt system continue operating normally consuming 6.5mA. In Idle mode, the state of all registers and I/O ports remains unchanged. In order to exit the Idle mode and make the microcontroller operate normally, it is necessary to enable and execute any interrupt or reset. It will cause the IDL bit to be automatically cleared and the program resumes operation from instruction having set the IDL bit. It is recommended that first three instructions to execute now are NOP instructions. They don't perform any operation but provide some time for the microcontroller to stabilize and prevents undesired changes on the I/O ports.
SMOD Baud rate is twice as much higher by setting this bit. GF1 indicates that it is a General-purpose bit . GF0 indicates that it is a General-purpose bit. If PD set to logic 1 then the microcontroller enters into the Power down mode. If IDL set to logic 1 then the microcontroller enters into the Idle mode.