MSC-51

Size: px
Start display at page:

Download "MSC-51"

Transcription

1 اصول ميکروکامپيوترها استاد درس: دکتر ا درس و Website برای تکاليف و... : ١ پانزدهم فصل ا شنايی با ميکروکنترولرها خانواده MSC-51 ٢ ١

2 Contents: Introduction Block Diagram and Pin Description of the 8051 Registers Memory Mapping in 8051 Stack in the 8051 Addressing Modes and Instructions I/O Port Programming Timer ٣ Interrupt Why do we need to learn Microprocessors/controllers? The microprocessor is the core of computer systems. Nowadays many communication, digital entertainment, portable devices, are controlled by them. A designer should know what types of components he/she needs, ways to reduce production costs and product reliable. ٤ ٢

3 Different aspects of a microprocessor/controller Hardware :Interface to the real world Software :order how to deal with inputs ٥ ٦ The necessary tools for a microprocessor/controller CPU: Central Processing Unit I/O: Input /Output Bus: Address bus & Data bus Memory: RAM & ROM Timer Interrupt Serial Port Parallel Port ٣

4 Microprocessor vs. Microcontroller Microprocessor CPU is stand-alone, RAM, ROM, I/O, timer are separate Designer can decide on the amount of ROM, RAM and I/O ports. Expansive Versatility General-purpose Microcontroller CPU, RAM, ROM, I/O and timer are all on a single chip Fix amount of on-chip ROM, RAM, I/O ports For applications in which cost, power and space are critical Single-purpose ٧ مقايسه ميکروکامپيوتر با ميکروکنترولر ميکروکنترولرها در کاربرد های (خاص) ثابتی مورد استفاده قرار می گيرند. به دليل نوع کاربرد دارای ملزومات سخت افزاری و نرم افزاری متفاوت هستند. به دليل کاربردهای کنترلی به مجموعه دستورالعمل متفاوتی نياز دارد. درميکروکنترولرها برنامه کنترلی در ROM قرار می گيرد. نياز به RAM کم است. سيستم های ميکرو کامپيوتری دارای کاربرد عام هستند. به دليل نياز به سخت افزار بيشتر سيستم های م يکروکامپيوتری گرانتر است. ٨ ٤

5 Embedded System Embedded system means the processor is embedded into that application. An embedded product uses a microprocessor or microcontroller to do one task only. In an embedded system, there is only one application software that is typically burned into ROM. Example:printer, keyboard, video game player ٩ More examples of embedded systems Mobile phone Braking systems Traction control Engine management units Steer-by-wire (includes fly-by-wire) Cruise control Video Cassette Recorder (VCR) Auto-pilots Flight control systems Radar systems Missile guidance systems ١٠ ٥

6 Three criteria in Choosing a Microcontroller 1. Meeting the computing needs of the task efficiently and cost effectively Speed, the amount of ROM and RAM, the number of I/O ports and timers, size, packaging, power consumption Easy to upgrade Cost per unit 2. Availability of software development tools Assemblers, Debuggers, C-compilers, Emulator, Simulator, Technical support 3. Wide availability and reliable sources of the microcontrollers. ١١ مقايسه ميکروکامپيوتر با ميکروکنترولر مينيمم سيستم يک ميکروکامپيوتر ١٢ ٦

7 Microprocessors: CPU for Microcomputers No RAM, ROM, I/O on CPU chip itself Example:Z80-CPU, Intel s 8085A, Intel s x86, Motorola s 680x0 CPU Data Bus Many chips on mother s board General- Purpose Microprocessor RAM ROM I/O Port Timer Serial COM Port Address Bus ١٣ General-Purpose Microcomputer System Microcontroller : A smaller computer On-chip RAM, ROM, I/O ports... Example: Intel s 8051, Motorola s 6811, Zilog s Z8 and PIC 16X CPU I/O Port RAM Timer ROM Serial COM Port Microcontroller A single chip ١٤ ٧

8 Microcontroller Block Diagram External interrupts Interrupt Control On-chip ROM for program code On-chip RAM Timer/Counter Timer 1 Timer 0 Counter Inputs CPU OSC Bus Control 4 I/O Ports Serial Port P0 P1 P2 P3 TxD RxD Address/Data ١٥ 8051 Block Diagram INT1 INT0 شماي داخلی میکروکنترولر 8051 Interrupt control Timer2 (8032 / 8052) Timer 1 Timer 0 Serial port Other registers 128 bytes RAM (8032 / 8052) 128 bytes RAM ROM 0K /8032 4K K Timer 2 (8032/8052) Timer 1 Timer 0 T2EX* T2* T1* T0* CPU باس داخلی Oscillator Bus control I / O ports Serial Port ١٦ EA RST ALE PSEN P0 P2 P1 P3 TXD* RXD* Address/Data ٨

