Interrupts in 8051 8051 Micro-controller by Ravinder Nath Rajotiya - December 3, 2021December 3, 20210 Interrupts in 8051 What is an Interrupt: It is a requesting mechanism for the peripherals to make the microcontroller interrupt the currently executing program and run the program to service the request. The program that is run upon the interrupt is called an ISR (interrupt service routine) Types of Interrupts in 8051 There are five different sources of interrupts A real life example - Before going to sleep, you set the timer. Then forget what the timer does, and go for sleep. When the timer finishes the counting, it alarms and interrupts you from sleep. You then wake and starts doing your routine. sources of interrupt in 8051 are: Timer-0: Timer-0 interrupts Timer-1: Timer-1 interrupts Serial Rx/Tx INT0 INT1 All interrupts in 8051 are vectored interrupts Interrupt
8051 Timers 8051 Micro-controller by Ravinder Nath Rajotiya - December 3, 20210 Timers in 8051 There are two timer in 8051, Timer-0, Timer-1;--- Use of timers: To produce precise delay timing Counting the events Generating baud rate Registers associated with timer operation are: TMOD 89h TCON 88h TH0 8Ch TL0 8Ah TH1 8Dh TL1 8Bh Format of TMOD and TCON registers TMOD SFR (89h) Timer-1 Timer-0 D7 D6 D5 D4 D3 D2 D1 D0 Gate C’/T M1 M0 Gate C’/T M1 M0 1: COUNT only if INT1 (P3.3) input pin is high 0-count regardless of INT1 1- Count pulses on pin T1(P3.5) 0- Count every machine cycle 00 Mode-0; 13 bit timer 01- Timer 16 bit 10 mode-2; 8-bit auto reload 11- Split timer mode 1: COUNT only if INT0 (P3.3) input pin is high 0-count regardless of INT0 1 Count pulses on pin T1(P3.5) Count eevery machine cycle 00 Mode-0; 13 bit timer 01- Timer 16 bit 10 mode-2; 8-bit auto reload 11- Split timer mode Timer Control SFR Timer Control TCON SFR (88h) Bits D7 D6 D5 D4 D3 D2 D1 D0 Bit Address 8F 8E 8D 8C 8B 8A 89 88 Bit Name TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT0 Description Timer-1
Experiment-1: Introduction to 8051 Programming environment and Hardware 8051 Micro-controller by Ravinder Nath Rajotiya - September 16, 20200 Introduction to Hardware ET-8031/51 KIT: General: 8-bit 8031/8051 microcontroller operating at 10/12 MHz with on-chip oscillator and clock circuit, 8 i/o lines, two 16-bit timers/counters, five sources of interrupt structure. 64 KB of external program memory and 64 KB of data memory. Memory: Kit has 8KB RAM using IC 6264 and 32KB of EEPROM monitor using IC 27256 There is a memory space provided for memory expansion, the space can be defined for an address from 4000 – FFFF depending upon size of memory chip to be used. I/O Devices: The kit uses 8279 programmable KB-display controller, 8253- programmable interval timer, 8255 –programmable peripheral interface, peripheral chips. These are explained below: 8279 –Programmable KB and display controller:It is a general
8051 LOGICAL INSTRUCTIONS 8051 Micro-controller by Ravinder Nath Rajotiya - April 24, 2019April 5, 20200 Logical Type Instruction ANL Instruction ANL Performs bit wise AND operation between the specified byte. When used to modify an output port, the value used as the port data will be read from the output data latch, not the input pins of the port. format example Opcode/Encoding Flags affected ANL A, #data ANL A, #3FH 01010100 (54H) immediate P ANL A, @Ri ANL A, @R0 0101011i (57H) P ANL A, direct ANL A, 4BH 01010101 (55H) direct P ANL A, Rn ANL A, R4 01011nnn (nnn is Rn) P ANL C, /bit ANL C, /22H 10110000 (B0H) bit None ANL C, bit ANL C,22H 10000010 (82H) bit C ANL direct, #data ANL 30H, #77H 01010011 (53H) direct immediate None SETB Instruction SETB instruction sets the bit operand to a value of 1 Can be used to carry flag or any other directly addressable bit No other flags are affected by this instruction. Format Example/ Operation Opcode/ Encoding Next Opcode Byte Flags affected Byte SETB bit SETB 63h 11010010 63h C 2 SETB C SETB C C=1 11010011 -- C 1 CPL Instruction CPL instruction is used to logically complement the value
8051 Rotate Instructions 8051 Micro-controller by Ravinder Nath Rajotiya - April 24, 2019April 6, 20200 ROTATE INSTRUCTIONS These instruction rotate the accumulator left, or right with or without carry. The instructions are RR, RRC, RL, RLC. RL Instruction The RL instruction rotates accumulator left one bit left Figure shows how the bits rotate left internally and then bit-7 to bit-0 No flags are affected by this instruction Figure 7.1 : Rotate left logic operation format Example/ Operation Opcode/ Encoding Next Opcode Byte Flags affected Byte Cycles RL A RL A An+1=An for n=0 to 7 A0=A7 00100011 -- none 1 1 RLC Instruction Rotate the accumulator left one bit through carry carry-bit into bit-0, and Bit-7 into carry carry flag is update with bit-7 No other flags are affected by this operation. format example / Operation Opcode/ Encoding Subsequent Byte of Opcode Flags affected Cycles RLC A RLC A An+1=An for n=0 to 7 A0=C C=A7 00110011 -- C, P 1 RR Instruction RR Instruction rotate the accumulator Right one bit Bit-7 to bit-6…..bit-1 to bit-0; bit -0 into bit-7 No flags are affected by this instruction. Format