9 ويژگی های 8051: ( ۴ کيلوبايت ۸) ROM کيلوبايت برای 8052 ( ۱۲۸ بايت ۲۵۶) RAM بايت برای 8052 ۴ پورت ورودی- خروجی ۸ بيتی( PIO ) - دو تايمر ۱۶ بيتی (۳ تايمر برای 8052) پورت سريال( Interface (Serial امکان دسترسی به ۶۴ کيلوبايت حافظه بيرونی برای برنامه( Code ) امکان دسترسی به ۶۴ کيلوبايت حافظه بيرونی برای داده (Data) امکان کار روی بيت Processor) (Boolean ۲۱۰ بيت قابل ا درس دهی توانايی انجام عمليات ضرب و تقسيم در کمتر از ۴μs ١٧ ويژگی های خانواده 8051 ١٨ ٩

10 فرکانس های کار 8051 ١٩ تصوير ا ی سی 8052 ساخت کارخانه Atmel ٢٠ ١٠

11 ROM memory map in 8051 family 0000H 4k 0000H 0000H 0FFFH 8751 AT89C51 8k 8752 AT89C52 32k DS FFFH 7FFFH ٢١ from Atmel Corporation from Dallas Semiconductor Pin Description of the 8051 ٢٢ P1.0 P1.1 P1.2 P1.3 P1.4 P1.5 P1.6 P1.7 RST (RXD)P3.0 (TXD)P3.1 (INT0)P3.2 (INT1)P3.3 (T0)P3.4 (T1)P3.5 (WR)P3.6 (RD)P3.7 XTAL2 XTAL1 GND (8031) Vcc P0.0(AD0) P0.1(AD1) P0.2(AD2) P0.3(AD3) P0.4(AD4) P0.5(AD5) P0.6(AD6) P0.7(AD7) EA/VPP ALE/PROG PSEN P2.7(A15) P2.6(A14) P2.5(A13) P2.4(A12) P2.3(A11) P2.2(A10) P2.1(A9) P2.0(A8) ١١

12 رجيسترهای داخلی ميکروکنترولر 8051 PSW PC SP DPH DPL Data Pointer (DPTR) ACC B بيت های مربوط به رجيستر پرچم R7 R6 R5 R4 R3 R2 R1 R0 ٢٣ Program Status Word (PSW) Registers PSW A B R0 R1 R2 R3 R4 R5 R6 R7 DPTR PC DPH PC DPL Some bit Register Some 8-bitt Registers of the 8051 ٢٤ ١٢

13 ۸۰ بايت رجيسترها وRAM داخلی ميکروکنترولر 8051 ۱۲۸ بيت قابل ا درس دهی SETB 7FH MOV A, 7FH معادل (7FH) LD A, ادرس های RAM داخلی يک بايتی است ٢٥ رجيسترهای داخلی ميکروکنترولر 8051 ٢٦ Accumulator Program Status Word B Register Stack Pointer Data Pointer Port Register Power Control Register PCON Low Timer Register High Timer Register Timer Mode Register TMOD Timer Control Register TCON Interrupt Enable Register IE Interrupt Priority Register IP Serial Port Data Register SBUF Serial Port Control Register SCON ACC or A PSW B SP DPTR Pi i= 0, 1, 2, 3 TLi i=0, 1 THi i=0, 1 ١٣

14 علامت اختصاری نام وا درس های رجيستر های (با کارکرد) خاص ٢٧ ادامه جدول ٢٨ ١٤

15 فضای RAM داخلی ميکروکنترولر 8051 و 8052 Internal RAM SFR s MOV A, 0F0H معادل (0F0H) LD A, Direct Add. mode ا درس رجيسترB است F0H ٢٩ MOV R0, #0F0H MOV LD R0, 0F0H LD A, (R0) Indirect Add. Mode RAM memory space allocation in the FH Scratch pad RAM 30H ٣٠ 2FH 20H 1FH 18H 17H 10H 0FH 08H 07H 00H Bit-Addressable RAM Register Bank 3 Register Bank 2 (Stack) Register Bank 1 Register Bank 0 ١٥

16 Stack in the 8051 The register used to access the stack is called SP (stack pointer) register. 7FH 30H Scratch pad RAM MOV The stack pointer in the 8051 is only 8 bits wide, which means that it can take value 00 to FFH. When 8051 powered up, the SP register contains value 07. ٣١ SP, #30H ; Initialize Stack Pointer 2FH 20H 1FH 18H 17H 10H 0FH 08H 07H 00H Bit-Addressable RAM Register Bank 3 Register Bank 2 (Stack) Register Bank 1 Register Bank 0 پايه های (Pinots) 8051 (مدل سخت افزاری) Program Store Enable (PSEN) External Access (EA) 0V ExternalROM EA = 5V InternalROM Upon reset, all ports are configured as out-put ports. ٣٢ ١٦

17 Pins of 8051 (1/4) Vcc(pin 40): Vcc provides supply voltage to the chip. The voltage source is +5V. GND(pin 20):Ground XTAL1 and XTAL2(pins 19,18) ٣٣ Figure (a). XTAL Connection to 8051 Using a quartz crystal oscillator We can observe the frequency on the XTAL2 pin 18. C2 30pF C1 30pF XTAL2 XTAL1 ٣٤ GND ١٧

18 RST(pin 9):Reset Pins of 8051 (2/4) It is an input pin and is active high (normally low). The high pulse must be high at least 2 machine cycles. It is a power-on reset. Upon applying a high pulse to RST, the microcontroller will reset and all values in registers will be lost. ٣٥ Reset values of some 8051 registers + Vcc Figure (b). Power-On RESET Circuit 10 uf 8.2 K 30 pf 30 pf MHz EA/VPP X1 X2 RST ٣٦ ١٨

19 Pins of 8051 (3/4) EA (pin 31):External Access There is no on-chip ROM in 8031 and The EA pin is connected to GND to indicate the code is stored externally. PSEN & ALE are used for external ROM. For 8051, EA pin is connected to Vcc. PSEN (pin 29):Program Store ENable This is an output pin and is connected to the OE pin of the ROM. ٣٧ ٣٨ Pins of 8051 (4/4) ALE (pin 30):address latch enable It is an output pin and is active high port 0 provides both address and data. The ALE pin is used for de-multiplexing the address and data by connecting to the G pin of the 74LS373 latch. I/O port pins The four ports P0, P1, P2, and P3. Each port uses 8 pins. All I/O pins are bi-directional. ١٩

20 Pins of I/O Port The 8051 has four I/O ports Port 0 (pins 32-39):P0 (P0.0~P0.7) Port 1 (pins 1-8) :P1(P1.0~P1.7) Port 2(pins 21-28):P2(P2.0~P2.7) Port 3(pins 10-17):P3(P3.0~P3.7) Each port has 8 pins. Named P0.X (X=0,1,...,7), P1.X, P2.X, P3.X Ex:P0.0 is the bit 0(LSB)of P0 Ex:P0.7 is the bit 7(MSB)of P0 These 8 bits form a byte. ٣٩ Each port can be used as input or output (bi-direction). Port 3 Alternate Functions P3 Bit Function Pin P3.0 P3.1 P3.2 P3.3 P3.4 P3.5 P3.6 P3.7 RxD TxD INT0 INT1 T0 T1 WR RD ٤٠ ٢٠

21 ٤١ نحوه Demultiplex کردن خطوط Data و Address ٤٢ ٢١

22 نحوه استفاده از حافظه خارجی ٤٣ Interfacing To External Memory 74HC138 A 13 A 14 A 15 A B C E1 E2 E3 O 0 O 1 O 2 O 3 O 4 O 5 O 6 O P2.7 P2.6 P2.5 P2.4 P2.3 P2.2 P2.1 P2.0 ALE P0.7 P0.6 P0.5 P0.4 P0.3 P0.2 P0.1 P0.0 G D D D D D D D D 373 Q Q Q Q D Q Q Q A 12 A 11 A 10 A 9 A 8 A 7 A 6 A 5 A 4 A 3 A 2 A 1 A 0 OE CS 8 K EPROM D 0 D 1 D 2 D 3 D 4 D 5 D 6 D 7 D 0 D 1 D 2 D 3 D 4 D 5 D 6 D 7 WR RD CS 8 K RAM A 12 A 11 A 10 A 9 A 8 A 7 A 6 A 5 A 4 A 3 A 2 A 1 A 0 PSEN (P3.6) (P3.7) WR RD ٤٤ EA ٢٢

23 ٤٥ نحوه استفاده از دو بانک حافظه RAM وROM خارجی با يک مدارDecoder Add. ٤٦ Hardware Structure of I/O Pin Each pin of I/O ports Internal CPU bus:communicate with CPU A D-latch stores the value of this pin D-latch is controlled by Write to latch Write to latch=1:write data into the D latch 2 Tri-state buffer TB1: controlled by Read pin Read pin=1:really reads the data present at the pin TB2: controlled by Read latch Read latch=1:to read value from internal latch A transistor M1 gate Gate=0: open Gate=1: close ٢٣

24 A Pin of Port 1 Read latch TB2 Vcc Load(R1) Internal CPU bus D Q P1.X P1.X pin Write to latch Clk Q M1 Read pin TB1 P0.x ٤٧ 8051 IC Writing 1 to Output Pin P1.X Read latch 1. write a 1 to the pin SETB P1.X Internal CPU bus Write to latch Vcc TB2 Load(L1) 2. output pin is Vcc D Q 1 P1.X P1.X pin Clk Q 0 M1 output 1 Read pin TB1 ٤٨ 8051 IC ٢٤

25 Writing 0 to Output Pin P1.X Read latch 1. write a 0 to the pin MOV P1,#00H Internal CPU bus Write to latch Vcc TB2 Load(L1) 2. output pin is ground 0 D Q P1.X P1.X pin Clk Q 1 output 0 M1 Read pin TB1 ٤٩ 8051 IC Reading High at Input Pin Read latch 1. write a 1 to the pin MOV P1, #0FFH TB2 Vcc Load(L1) 2. MOV A, P1 external pin=high Internal CPU bus Write to latch D Q P1.X Clk Q 1 0 M1 1 P1.X pin TB1 ٥٠ Read pin 3. Read pin=1 Read latch=0 Write to latch= IC ٢٥

26 Reading Low at Input Pin Read latch 1. write a 1 to the pin MOV P1,#0FFH Internal CPU bus TB2 1 D Q P1.X Vcc Load(L1) 0 2. MOV A,P1 external pin=low P1.X pin Write to latch Clk Q 0 M1 TB1 ٥١ Read pin 3. Read pin=1 Read latch=0 Write to latch= IC پورت ها هرکدام به صورت بايت يا بيت قابل ا درس دهی هستند ( Single-Bit Addressability of Ports) Port's Bit D0 D1 D2 D3 D4 D5 D6 P3 P3.0 P3.1 P3.2 P3.3 P3.4 P3.5 P3.6 P2 P2.0 P2.1 P2.2 P2.3 P2.4 P2.5 P2.6 Pl P1.0 Pl.1 P1.2 P1.3 P1.4 P1.5 P1.6 P0 P0.0 P0.1 P0.2 P0.3 P0.4 P0.5 P0.6 ٥٢ SETB P1.2 ; P1.2=1 CLR P1.2 ; P1.2=0 CPL P30 ; Complement P1.2 MOV P1, 0FFH ; P1 = FF (P1 is configured I/P ) ٢٦

27 Other Pins P1, P2, and P3 have internal pull-up resisters. P1, P2, and P3 are not open drain. P0 has no internal pull-up resistors and does not connects to Vcc inside the P0 is open drain. However, for a programmer, it is the same to program P0, P1, P2 and P3. All the ports upon RESET are configured as output. P0.x ٥٣ A Pin of Port 0 Read latch TB2 Internal CPU bus D Q P1.X P0.X pin Write to latch Clk Q M1 Read pin TB1 ٥٤ 8051 IC P1.x ٢٧

28 Port 0 with Pull-Up Resistors Vcc 10 K DS P0.0 P0.1 P0.2 P0.3 P0.4 P0.5 P0.6 P0.7 Port 0 ٥٥ RESET Value of Some 8051 Registers Register Reset Value PC 0000 ACC 0000 B 0000 PSW 0000 SP 0007 DPTR 0000 ٥٦ RAM are all zero. ٢٨

29 رجيسترهای مخصوص تايمرهای داخلی 8051/2 ٥٧ Timer : ٥٨ ٢٩

30 رجيستر کنترل کننده تايمرها( Register (TCON TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT0 TF1: Timer 1 overflow flag. TR1: Timer 1 run control bit.(tr1=1 Timer1 runs) TF0: Timer 0 overflow flag. TR0: Timer 0 run control bit..(tr0=1 Timer0 runs) IE1: External interrupt 1 edge flag. (IE-Flags are used by CPU) IT1: External interrupt 1 type flag.(it1=1 Edge-triggered) IE0: External interrupt 0 edge flag. IT0: External interrupt 0 type flag. ٥٩ رجيستر تعيين کننده مود تايمرها Register) (TMOD Gate C/T M1 M0 Gate C/T M1 M0 Timer1 Timer0 Gate : When set, timer only runs while INT0 (or 1) is high. C/T : Counter/Timer select bit. M1 : Mode bit 1. M0 : Mode bit 0. M1 0 M0 0 Mode 13 bit Timer Mode bit Timer Mode bit auto-reload Mode ٦٠ 1 1 Split Mode ٣٠

31 Mode های مختلف تايمرها XTAL Oscillator f/12 C/ T= 0 TR=1 TLX THX (8bits) (8bits) TF is set when FFFF 0000 TFX Overflow Flag Mode1 XTAL Oscillator f/12 C/ T= 0 TR=1 TLX THX (5bits) (8bits) TF is set when FFFF 0000 TFX Overflow Flag Mode0 Mode2 ٦١ XTAL Oscillator f/12 C/ T= 0 TR=1 TLX (8bits) THX (8bits) Reload TFX Overflow Flag Mode 3 Timer1: Timer Clock TL1 (8bits) TH1 (8bits) Timer0: Timer Clock TL0 (8bits) TF0 Overflow Flag ٦٢ 12 f Osci TL0 (8bits) TF1 Overflow Flag ٣١

32 عملکرد تايمر ۱ در Mode1 ٦٣ Interrupt : ٦٤ ٣٢

33 Interrupt Enable (IE) Register EA - ET2 ES ET1 EX1 ET0 EX0 EA : Global enable/disable. --- : Undefined. ET2 :Enable Timer 2 interrupt. ES :Enable Serial port interrupt. ET1 :Enable Timer 1 interrupt. EX1 :Enable External 1 interrupt. ET0 : Enable Timer 0 interrupt. EX0 : Enable External 0 interrupt. ٦٥ حالت ها ا درس دهی 8051 The 8051Addressing Modes ٦٦ ٣٣

34 (ا درس دهی با ثبات) -1 Register Addressing Mode Operand به صورت يک بايت در يکی از رجيسترهای داخلی( Rn ) قرار دارد. MOV A, R7 ; Copy the contents of R7 into A ADD A, R7 ; Add the contents of R7 to A مثال: MOV MOV R7, A A, R5 INC R0 ; Increment R0 DEC R1 ; Decrement R1 ANL A, R6 ; Logic AND (A+R6) ٦٧ (ا درس دهی مستقيم) 2-Direct Addressing Mode MOV A, P1 MOV A, 7FH ا درس Operand به صورت يک بايت داده می شود ; Copy the contents of P1 (7FH) into A ; Copy the contents of memory location (7FH) into A مثال: INC 7FH ; Increment memory location (7FH) MOV MOV P1, A A, DPH ADD A, 4 ANL A, 37H ; AND Logically MOV 4, 7 ; Copy the contents of R7 into R4 MOV ٦٨ R4, R7 Invalid Instruction ٣٤

35 (ا درس دهی غير مستقيم) Mode -3 Indirect Addressing ا درس در يکی از رجيسترهای R0 يا R1 قرار دارد MOV ; Copy the contents of (R7) into A A B MOV MOVX ; Read from external memory A ; Write to external memory MOVX ; Read from external memory A ; Write to external memory ADD ; Add the contents of (R0) to A ANL ; AND Logic ***** مثال: ٦٩ (ا درس دهی بلافصل) 4-Immediate Addressing Mode ٧٠ Data ا درس يا Operand مقدار ثابتی است MOV A, #12H MOV DPTR, #2000H MOV DPL #00 MOV DPH #2O MOV R4, #62 MOV R4, #COUNT ADD A, #25H ANL A, #33 مثال: ٣٥

36 (ا درس دهی نسبی) Mode 5-Relative Addressing از اين ا درس دهی برای پرش های نسبی کوتاه (۱۲۷- تا ۱۲۸+) استفاده می شود JZ AGAIN ; Jump if A=0 JNZ AGAIN ; Jump if A 0 SJMP 5 ; Jump forward 5 locations SJMP 0F6H ; Jump back 10 locations JB P1.2, LABLE1 ; Jump if the bit is set (P1.2=1) JC LABLE2 ; Jump if Carry is set (Cy=1) JNC LABLE2 ; Jump if Carry is not set (Cy=0) SJMP START مثال: DJNZ Ri, 5 ; Decrement Ri and jump if Ri 0 ٧١ DJNZ CJNE R7, AGIN R5, #73H, AGAIN ;Compare and Jump if Not Equal مثال: (ا درس دهی مطلق) 6- Absolute Addressing Mode فقط در دستورات ACALL و AJMP استفاده می شود. ا درس دارای ۱۱ بيت است. به هر خانه ای در صفحه ۲ کيلوبايت حاضر می تواند پرش کند. AJMP ACALL THERE ;Absolute Jump THERE ;Absolute Jump ٧٢ ٣٦

37 (ا درس دهی طولانی) 7- Long Addressing Mode فقط در دستورات LCALL و LJMP استفاده می شود. ا درس دارای ۱۶ بيت است. به هر خانه ای در حافظه می تواند پرش کند. LJMP LCALL THERE ;Long Jump THERE ;Long Call مثال: ٧٣ (ا درس دهی انديس دار) -8 Indexed Addressing Mode فقط در دستورات JMP و MOVC استفاده می شود. ا درس حاصل مساوی است با محتويات PC يا DPTR (به عنوان ا درس پايه) بعلاوه محتويات ا کومولاتور (به عنوان ا فست). اين مود ا درس دهی کار با جداول را ا سان می کند. MOVC MOVC ;Read from address (A+PC) ;Read from address (A+DPTR) مثال: Jump to address (A+DPTR) ٧٤ ٣٧

38 ا شنايی بادستورالعمل ها و برنامه نويسی ميکروکنترولر 8051 ٧٥ SETBbit ; bit=1 CLR bit ; bit=0 دستورالعمل های مربوط به bit SETB C ; CY=1 SETB P0.0 ;bit 0 from port 0 =1 SETB P3.7 ;bit 7 from port 3 =1 SETB ACC.2 ;bit 2 from ACCUMULATOR =1 SETB 05 ;set high D5 of RAM loc. 20h Note: CLR instruction is as same as SETB i.e.: CLR C ; CY=0 But following instruction is only for CLR: ٧٦ CLR A ; A=0 ٣٨

39 DEC byte ;byte=byte-1 INC byte ;byte=byte+1 INC R7 DEC A DEC 40H ; [40]=[40]-1 SETB P0.0.. ACALL UP.. UP: CLR P0.0. RET ٧٧ Call instruction ACALL SUBROUTINE1 LCALL SUBROUTINE2 دستورالعمل های پرش شرطی JZ JNZ DJNZ CJNE A, byte CJNE Reg, data JC JNC JB JNB Jump if A=0 Jump if A 0 Decrement and jump if A 0 Jump if A byte Jump if byte data Jump if CY=1 Jump if CY=0 Jump if bit=1 Jump if bit=0 ٧٨ JBC Jump if bit=1 and clear bit ٣٩

40 Example 1: Write a program to a) clear ACC, b) add 3 to the accumulator ten times. Solution: ;This program adds value 3 to the ACC ten times MOV A, #0 ;A=0, clear ACC MOV R2, #10 ;load counter R2=10 AGAIN: ADD A, #03 ;add 03 to ACC DJNZ R2, AGAIN ;repeat until R2 = 0 (10 times) MOV R5, A ;save A in R5 ٧٩ Example 2 : Port 1 as input To make port 1 an input port, it must be programmed as such, by writing 1 to all its bits. Port 1 is configured first as an input port by writing 1 s to it, then data is received from that port and saved in R7, R6, and R5. Solution: ٨٠ MOV A,#0FFH ;A=FF hex MOV P1, A ;make P1 an input port by writing all 1s to it MOV A,Pl ;get data from P1 MOV R7, A ;save it in reg R7 ACALL DEALY ;wait MOV A, P1 ;get another data from PI MOV R6, A ;save it in reg R6 ACALL DELAY :wait MOV A,P1 ;get another data from P1 MOV R5, A ;save it in reg R5 ٤٠

41 Example 3: Write a program to toggle all the bits of P2 continuously. Solution: ٨١ MOV A, #55H BACK: MOV P2, A ACALL DELAY CPL Example 4: SJMP A BACK First Configure Port 2 as an input port. Then receive data from that port and is sent to P1 continuously. Solution: MOV A, #0FFH ;A=FF hex MOV P2, A ;make P2 an input port by writing all 1s to it BACK: MOV A, P2 ;get data from P2 MOV P1, A ;send it to Port 1 SJMP BACK ;keep doing that Example 5: Assume that RAM locations have the following values. Write a program to find the sum of the values. At the end of the program, register A should contain the low byte and R7 the high byte. All values are in hex. 40=(7D), 41=(EB), 42=(C5), 43=(5B), 44=(30) Solution: MOV R0, #40H ;load pointer MOV R2, #5 ;load counter CLR A ;A=0 MOV R7, A ;clear R7 AGAIN: ADD ;add the byte pointed to by R0 JNC NEXT ;if CY=0 don't accumulate carry INC R7 ;keep track of carries NEXT: INC R0 ;increment pointer if carry is set DJNZ R2, AGAIN ;repeat until R2 is zero ٨٢ ٤١

42 Example 6: Assume internal RAM memory locations 40H - 44H contain the daily temperature for five days, as shown below. Search to see if any of the values equals 65. lf value 65 does exist in the table, give its location to R4; otherwise, make R4 = 0. 40H=(76), 41H=(79), 42H=(69), 43H=(65), 44H=(62) Solution: ٨٣ MOV R4,#0 ; R4=O MOV R0, #40H ; load pointer MOV R2, #05 ; load counter MOV A, #65 ; A=65, value searched for BACK: CJNE NEXT ;compare RAM data with 65 MOV R4, RO ; if 65, save address SJMP EXIT ;and exit NEXT: INC R0 ; otherwise increment pointer EXIT... DJNZ R2, BACK ; keep checking until count=0 مثال ۷: برنامه ای بنويسيد که ۱۶ خانه حافظه از ا درس ۶۰ به بعد را پاک کند. CLR A MOV R1, #60 MOV R7, #16 AGIN: A INC R1 DJNZ R7, AGIN MOV R1, #60 MOV R2, #35 MOV R7, #16 BACK: MOV A INC R1 INC R2 مثال ۸: برنامه ای بنويسيد که ١٦ خانه حافظه از ا درس ٦٠ به بعد را در خانه های حافظه از ٣٥ به بعد کپی کند. DJNZ R7, BACK ٨٤ ٤٢

43 مثال ۹: برنامه ای بنويسيد که در پايه P1.2 ايجاد شکل موج مربعی کند. ٨٥ Example 10: In the following program, we are creating a square wave of 50% duty cycle on the P 1.5 bit. Timer 0 is used to generate the time delay. MOV TMOD, #01 ;Timer 0, mode 1 (16-bit mode) HERE: MOV TL0, #0F2H ;TL0= F2H, the low byte MOV THO,#OFFH ;THO=FFH, the high byte CPL P1.5 ;toggle PI.5 ACALL DELAY SJMP HERE ;load TH,TL again ; -delay using timer 0 DELAY: SETB TR0 ;start the timer 0 AGAIN: JNB TF0, AGAIN ;monitor timer flag 0 until it rolls over CLR TR0 ;stop timer 0 CLR TF0 ;clear timer 0 flag RET ٨٦ ٤٣

44 Example 11: Examine the following program and find the time delay in seconds. Exclude the over-head due to the instructions in the loop. MOV TMOD, #10H ; Timer 1, mode 1(16-bit) MOV R3, #200 ; counter for multiple delay AGAIN: MOV TL1, #08 ; TL1=08, low byte of timer MOV TH1, #01 ; TH1=01, Hi byte SETB TR1 ; start the timer 1 BACK: JNB TF1, BACK ; stay until timer rolls over Solution: CLR TRI ; stop timer 1 CLR TF1 ; clear timer flag 1 DJNZ R3, AGAIN ; if R3 not zero then reload timer TH - TL = 0108H = 264 in decimal and = Now x μs = ms, and for 200 of them we have 200 x ms = seconds. ٨٧ Example 12: Assuming that XT AL = MHz, find (a) the frequency of the square wave generated on pin P1.0 in the following program, and (b) the smallest frequency achievable in this program, and the TH value to do that. MOV TMOD, #20H ; T1/ mode 2/ 8-bit/ auto reload MOV TH1, #5 ; TH1=5 SETB TR1 ; start the timer 1 BACK: JNB TF1, BACK ; stay till timer rolls over CPL P1.0 ; comp. P1.0 to get hi, lo CLR TF1 ; clear tl.mer J.ag 1 SJMP BACK ; mode 2 is auto-reload Solution: (a) In mode 2 we do not need to reload TH since it is auto-reload. Now (256-05) x ).is = 251 x ).is = ).is is the high portion of the pulse. Since it is a 50% duty cycle square wave, the period T is twice that; as a result T = 2 x ).is = ).is and the frequency = khz. (b) To get the smallest frequency, we need the largest T and that is achieved when TH= 00. In ٨٨ that case, we have T = 2 x 256 x ).is = ).is and the frequency = 1.8 khz. ٤٤

45 نحوه اتصال ورودی و خروجی ساده به ميکروکنترولر ٨٩ 4 4 Matrix Hex Keypad 8051 Column 0 Column 1 Column 2 Column 3 P1.7 P1.6 P1.5 P1.4 P1.3 P1.2 P1.1 P1.0 Row 3 Row 2 C D E F 8 9 A B Row Row 0 ٩٠ ٤٥

46 ساخت شمارنده يک رقمی باAT89C51 ٩١ نحوه اتصال LCD به ميکروکنترولر 8051 RS: Register Select RS = D/C E: Enable 8051 E R/ W RS DB7 DB0 communications bus microcontroller ٩٢ 8 LCD controller ٤٦

47 LCD Command Codes code command to LCD Instruction Register 1 Clear display screen 2 Return home 4 Decrement cursor (shift cursor to left) 6 Increment cursor (shift cursor to right) 5 Shift display right 7 Shift display left 8 Display off, cursor off A Display off, cursor on C Display on, cursor off- E Display on, cursor not blinking F Display on, cursor blinking 10 Shift cursor position to left 14 Shift cursor position to right ٩٣ LCD Command Codes code command to LCD Instruction Register 18 Shift the entire display to the left 1C Shift the entire display to the right 80 Force cursor to beginning of 1st line C0 Force cursor to beginning of 2nd line 38 2 lines and 5x7 matrix (To initialize the LCD) ٩٤ 40 Characters / Line ٤٧

48 Example 13: نحوه Initialize کردن وارتباط با LCD ; Check busy flag before sending data, command to LCD. P1=data port ; P2.0 connected to RS (D/C) pin. P2.1 connected to R/W pin. ; P2.2 connected to E pin ORG MOV A, #38H ;Init. LCD 2 lines,5x7 matrix ACALL COMMAND ; issue command MOV A, #0EH ; LCD on, cursor on ACALL COMMAND ; issue command MOV A, #01H ; clear LCD command ACALL COMMAND ; issue command MOV A, #06H ; shift cursor right ACALL COMMAND ; issue command MOV A, #86H ; cursor: line 1, pos. 6 ACALL COMMAND ; command subroutine MOV A, #'N' ; display letter N ٩٥ ACALL DATA_DISPLAY Example 13 (Continued): MOV A,#'O ; display letter ACALL DATA DISPLAY HERE: SJMP HERE ; STAY HERE COMMAND: ACALL READY is LCD ready? MOV P1, A ; issue command code CLR P2.0 ; RS=O for command CLR P2.1 ; R/W=O to write to LCD SETB P2.2 ; E=1 for H-to-L pulse CLR P2.2 ; E=O,latch in RET DATA_DISPLAY: ACALL READY ; is LCD ready? MOV P1, A ; lssue data SETB P2.0 ; RS=l for data CLR P2.1 ; R/W=O to write to LCD SETB P2.2 ; E=1 for H-to-L pulse CLR P2.2 ; E=0, latch in ٩٦ RET ٤٨

49 Example 13 (Continued): READY: SETB P1.7 ; Make P1.7 input port. CLR P2.0 ; RS=O access command Reg. SETB P2.1 ; R/W=1 read command Reg. ; Read command reg and check busy flag. BACK: SETB P2.2 ; E=1 for L-to-H pulse CLR P2. 2 ; E=0 for H- to-l pulse JB P1.7, BACK ; Stay until busy flag=o RET END ۱ بود LCD (P1.7) Data نيست پس از خواندن رجيستر فرمان اگر پرچم خوانده شده مشغول است وا ماده دريافت بايت Command يا ٩٧ مبدل ا نالوگ به ديجيتال ۸ کاناله EOC: End Of Conversion OE: Output Enable SC: Start Conversion ٩٨ ٤٩

50 پايان ٩٩ ٥٠

اصول ميکروکامپيوترها استاد درس: دکتر http://ee.iust.ac.ir/rahmati/index.htm rahmati@iust.ac.ir ا درس Email و Website برای تکاليف و... : http://eel.iust.ac.ir/rahmati/ ١ نوزدهم فصل ا شنايی با دستورالعمل

More information

اصول ميکروکامپيوترها استاد درس: دکتر http://eeiustacir/rahmati/indexhtm rahmati@iustacir ا درس Email و Website برای تکاليف و : http://eeliustacir/rahmati/ ١ /١۴ هفدهم فصل ا شنايی با دستورالعمل ها وMode

More information

اصول ميکروکامپيوترها استاد درس: دکتر http://ee.iust.ac.ir/rahmati/index.htm rahmati@iust.ac.ir ا درس Email و Website برای تکاليف و... : http://eel.iust.ac.ir/rahmati/ ١ هجدهم فصل ا شنايی با تايمرهای 8051

More information

Three criteria in Choosing a Microcontroller

Three criteria in Choosing a Microcontroller The 8051 Microcontroller architecture Contents: Introduction Block Diagram and Pin Description of the 8051 Registers Some Simple Instructions Structure of Assembly language and Running an 8051 program

More information

Microcontrollers can be considered as self-contained systems with a processor, memory and I/O ports.

Microcontrollers can be considered as self-contained systems with a processor, memory and I/O ports. 8051 Architecture 1 Microcontrollers can be considered as self-contained systems with a processor, memory and I/O ports. In most cases, all that is missing is the software to define the operation of the

More information

EEE3410 Microcontroller Applications Department of Electrical Engineering Lecture 4 The 8051 Architecture

EEE3410 Microcontroller Applications Department of Electrical Engineering Lecture 4 The 8051 Architecture Department of Electrical Engineering Lecture 4 The 8051 Architecture 1 In this Lecture Overview General physical & operational features Block diagram Pin assignments Logic symbol Hardware description Pin

More information

Embedded Controller Programming

Embedded Controller Programming Embedded Controller Programming Counters, Timers and I/O in Assembly Language Ken Arnold Copyright 2000-2004 Ken Arnold 1 Outline Timer/Counters Serial Port More 8051 Instructions Examples Copyright 2000-2004

More information

Engr. A. N. Aniedu Electronic and Computer Engineering Nnamdi Azikiwe University, Awka

Engr. A. N. Aniedu Electronic and Computer Engineering Nnamdi Azikiwe University, Awka Engr. A. N. Aniedu Electronic and Computer Engineering Nnamdi Azikiwe University, Awka INTRODUCTION Microcontroller vs General Purpose Microprocessor General-purpose microprocessors contains No RAM No

More information

Microcontroller Intel [Instruction Set]

Microcontroller Intel [Instruction Set] Microcontroller Intel 8051 [Instruction Set] Structure of Assembly Language [ label: ] mnemonic [operands] [ ;comment ] Example: MOV R1, #25H ; load data 25H into R1 2 8051 Assembly Language Registers

More information

Introduction To MCS-51

Introduction To MCS-51 Introduction To MCS-51 By Charoen Vongchumyen Department of Computer Engineering Faculty of Engineering KMITLadkrabang 8051 Hardware Basic Content Overview Architechture Memory map Register Interrupt Timer/Counter

More information

8051 MICROCONTROLLER

8051 MICROCONTROLLER 8051 MICROCONTROLLER Mr.Darshan Patel M.Tech (Power Electronics & Drives) Assistant Professor Department of Electrical Engineering Sankalchand Patel College of Engineering-Visnagar WHY DO WE NEED TO LEARN

More information

UNIT 2 THE 8051 INSTRUCTION SET AND PROGRAMMING

UNIT 2 THE 8051 INSTRUCTION SET AND PROGRAMMING UNIT 2 THE 8051 INSTRUCTION SET AND PROGRAMMING Instructions Alphabetical List of Instructions ACALL: Absolute Call ADD, ADDC: Add Accumulator (With Carry) AJMP: Absolute Jump ANL: Bitwise AND CJNE: Compare

More information

Unit I. Introduction Microcontrollers and Embedded processors Overview of the 8051 Inside the 8051 Addressing Modes

Unit I. Introduction Microcontrollers and Embedded processors Overview of the 8051 Inside the 8051 Addressing Modes Unit I Introduction Microcontrollers and Embedded processors Overview of the 8051 Inside the 8051 Addressing Modes 1.1.1. Basic Introduction 1.1.1. Basic Introduction (contd.) 1.1.1. Basic Introduction

More information

UNIT IV MICROCONTROLLER

UNIT IV MICROCONTROLLER UNIT IV 8051- MICROCONTROLLER Prepared by R. Kavitha Page 1 Application Prepared by R. Kavitha Page 2 Pin Description of the 8051 UNIT IV- 8051 MICROCONTROLLER P1.0 P1.1 P1.2 P1.3 P1.4 P1.5 P1.6 P1.7 RST

More information

Microprocessors 1. The 8051 Instruction Set. Microprocessors 1 1. Msc. Ivan A. Escobar Broitman

Microprocessors 1. The 8051 Instruction Set. Microprocessors 1 1. Msc. Ivan A. Escobar Broitman Microprocessors 1 The 8051 Instruction Set Microprocessors 1 1 Instruction Groups The 8051 has 255 instructions Every 8-bit opcode from 00 to FF is used except for A5. The instructions are grouped into

More information

8051 Microcontroller memory Organization and its Applications

8051 Microcontroller memory Organization and its Applications 8051 Microcontroller memory Organization and its Applications Memory mapping in 8051 ROM memory map in 8051 family 0000H 4k 0000H 8k 0000H 32k 0FFFH DS5000-32 8051 1FFFH 8752 7FFFH from Atmel Corporation

More information

EE6502- MICROPROCESSOR AND MICROCONTROLLER

EE6502- MICROPROCESSOR AND MICROCONTROLLER . EE6502- MICROPROCESSOR AND MICROCONTROLLER UNIT III - 8051 MICROCONTROLLER PART - A 1. What is Microcontroller? A device which contains the microprocessor with integrated peripherals like memory, serial

More information

Module I. Microcontroller can be classified on the basis of their bits processed like 8bit MC, 16bit MC.

Module I. Microcontroller can be classified on the basis of their bits processed like 8bit MC, 16bit MC. MICROCONTROLLERS AND APPLICATIONS 1 Module 1 Module I Introduction to Microcontrollers: Comparison with Microprocessors Harvard and Von Neumann Architectures - 80C51 microcontroller features - internal

More information

8051 Overview and Instruction Set

8051 Overview and Instruction Set 8051 Overview and Instruction Set Curtis A. Nelson Engr 355 1 Microprocessors vs. Microcontrollers Microprocessors are single-chip CPUs used in microcomputers Microcontrollers and microprocessors are different

More information

1. Pin diagram of 8051 and ports

1. Pin diagram of 8051 and ports e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: Programming parallel ports Module No: CS/ES/9 Quadrant 1 e-text In this lecture pin diagram of 8051 controller will be shown and

More information

8-bit Microcontroller with 8K Bytes In-System Programmable Flash AT89S52

8-bit Microcontroller with 8K Bytes In-System Programmable Flash AT89S52 Features Compatible with MCS -51 Products 8K Bytes of In-System Programmable (ISP) Flash Memory Endurance: 10,000 Write/Erase Cycles 4.0V to 5.5V Operating Range Fully Static Operation: 0 Hz to 33 MHz

More information

VRS540-4kB Flash, 128B RAM, 25~40MHz, 8-Bit MCU

VRS540-4kB Flash, 128B RAM, 25~40MHz, 8-Bit MCU VRS540-4kB Flash, 28B RAM, 25~40MHz, 8-Bit MCU 34 Ste Catherine Street West, Suite 900, Montreal, Quebec, Canada H3B H4 Tel: (54) 87-2447 http://www.goalsemi.com P.3 P.2 XTAL NC P0./AD VRS540 Overview

More information

Microcontroller and Embedded Systems:

Microcontroller and Embedded Systems: Microcontroller and Embedded Systems: Branches: 1. Electronics & Telecommunication Engineering 2. Electrical & Electronics Engineering Semester: 6 th Semester / 7 th Semester 1. Explain the differences

More information

VRS550-8kB Flash, 256B RAM, 25~40MHz, 8-Bit MCU VRS560-16kB Flash, 256B RAM, 40MHz, 8-Bit MCU

VRS550-8kB Flash, 256B RAM, 25~40MHz, 8-Bit MCU VRS560-16kB Flash, 256B RAM, 40MHz, 8-Bit MCU VRS550-8kB Flash, 256B RAM, 25~40MHz, 8-Bit MCU VRS560-6kB Flash, 256B RAM, 40MHz, 8-Bit MCU 34 Ste Catherine Street West, Suite 900, Montreal, Quebec, Canada H3B H4 Tel: (54) 87-2447 http://www.goalsemi.com

More information

8051 Microcontroller

8051 Microcontroller 8051 Microcontroller EE4380 Fall 2001 Pari vallal Kannan Center for Integrated Circuits and Systems University of Texas at Dallas 8051 Architecture Programmer s View Register Set Instruction Set Memory

More information

MICROPROCESSORS AND MICROCONTROLLERS MATERIAL. Features of 8051:

MICROPROCESSORS AND MICROCONTROLLERS MATERIAL. Features of 8051: DEPARTMENT OF ECE MICROPROCESSORS AND MICROCONTROLLERS MATERIAL UNIT V 8051 MICROCONTROLLERS To make a complete microcomputer system, only microprocessor is not sufficient. It is necessary to add other

More information

UNIT THE 8051 INSTRUCTION SET AND PROGRAMMING

UNIT THE 8051 INSTRUCTION SET AND PROGRAMMING UNIT THE 8051 INSTRUCTION SET AND PROGRAMMING Instructions Alphabetical List of Instructions ACALL: Absolute Call ADD, ADDC: Add Accumulator (With Carry) AJMP: Absolute Jump ANL: Bitwise AND CJNE: Compare

More information

Interrupts. EE4380 Fall 2001 Class 9. Pari vallal Kannan. Center for Integrated Circuits and Systems University of Texas at Dallas

Interrupts. EE4380 Fall 2001 Class 9. Pari vallal Kannan. Center for Integrated Circuits and Systems University of Texas at Dallas 8051 - Interrupts EE4380 Fall 2001 Class 9 Pari vallal Kannan Center for Integrated Circuits and Systems University of Texas at Dallas Polling Vs Interrupts Polling: MCU monitors all served devices continuously,

More information

Module Contents of the Module Hours COs

Module Contents of the Module Hours COs Microcontrollers (EE45): Syllabus: Module Contents of the Module Hours COs 1 8051 MICROCONTROLLER ARCHITECTURE: Introduction to Microprocessors and Microcontrollers, the 8051 Architecture, 08 1 and pin

More information

2. Write an 8051 program to generate a square wave of 25 khz at pin P2.3 using XTAL = 12 MHz. Solution:

2. Write an 8051 program to generate a square wave of 25 khz at pin P2.3 using XTAL = 12 MHz. Solution: Assignment 2 1. Assume that 5 binary data items are stored in RAM locations starting at 50h, as shown below. Write a program to find the sum of all the numbers. The calculation is in 16-bit format and

More information

CIDESI Minimal Configuration of a Microcomputer System

CIDESI Minimal Configuration of a Microcomputer System CIDESI 24.9.22 اصول میکروکامپیوترها دانشکده برق دانشگاه علم و صنعت ایران :... درس: دکتر رحمتی http://ee.iust.ac.ir/rahmati/index.htm آدرس Email و Website براي تکالیف و rahmati@iust.ac.ir http://eel.iust.ac.ir/rahmati/

More information

8051 Microcontroller

8051 Microcontroller 8051 Microcontroller 1 Salient Features (1). 8 bit microcontroller originally developed by Intel in 1980. (2). High-performance CMOS Technology. (3). Contains Total 40 pins. (4). Address bus is of 16 bit

More information

8051 Microcontroller

8051 Microcontroller 8051 Microcontroller The 8051, Motorola and PIC families are the 3 leading sellers in the microcontroller market. The 8051 microcontroller was originally developed by Intel in the late 1970 s. Today many

More information

Architecture & Instruction set of 8085 Microprocessor and 8051 Micro Controller

Architecture & Instruction set of 8085 Microprocessor and 8051 Micro Controller of 8085 microprocessor 8085 is pronounced as "eighty-eighty-five" microprocessor. It is an 8-bit microprocessor designed by Intel in 1977 using NMOS technology. It has the following configuration 8-bit

More information

8051 Core Specification

8051 Core Specification 8051 Core Specification Authors: Jaka Simsic Simon Teran jakas@opencores.org simont@opencores.org Rev. 0.1 August 14, 2001 First Draft www.opencores.org Rev 0.1 First Draft 1 of 26 Revision History Rev.

More information

VRS570 32K Flash, 1kB RAM, 25~40MHz, 8-Bit MCU VRS580 64K Flash, 1kB RAM, 25~40MHz, 8-Bit MCU

VRS570 32K Flash, 1kB RAM, 25~40MHz, 8-Bit MCU VRS580 64K Flash, 1kB RAM, 25~40MHz, 8-Bit MCU VRS570 32K Flash, 1kB RAM, 25~40MHz, 8-Bit MCU VRS580 64K Flash, 1kB RAM, 25~40MHz, 8-Bit MCU 1134 Ste Catherine Street West, Suite 900, Montreal, Quebec, Canada H3B 1H4 Tel: (514) 871-2447 http://www.goalsemi.com

More information

8051 Timers. Class 7 EE4380 Fall Pari vallal Kannan. Center for Integrated Circuits and Systems University of Texas at Dallas

8051 Timers. Class 7 EE4380 Fall Pari vallal Kannan. Center for Integrated Circuits and Systems University of Texas at Dallas 8051 Timers Class 7 EE4380 Fall 2002 Pari vallal Kannan Center for Integrated Circuits and Systems University of Texas at Dallas Introduction Timers Timing devices - Generate specific time delay Event

More information

Question Bank Microprocessor and Microcontroller

Question Bank Microprocessor and Microcontroller QUESTION BANK - 2 PART A 1. What is cycle stealing? (K1-CO3) During any given bus cycle, one of the system components connected to the system bus is given control of the bus. This component is said to

More information

UNIT MICROCONTROLLER AND ITS PROGRAMMING

UNIT MICROCONTROLLER AND ITS PROGRAMMING M i c r o p r o c e s s o r s a n d M i c r o c o n t r o l l e r s P a g e 1 UNIT-7 8051 MICROCONTROLLER AND ITS PROGRAMMING INTRODUCTION The microcontroller incorporates all the features that are found

More information

Control Transfer Instructions Jump, Loop, and Call. ECE473/573 Microprocessor System Design, Dr. Shiue

Control Transfer Instructions Jump, Loop, and Call. ECE473/573 Microprocessor System Design, Dr. Shiue Control Transfer Instructions Jump, Loop, and Call 1 Jump Instructions JZ label ; Jump if A=0 JNZ label ; Jump if A!=0 DJNZ reg, label ; Decrement and Jump if A (or reg.)!=0 CJNE A, byte ; Compare and

More information

Digital Blocks Semiconductor IP

Digital Blocks Semiconductor IP 805 SFR Bus Digital Blocks Semiconductor IP 805 Microcontroller Configurable Peripherals General Description The Digital Blocks (Configurable Peripherals) Microcontroller Verilog IP Core is complaint with

More information

SN8F5000 Family Instruction Set

SN8F5000 Family Instruction Set SONiX Technology Co., Ltd. 8051-based Microcontroller 1 Overview SN8F5000 is 8051 Flash Type microcontroller supports comprehensive assembly instructions and which are fully compatible with standard 8051.

More information

CPEG300 Embedded System Design. Lecture 8 Timer

CPEG300 Embedded System Design. Lecture 8 Timer CPEG300 Embedded System Design Lecture 8 Timer Hamad Bin Khalifa University, Spring 2018 Review 8051 port and port schematic Internal read/write data path Serial communication vs. parallel communication

More information

MASSEY UNIVERSITY PALMERSTON NORTH CAMPUS

MASSEY UNIVERSITY PALMERSTON NORTH CAMPUS MASSEY UNIVERSITY PALMERSTON NORTH CAMPUS EXAMINATION FOR 159.233 COMPUTER SYSTEMS Semester One June 2008 Time allowed: THREE (3) hours This exam contains THREE (3) questions ANSWER ALL THREE (3) QUESTIONS

More information

Memory organization Programming model - Program status word - register banks - Addressing modes - instruction set Programming examples.

Memory organization Programming model - Program status word - register banks - Addressing modes - instruction set Programming examples. MICROCONTROLLERS AND APPLICATIONS 1 Module 2 Module-2 Contents: Memory organization Programming model - Program status word - register banks - Addressing modes - instruction set Programming examples. MEMORY

More information

Principle and Interface Techniques of Microcontroller

Principle and Interface Techniques of Microcontroller Principle and Interface Techniques of Microcontroller --8051 Microcontroller and Embedded Systems Using Assembly and C LI, Guang ( 李光 ) Prof. PhD, DIC, MIET WANG, You ( 王酉 ) PhD, MIET 杭州 浙江大学 2014 Chapter

More information

8051 microcontrollers

8051 microcontrollers 8051 microcontrollers Presented by: Deepak Kumar Rout Synergy Institute of Engineering and Technology, Dhenkanal Chapter 2 Introduction Intel MCS-51 family of microcontrollers consists of various devices

More information

ET2640 Microprocessors

ET2640 Microprocessors ET2640 Microprocessors Unit -2 Processor Programming Concepts Basic Control Instructor : Stan Kong Email : skong@itt-tech.edu Figure 2 4 Bits of the PSW Register 8051 REGISTER BANKS AND STACK 80 BYTES

More information

MODEL ANSWER SUBJECT- MICROCONTROLLER(12187) CLASS-EJ5E CLASS TEST-02 Q1.)Attempt any THREE of the following.

MODEL ANSWER SUBJECT- MICROCONTROLLER(12187) CLASS-EJ5E CLASS TEST-02 Q1.)Attempt any THREE of the following. MODEL ANSWER SUBJECT- MICROCONTROLLER(12187) CLASS-EJ5E CLASS TEST-02 Q1.)Attempt any THREE of the following. (9M) 1) Describe the instructions SWAP A and MOVX@DPTR,A with one example. (3Marks) SWAP A

More information

The Microcontroller. Lecture Set 3. Major Microcontroller Families. Example Microcontroller Families Cont. Example Microcontroller Families

The Microcontroller. Lecture Set 3. Major Microcontroller Families. Example Microcontroller Families Cont. Example Microcontroller Families The Microcontroller Lecture Set 3 Architecture of the 8051 Microcontroller Microcontrollers can be considered as self-contained systems with a processor, memory and I/O ports. In most cases, all that is

More information

ELEG3923 Microprocessor Ch.9 Timer Programming

ELEG3923 Microprocessor Ch.9 Timer Programming Department of Electrical Engineering University of Arkansas ELEG3923 Microprocessor Ch.9 Timer Programming Dr. Jingxian Wu wuj@uark.edu OUTLINE 2 Programming 8051 Timers Counter programming Timer programming

More information

8051 Microcontroller Assembly Programming

8051 Microcontroller Assembly Programming 8051 Microcontroller Assembly Programming EE4380 Fall 2002 Class 3 Pari vallal Kannan Center for Integrated Circuits and Systems University of Texas at Dallas Topics Machine code 8051 Addressing Modes

More information

MAHALAKSHMI ENGINEERING COLLEGE TIRUCHIRAPALLI UNIT- IV

MAHALAKSHMI ENGINEERING COLLEGE TIRUCHIRAPALLI UNIT- IV UNIT- IV PART A (2 MARK QUESTIONS) 1. What is the need for de-bouncing the keyboard? (AUC NOV 2012) Debouncing is any kind of hardware device or software that ensures that only a single signal will be

More information

8051 Microcontroller. Ali Ziya Alkar 1

8051 Microcontroller. Ali Ziya Alkar 1 8051 Microcontroller Ali Ziya Alkar 1 8051 Introduction 8051 is one of the most popular microcontrollers in use today. Many derivative microcontrollers have since been developed that are based on--and

More information

FACULTY OF ENGINEERING LAB SHEET

FACULTY OF ENGINEERING LAB SHEET FACULTY OF ENGINEERING LAB SHEET MICROCONTROLLER AND MICROPROCESSOR SYSTEMS ECE2216 TRIMESTER 1 (2017/2018) MP2: Construction and programming of a basic electronic piano *Note: On-the-spot evaluation may

More information

Digital Blocks Semiconductor IP

Digital Blocks Semiconductor IP Digital Blocks Semiconductor IP 805 Microcontroller General Description The Digital Blocks Microcontroller Verilog IP Core is complaint with the MCS 5 Instruction Set and contains standard 805 MCU peripherals,

More information

The Timers/Counters The Serial Interface The Interrupt System Reset P0.0-P0.7 P2.0-P2.7. Port 2 Drivers. Port 2 Latch

The Timers/Counters The Serial Interface The Interrupt System Reset P0.0-P0.7 P2.0-P2.7. Port 2 Drivers. Port 2 Latch HARDWARE DESCRIPTION This chapter provides a detailed description of the 80C51 microcontroller (see Figure 1). Included in this description are: The port drivers and how they function both as ports and,

More information

MODULE-1. Short Answer Questions

MODULE-1. Short Answer Questions MODULE-1 Short Answer Questions 1. Give the comparison between microprocessor and microcontroller. It is very clear from figure that in microprocessor we have to interface additional circuitry for providing

More information

e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: 8051 Architecture Module No: CS/ES/5 Quadrant 1 e-text

e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: 8051 Architecture Module No: CS/ES/5 Quadrant 1 e-text e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: 8051 Architecture Module No: CS/ES/5 Quadrant 1 e-text In this lecture the detailed architecture of 8051 controller, register bank,

More information

Application Brief D-005

Application Brief D-005 Interfacing the Avago HDSP-2xxx LED Alphanumeric Displays with the Intel 8751H Microcontroller Application Brief D-005 Introduction The HDSP-21xx/-25xx series of products is ideal for applications where

More information

Chapter Family Microcontrollers Instruction Set

Chapter Family Microcontrollers Instruction Set Chapter 4 8051 Family Microcontrollers Instruction Set Lesson 5 Program Flow Control and Interrupt Flow Control Instructions 2 Branch instructions- Jump to new value of Program Counter (PC) LJMP address16

More information

C51 Family. Architectural Overview of the C51 Family. Summary

C51 Family. Architectural Overview of the C51 Family. Summary Architectural Overview of the C51 Family C51 Family Summary 1. Introduction............................................................ I.1. 1.1. TSC80C51/80C51/80C31.................................................................

More information

CS 320. Computer Architecture Core Architecture

CS 320. Computer Architecture Core Architecture CS 320 Computer Architecture 8051 Core Architecture Evan Hallam 19 April 2006 Abstract The 8051 is an 8-bit microprocessor designed originally in the 1980 s by the Intel Corporation. This inexpensive and

More information

Contents 8051 Instruction Set BY D. BALAKRISHNA, Research Assistant, IIIT-H Chapter I : Control Transfer Instructions Lesson (a): Loop Lesson (b): Jump (i) Conditional Lesson (c): Lesson (d): Lesson (e):

More information

ISSI. IS89C51 CMOS SINGLE CHIP 8-BIT MICROCONTROLLER with 4-Kbytes of FLASH ISSI IS89C51 NOVEMBER 1998 FEATURES GENERAL DESCRIPTION

ISSI. IS89C51 CMOS SINGLE CHIP 8-BIT MICROCONTROLLER with 4-Kbytes of FLASH ISSI IS89C51 NOVEMBER 1998 FEATURES GENERAL DESCRIPTION IS89C51 CMOS SINGLE CHIP 8-BIT MICROCONTROLLER with 4-Kbytes of FLASH NOVEMBER 1998 FEATURES 80C51 based architecture 4-Kbytes of on-chip Reprogrammable Flash Memory 128 x 8 RAM Two 16-bit Timer/Counters

More information

8051 Microcontrollers

8051 Microcontrollers 8051 Microcontrollers Richa Upadhyay Prabhu NMIMS s MPSTME richa.upadhyay@nmims.edu March 8, 2016 Controller vs Processor Controller vs Processor Introduction to 8051 Micro-controller In 1981,Intel corporation

More information

80C51 family programmer s guide and instruction set. 80C51 Family. PROGRAMMER S GUIDE AND INSTRUCTION SET Memory Organization. Philips Semiconductors

80C51 family programmer s guide and instruction set. 80C51 Family. PROGRAMMER S GUIDE AND INSTRUCTION SET Memory Organization. Philips Semiconductors PROGRAMMER S GUIDE AND INSTRUCTION SET Memory Organization Program Memory The 80C51 has separate address spaces for program and data memory. The Program memory can be up to 64k bytes long. The lower 4k

More information

Rev. No. History Issue Date Remark

Rev. No. History Issue Date Remark Preliminary Bar Code Reader Document Title Bar Code Reader Revision History Rev. No. History Issue Date Remark 0.0 Initial issue June 5, 2000 Preliminary 0.1 Change document title from Bar Code Reader

More information

Distributed by: www.jameco.com 1-800-831-4242 The content and copyrights of the attached material are the property of its owner. 8051 8052 and 80C51 Hardware Description December 1992 Order Number 270252-006

More information

Vidyalankar T.E. Sem. V [ETRX] Microprocessors and Microcontrollers I Prelim Question Paper Solution

Vidyalankar T.E. Sem. V [ETRX] Microprocessors and Microcontrollers I Prelim Question Paper Solution 1. (a) 1. (b) T.E. Sem. V [ETRX] Microprocessors and Microcontrollers I Prelim Question Paper Solution Priority modes. 1) Fully Nested Mode : It is a general purpose mode. IR 0 highest priority IR 1 lowest

More information

Programming of 8085 microprocessor and 8051 micro controller Study material

Programming of 8085 microprocessor and 8051 micro controller Study material 8085 Demo Programs Now, let us take a look at some program demonstrations using the above instructions Adding Two 8-bit Numbers Write a program to add data at 3005H & 3006H memory location and store the

More information

MODEL ANSWER SUMMER 17 EXAMINATION Subject Title: Microcontroller Subject Code:

MODEL ANSWER SUMMER 17 EXAMINATION Subject Title: Microcontroller Subject Code: MODEL ANSWER SUMMER 17 EXAMINATION Subject Title: Microcontroller Subject Code: 17534 Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given

More information

SUMMER 13 EXAMINATION

SUMMER 13 EXAMINATION MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC - 27001-2005 Certified) Subject Code: 12187 SUMMER 13 EXAMINATION Model Answer Important Instructions to examiners: 1) The answers should

More information

Microcontroller and Applications

Microcontroller and Applications S.Y. Diploma : Sem. IV [DE/EJ/ET/EN/EX/EQ/IS/IC/IE] Microcontroller and Applications Time: 3 Hrs.] Prelim Question Paper Solution [Marks : 70 Q.1 Attempt any FIVE of the following : [10] Q.1(a) Define

More information

Programming Book Microcontroller Kit. Rev 3.0 January, Wichit Sirichote

Programming Book Microcontroller Kit. Rev 3.0 January, Wichit Sirichote Programming Book1 8051 Microcontroller Kit Rev 3.0 January, 016 016 Wichit Sirichote 1 Contents Overview...3 SAFTY INFORMATION...3 Tools...3 Experiment 1 Blinking LED...4 Experiment Binary number counting...9

More information

Digital Blocks Semiconductor IP

Digital Blocks Semiconductor IP Digital Blocks Semiconductor IP DB805C-FSM 805 Microcontroller FSM Finite State Machine General Description The Digital Blocks DB805C-FSM IP Core contains Digital Blocks compact DB805C CPU Core & GPIO

More information

Q.1. A) Attempt any THREE of the following:

Q.1. A) Attempt any THREE of the following: Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme. 2) The model answer and the answer written by candidate

More information

MCS -51 Programmer s Guide and Instruction Set

MCS -51 Programmer s Guide and Instruction Set MCS -51 Programmer s Guide and Instruction Set November 1992 Order Number 270249-003 COPYRIGHT INTEL CORPORATION 1996 MCS -51 PROGRAMMER S GUIDE AND INSTRUCTION SET CONTENTS PAGE MEMORY ORGANIZATION 1

More information

Interrupt Programming: Interrupts vs. Polling Method:

Interrupt Programming: Interrupts vs. Polling Method: UNIT 4: INTERRUPT PROGRAMMING & SERIAL COMMUNICATION WITH 8051: Definition of an interrupt, types of interrupts, Timers and Counter programming with interrupts in assembly. 8051 Serial Communication: Data

More information

MICROCONTROLLER AND PLC LAB-436 SEMESTER-5

MICROCONTROLLER AND PLC LAB-436 SEMESTER-5 MICROCONTROLLER AND PLC LAB-436 SEMESTER-5 Exp:1 STUDY OF MICROCONTROLLER 8051 To study the microcontroller and familiarize the 8051microcontroller kit Theory:- A Microcontroller consists of a powerful

More information

Mod-3: Interrupts,Timer operation,serial communication 1

Mod-3: Interrupts,Timer operation,serial communication 1 Mod-3: Interrupts,Timer operation,serial communication 1 Module-3 Contents: Interrupts - interrupt sources - interrupt handling programming examples. Timers operation different modes waveform generation-

More information

Dodatak. Skup instrukcija

Dodatak. Skup instrukcija Dodatak Skup instrukcija Arithmetic Operations [@Ri] implies contents of memory location pointed to by R0 or R1 Rn refers to registers R0-R7 of the currently selected register bank 2 ADD A,

More information

UNIT MICROCONTROLLER

UNIT MICROCONTROLLER Page UNIT-5 805 MICROCONTROLLER INTRODUCTION The microcontroller incorporates all the features that are found in microprocessor. The microcontroller has built in ROM, RAM, Input Output ports, Serial Port,

More information

8051 I/O and Class 6 EE4380 Spring 03. Pari vallal Kannan. Center for Integrated Circuits and Systems University of Texas at Dallas

8051 I/O and Class 6 EE4380 Spring 03. Pari vallal Kannan. Center for Integrated Circuits and Systems University of Texas at Dallas 8051 I/O and 8255 Class 6 EE4380 Spring 03 Pari vallal Kannan Center for Integrated Circuits and Systems University of Texas at Dallas Why I/O Ports Controllers need to get external inputs and produce

More information

C H A P T E R 1 INTRODUCTION

C H A P T E R 1 INTRODUCTION C H A P T E R 1 INTRODUCTION The mentioned project is based on the worlds most powerful intel controller 8051. Most of the services provided in todays world are voice interactive, you call up your bank

More information

Assembly Language programming (2)

Assembly Language programming (2) EEE3410 Microcontroller Applications LABORATORY Experiment 2 Assembly Language programming (2) Name Class Date Class No. Marks Arithmetic, Logic and Jump instructions Objectives To learn and practice the

More information

LCD AND KEYBOARD INTERFACING

LCD AND KEYBOARD INTERFACING LCD AND KEYBOARD The 8051 Microcontroller and Embedded Systems: Using Assembly and C Mazidi, Mazidi and McKinlay Chung-Ping Young 楊中平 Home Automation, Networking, and Entertainment Lab Dept. of Computer

More information

CPEG300 Embedded System Design. Lecture 6 Interrupt System

CPEG300 Embedded System Design. Lecture 6 Interrupt System CPEG300 Embedded System Design Lecture 6 Interrupt System Hamad Bin Khalifa University, Spring 2018 Correction Lecture 3, page 18: Only direct addressing mode is allowed for pushing or popping the stack:

More information

JUMP, LOOP AND CALL INSTRUCTIONS

JUMP, LOOP AND CALL INSTRUCTIONS JUMP, LOOP AND CALL INSTRUCTIONS After you have understood the tutorial on Introduction to assembly language which includes simple instruction sets like input/output operations, now it s time to learn

More information

Microcontroller. Instruction set of 8051

Microcontroller. Instruction set of 8051 UNIT 2: Addressing Modes and Operations: Introduction, Addressing modes, External data Moves, Code Memory, Read Only Data Moves / Indexed Addressing mode, PUSH and POP Opcodes, Data exchanges, Example

More information

C51 Family. C51 Family Programmer s Guide and Instruction Set. Summary

C51 Family. C51 Family Programmer s Guide and Instruction Set. Summary C51 Family Programmer s Guide and Instruction Set Summary 1. Memory Organization.................................................... I.3.2 1.1. Program Memory.......................................................................

More information

WINTER 14 EXAMINATION

WINTER 14 EXAMINATION Subject Code: 17534 WINTER 14 EXAMINATION Model Answer Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme. 2)

More information

8XC51RA RB RC Hardware Description

8XC51RA RB RC Hardware Description 8XC51RA RB RC Hardware Description February 1995 Order Number 272668-001 Information in this document is provided in connection with Intel products Intel assumes no liability whatsoever including infringement

More information

8051 Memory Organization BY D. BALAKRISHNA, Research Assistant, IIIT-H Chapter 1: Memory Organization There are 2 types of memories available in 8051 microcontroller. Program memory/c code memory (ROM)

More information

TUTORIAL. Donal Heffernan University of Limerick May Tutorial D.Heffernan 2000,

TUTORIAL. Donal Heffernan University of Limerick May Tutorial D.Heffernan 2000, 8051 TUTORIAL Donal Heffernan University of Limerick May-2002 8051 Tutorial D.Heffernan 2000, 2001 1 Blank 8051 Tutorial D.Heffernan 2000, 2001 2 Some reference material: Test books + MacKenzie Scott.

More information

Embedded World Television, Radio, CD player, Washing Machine Microwave Oven Card readers, Palm devices

Embedded World Television, Radio, CD player, Washing Machine Microwave Oven Card readers, Palm devices A presentation on INTRODUCTION We are living in the Embedded World. We are surrounded with many embedded products and our daily life largely depends on the proper functioning of these gadgets. Television,

More information

Microcontrollers. Fig. 1 gives a comparison of a microprocessor system and a microcontroller system.

Microcontrollers. Fig. 1 gives a comparison of a microprocessor system and a microcontroller system. Syllabus: : Introduction to, 8051 Microcontroller Architecture and an example of Microcontroller based stepper motor control system (only Block Diagram approach). (5 Hours) Introduction to A microcontroller

More information

Q. Classify the instruction set of 8051 and list out the instructions in each type.

Q. Classify the instruction set of 8051 and list out the instructions in each type. INTRODUCTION Here is a list of the operands and their meanings: A - accumulator; Rn - is one of working registers (R0-R7) in the currently active RAM memory bank; Direct - is any 8-bit address register

More information

8051 Programming using Assembly

8051 Programming using Assembly 8051 Programming using Assembly The Instruction Addressing Modes dest,source ; dest = source A,#72H ;A=72H A, # r ;A= r OR 72H R4,#62H ;R4=62H B,0F9H ;B=the content of F9 th byte of RAM DPTR,#7634H DPL,#34H

More information

Introduction to uc & Embedded Systems

Introduction to uc & Embedded Systems Introduction to uc & Embedded Systems Prepared by, Tamim Roshdy Embedded Systems What is an embedded system? An embedded system is an application that contains at least one programmable computer (typically

More information