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

Size: px
Start display at page:

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

Transcription

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- programming examples - Serial communication different modes - programming examples. Interrupts There are five interrupt sources for the Since the main RESET input can also be considered as an interrupt, six interrupts can be listed as follows: External Interrupts Port P3 of 8051 is a multi-function port. Different lines of this port carry out functions which are additional to data input-output on the port. Lines P3.2 and P3.3 can be used as interrupt inputs. Interrupts will be caused by a LOW level, or a negative edge on these lines. Half of the special function register TCON is used for setting the conditions for causing interrupts from external sources. This register is bit addressable. IT1 and IT0 are the Interrupt Type flags for external sources 1 and 0 respectively. These decide whether a negative going edge or a LOW level will cause an interrupt. If the bit is set, the corresponding interrupt is edge sensitive. If it is cleared, the interrupt is level sensitive. IE1

2 Mod-3: Interrupts,Timer operation,serial communication 2 and IE0 are the status flags for the two external interrupt lines. If the flag is 1, the selected type of event (edge or level) has occurred on the corresponding interrupt line. Internal Interrupts Internally generated interrupts can be from either timer, or from the serial interface. The serial interface causes interrupts due to a receive event (RI) or due to a transmit event (TI). The receive event occurs when the input buffer of the serial line (SBUF in) is full and a byte needs to be read from it. The transmit event indicates that a byte has been sent a new byte can be written to output buffer of the serial line (SBUF out) timers always count up. When their count rolls over from the maximum count to 0000, they set the corresponding timer flag TF1 or TF0 in TCON. Counters run only while their run flag (TR1 or TR0) is set by the user program. When the run flag is cleared, the count stops incrementing. The 8051 can be setup so that an interrupt occurs whenever TF1 or TF0 is set. Interrupts Enabling Interrupts are enabled in a manner which is quite similar to the There is an interrupt enable special function register IE at byte address A8H. This register is bit addressable. (The assembler gives special mnemonics to each bit address.) The most significant bit of the register is a global interrupt enable flag. This bit must be set in order to enable any interrupt. Bits 6 and 5 are undefined for Bit 4, when set, enables interrupts from the serial port. Bit 3 should be set to enable interrupts from Timer 1 overflow. Bit 2 is set to enable interrupts from external interrupt 1 (pin P3.3 on Port 3). Bit 1 enables interrupts from Timer 0 when it overflows. Bit 0, when set, will enable interrupts from external interrupt 0 (pin P3.2 on Port 3). Interrupt Priorities 8051 has two levels of interrupt priorities: high or low. By assigning priorities, we can control the order in which multiple interrupts will be serviced. Priorities are set by bits in a special function register called IP, which is at the byte address B8H. This register is also bit addressable.

3 Mod-3: Interrupts,Timer operation,serial communication 3 Notice that the bits are in the polling order of interrupts. A 1 in a bit position assigns a high priority to the corresponding source of interrupts a 0 gives it a low priority. In case of multiple interrupts, the following rules apply: While a low priority interrupt handler is running, if a high priority interrupt arrives, the handler will be interrupted and the high priority handler will run. When the high priority handler does RETI, the low priority handler will resume. When this handler does RETI, control is passed back to the main program. If a high priority interrupt is running, it cannot be interrupted by any other source even if it is a high priority interrupt which is higher in polling order. A low-priority interrupt handler will be invoked only if no other interrupt is already executing. Again, the low priority interrupt cannot preempt another low priority interrupt, even if the later one is higher in polling order. If two interrupts occur at the same time, the interrupt with higher priority will execute first. If both interrupts are of the same priority, the interrupt which is higher in polling sequence will be executed first. This is the only context in which the polling sequence matters. Serial Interrupts Serial interrupts are handled somewhat differently from the timers. There are independent interrupt flags for reception and transmission of serial data, called RI and TI. RI indicates that a byte has been received and is available for reading in the input buffer. TI indicates that the previous byte has been sent serially and a new byte can be written to the serial port. A serial interrupt occurs if either of these flags is set. (of course the serial interrupt must be enabled for this to occur). The interrupt service routine should check which of these events caused the interrupt. This can be done by examining the flags. Either or both of the flag might be set, requiring a read from or write to the serial buffer SBUF (or both). Recall that the input and output buffers are distinct but are located at the same address. A read from this address reads the input buffer while a write to the same address writes to the output buffer. The RI and TI flags are not automatically cleared when an interrupt is serviced. Therefore, the interrupt service routine must clear them before returning. Sources of Interrupts Figure shows the set of 8051 interrupt sources. If we follow the external interrupt INT0, for example, we see that this external interrupt connects to the processor at the P3.2 pin. Note Port 3 can be used as a standard input/output port as shown earlier but various Port 3 pins have alternative functionality. When INT0 is activated (negative edge usually), internally within the 8051 the EX0 request is raised. This flags an interrupt request but the relevant interrupt bit within the IE register must be set, along with the EA bit if this interrupt request is to raise an interrupt flag. The interrupt flag IE0 is then raised and causes the program counter (PC) to vector

4 Mod-3: Interrupts,Timer operation,serial communication 4 to vector location 0003h, as discussed earlier. Note, the Timer/Counter interrupt flags can be software polled even if the ETx bits are not enabled. Interrupts can also be software generated by setting the interrupt flags in software. The interrupt flags are accessible as flags on the TCON and SCON registers as follows: Interrupt Handling Fig: Interrupt sources Upon activation of an interrupt, the microcontroller goes through the following steps; 1. It finishes the instruction it is executing and saves the address of the next instruction (PC) on the stack. 2. It also saves the current status of all the inrterrupts internally.

5 Mod-3: Interrupts,Timer operation,serial communication 5 3. It jumps to a fixed location in the memory called the interrupt vector table that holds the address of the interrupt service routine. 4. The microcontroller gets the address of the ISR from the interrupt vector table and jumps to it. It starts to execute the interrupt service routine until it reaches the last instruction of the subroutine, which is RETI (return from interrupt). 5. Upon executing the RETI instruction, the microcontroller returns to the place where it was interrupted. First, it gets the program counter (PC) address from the stack by popping the top two bytes of the stack in to the PC. Then it starts to execute from that address. The following figure shows the flow of operation when a system is interrupted.

6 Mod-3: Interrupts,Timer operation,serial communication 6 Fig: Interrupt Operation Example. In this example it is assumed that some program, say the main program, is executing when the external interrupt INT0 occurs. The 8051 hardware will automatically complete the current machine level (assembler level) instruction and save the Program Counter to the stack. The IE register is also saved to the stack. The IE0 flag is disabled (cleared) so that another INT0 interrupt will be inhibited while the current interrupt is being serviced. The Program Counter is now loaded with the vector location 0003h. This vector address is a predefined address for

7 Mod-3: Interrupts,Timer operation,serial communication 7 interrupt INT0 so that program execution will always trap to this address when an INT0 interrupt occurs. Other interrupt sources have uniquely defined vector addresses for this purpose. The set of these vector addresses is referred to as the interrupt vector table. Program execution is now transferred to address location 0003h. In the example a LJMP instruction is programmed at this address to cause the program to jump to a predefined start address location for the relevant ISR (Interrupt Service Routine) routine. The ISR routine is a user written routine, which defines what action is to occur following the interrupt event. It is good practice to save (PUSH) to the stack any registers used during the ISR routine and to restore (POP) these registers at the end of the ISR routine, thus preserving the registers contents, just like a register is preserved within a subroutine program. The last instruction in the ISR routine is a RETI (RETurn from Interrupt) instruction and this instruction causes the 8051 to restore the IE register values, enable the INT0 flag, and restore the Program Counter contents from the stack. Since the Program Counter now contains the address of the next instruction which was to be executed before the INT0 interrupt occurred, the main program continues as if it had never being interrupted. Thus only the temporal behaviour of the interrupted program has been affected by the interrupt; the logic of the program has not been otherwise affected. Programming examples: 1. Assume that the INT1 pin is connected to a switch that is normally high. Whenever it goes low, it should turn on an LED. The LED is connected to P1.3 and is normally off. When it is turned on, it should stay on for a fraction of a second. As long as the switch is pressed low, the LED should stay on. Solution: ORG 0000H Pressing the switch will cause the LED to be turned on. If it is kept activated,the LED stays on. LJMP MAIN ;--ISR for hardware interrupt INT1 to turn on the LED ORG 0013H SETB P1.3 MOV R3,#255 BACK: DJNZ R3,BACK CLR P1.3 RETI

8 Mod-3: Interrupts,Timer operation,serial communication 8 ;--main program for initialization ORG 30H MAIN: MOV IE,# B ;enable INT1 HERE: SJMP HERE ;stay here until get interrupt END 2. Assuming that pin 3.3 (INT1) is connected to a pulse generator, write a program in which the falling edge of the pulse will send a high to P1.3 which is connected to an LED (or buzzer). In other words, the LED is turned on and off at the same rate as the pulses are applied to the INT1 pin. In this example, to turn on the LED again, the INT1 pulse must be brought back high and then forced low to create a falling edge to activate the interrupt. ORG 0000H LJMP MAIN ;--ISR for hardware interrupt INT1 to turn on the LED ORG 0013H SETB P1.3 MOV R3,#255 BACK: DJNZ R3,BACK ;keep the buzzer on for a while CLR P1.3 RETI ;--MAIN program for initialization ORG 30H MAIN: SETB TCON 0.2 ;make INT1 edge-trigger interrupt MOV IE,# B ;enable External INT 1 HERE: SJMP HERE END Timers Timer is a clock that controls the sequence of an event while counting in fixed intervals of time. A Timer is used for producing precise time delay. Secondly, it can be used to repeat or initiate an action after/at a known period of time. This feature is very commonly used in several

9 Mod-3: Interrupts,Timer operation,serial communication 9 applications. An example could be setting up an alarm which triggers at a point of time or after a period of time. Most of the microcontrollers have inbuilt Timers. Timers in a controller not only generate time delays but they can also be used as counters. They are used to count an action or event. The value of counter increases by one, every time its corresponding action or event occurs. Timers in a controller are inbuilt chips that are controlled by special function registers (SFRs) assigned for Timer operations. These SFRs are used to configure Timers in different modes of operations. While working with microcontrollers, it is more than often required to generate time delays. There are two possible ways of generating time delays. First is by using the code, like using for or while loops in a C program. However, the delays provided by the software are not very precise. The other method is to use Timers. Timers provide time delays that are very precise and accurate microcontroller has two Timers designated as Timer0 and Timer1. Each of these timers is assigned a 16-bit register. The value of a Timer register increases by one every time a timer counts. Timer takes a time period of one machine cycle to count one. (Machine cycle is a unit that refers to the time required by the microcontroller to execute instructions.) This means that the maximum number of times a timer can count without repeating is 2 16, i.e., So the maximum allowed counts in value of Timer registers can be from 0000H to FFFFH. Since 8051 is an 8 bit controller, the registers of 8051 Timers are accessed as two different registers; one for lower byte and other for higher byte. For example, register of Timer0 is accessed as TL0 for lower byte and TH0 for higher byte.similarly TL1 and TH1 are registers assigned to Timer 1.

10 Mod-3: Interrupts,Timer operation,serial communication 10 Timer/counter control logic: If we want to timer as a timer, it will count the on chip clock frequency of 8051 oscillator divided by 12. e.g if the crystal frequency is 6.0 megahertz, then we will gate timer clock frequency of 500 kilohertz. The resultant timer clock is gated to the timer by means of the circuit shown in Figure. In order to oscillator clock pulses to reach the timer we have to clear the C/T bit in the TMOD register. We must set Bit TRX in the TCON register to '1' to run the timer run, and we should clear Gate bit in the TMOD register, or external pin (INTX) must be a 1. In short, the timer is configured as a timer, then the timer pulses are gated to the timer by the run bit and the gate bit or the external input bits (INTX). Timer operation While using 8051 Timers certain factors need to be considered, like whether the Timer is to be used for time keeping or for counting; whether the source for time generation is external clock or the controller itself; how many bits of Timer register are to be used or left unused. The registers of Timers are loaded with some initial value. The value of a Timer register increases by one after every machine cycle. One machine cycle duration is the 1/12th of the frequency of the crystal attached to the controller. For example, if the frequency of the crystal is 12 MHz, then the frequency for Timer will be 1MHz (1/12 of crystal frequency) and hence the time (T = 1/f) taken by the Timer to count by one is 1μs (1/1MHz). Similarly if an MHz crystal is used, operating frequency of Timer is KHz and the time period is μs. If no value is loaded into the Timer, it starts counting from 0000H. When the Timer reaches FFFFH, it reloads to 0000H. This roll over is communicated to the controller by raising a flag corresponding to that Timer, i.e., a flag bit is raised (set high) when the timer starts

11 Mod-3: Interrupts,Timer operation,serial communication 11 counting from 0000H again. TF0 and TF1 are the Timer flags corresponding to Timers 0 and 1. These flags must be cleared (set low) by software every time they are raised. The Timer may terminate updating register values after a roll over or continue with its operation. Starting or stopping a Timer For every Timer, there is a corresponding Timer control bit which can be set or cleared by the program to start or stop the Timer. TR0 and TR1 are the control bits for Timers 0 and 1 respectively. Setting the control bit would start the Timer. TR0 = 1; starts Timer 0 TR1 = 1; starts Timer 1 Clearing the control bit would stop the Timer. TR0 = 0; stops Timer 0 TR1 = 0; stops Timer1 Designing a delay program using 8051 timers. Time Delay = No. of counts X one clock duration of timer

12 Mod-3: Interrupts,Timer operation,serial communication 12 While designing delay programs in 8051, calculating the initial value that has to be loaded in to TH and TL registers forms a very important thing. Let us see how it is done. Assume the processor is clocked by a 12MHz crystal. That means, the timer clock input will be 12MHz/12 = 1MHz That means, the time taken for the timer to make one increment = 1/1MHz = 1 S Devide the desired time delay by 1 S. 2^16 = is the maximim number of counts possible for a 16 bit timer. Perform 65,536-n, where n is the no. of counts. Then, THTL = Hexadecimal equivalent of (65536-n) where (65536-n) is considered in decimal. Example. Let the required delay be 1000 S (ie; 1mS). That means n = 1000 (1000 S/1 S) n = = is considered in decimal and converting it to hexadecimal gives FC18 That means THTL = FC18 Therefore TH=FC and TL=18 Program for generating 1mS delay using 8051 timer. The program shown below can be used for generating 1mS delay and it is written as a subroutine so that you can call it anywhere in the program. Also you can put this in a loop for creating longer time delays (multiples of 1mS). Here Timer 0 of 8051 is used and it is operating in MODE1 (16 bit timer). DELAY: MOV TMOD,# B // Sets Timer 0 to MODE1 (16 bit timer). Timer 1 is not used MOV TH0,#0FCH // Loads TH0 register with FCH MOV TL0,#018H // Loads TL0 register with 18H SETB TR0 // Starts the Timer 0 HERE: JNB TF0,HERE // Loops here until TF0 is set (ie;until roll over) CLR TR0 // Stops Timer 0 CLR TF0 // Clears TF0 flag RET Different modes of a Timer There are four Timer modes designated as Modes 0, 1, 2 and 3. A particular mode is selected by configuring the M1 & M0 bits of TMOD register.

13 Mod-3: Interrupts,Timer operation,serial communication bit Time Mode (mode 0) Mode 0 is a 13 bit Timer mode and uses 8 bits of high byte and 5 bit prescaler of low byte. The value that the Timer can update in mode0 is from 0000H to 1FFFH. The 5 bits of lower byte append with the bits of higher byte. The Timer rolls over from 1FFFH to 0000H to raise the Timer flag. When the timer is in 13-bit mode, TLx will count from 0 to 31. When TLx is incremented from 31, it will "reset" to 0 and increment THx. Thus, effectively, only 13 bits of the two timer bytes are being used: bits 0-4 of TLx and bits 0-7 of THx. 16-bit Time Mode (mode 1) Mode1 is one of the most commonly used Timer modes. It allows all 16 bits to be used for the Timer and so it allows values to vary from 0000H to FFFFH. TLx is incremented from 0 to 255. When TLx is incremented from 255, it resets to 0 and causes THx to be incremented by 1. Since this is a full 16-bit timer, the timer may contain up to distinct values. If you set a 16-bit timer to 0, it will overflow back to 0 after 65,536 machine cycles. Mode 1 Programming: The following are the characteristics and operations of mode 1: 1. It is a 16-bit timer; therefore, it allows value of 0000 to FFFFH to be loaded into the timer s register TL and TH.

14 Mod-3: Interrupts,Timer operation,serial communication After TH and TL are loaded with a 16-bit initial value, the timer must be started. This is done by SETB TR0 for timer 0 and SETB TR1 for timer After the timer is started, it starts to count up. It counts up until it reaches its limit of FFFFH. When it rolls over from FFFFH to 0000, it sets high a flag bit called TF (timer flag). Each timer has its own timer flag: TF0 for timer 0 and TF1 for timer 1. This timer flag can be monitored. When this timer flag is raised, one option would be to stop the timer with the instructions CLR TR0 or CLR TR1, for timer 0 and timer 1, respectively. 4. After the timer reaches its limit and rolls over, in order to repeat the process. TH and TL must be reloaded with the original value, and TF must be reloaded to 0. Steps to program in mode 1: To generate a time delay, using timer in mode 1, following are the steps: 1. Load the TMOD value register indicating which timer (timer 0 or timer 1) is to be used and which timer mode (0 or 1) is selected. 2. Load registers TL and TH with initial count value. 3. Start the timer. 4. Keep monitoring the timer flag (TF) with the JNB TFx, target instruction to see if it is raised. Get out of the loop when TF becomes high. 5. Stop the timer. 6. Clear the TF flag for the next round. 7. Go back to Step 2 to load TH and TL again. Programming Examples : 1. Assume that XTAL = MHz. What value do we need to load the timer s register if we want to have a time delay of 5 ms? Show the program for timer 0 to create a pulse width of 5 ms on P2.3. Solution: Since XTAL = MHz, the counter counts up every us. This means that out of many us intervals we must make a 5 ms pulse. To get that, we divide one by the other. We need 5 ms / 1.085μs = 4608 clocks. To Achieve that we need to load into TL and TH the value = EE00H. Therefore, we have TH = EE and TL = 00. Program: CLR P2.3 ;Clear P2.3 MOV TMOD,#01H HERE: MOV TL0,#00H MOV TH0,#0EEH SETB P2.3 ;SET high P2.3 ;Timer 0, 16-bitmode ;TL0=0, the low byte ;TH0=EE, the high byte

15 Mod-3: Interrupts,Timer operation,serial communication 15 SETB TR0 ;Start timer 0 AGAIN: JNB TF0,AGAIN ;Monitor timer flag 0 CLR TR0 ;Stop the timer 0 CLR TF0 ;Clear timer 0 flag 3. Assume that XTAL = MHz, write a program to generate a square wave of 2 khz frequency on pin P1.5. Solution: Look at the following steps. (a) T = 1 / f = 1 / 2 khz = 500 us the period of square wave. (b) 1 / 2 of it for the high and low portion of the pulse is 250 us. (c) 250 us / us = 230 and = which in hex is FF1AH. (d) TL = 1A and TH = FF, all in hex. Program MOV TMOD,#01 ;Timer 0, 16-bitmode AGAIN: MOV TL1,#1AH ;TL1=1A, low byte of timer MOV TH1,#0FFH ;TH1=FF, the high byte SETB TR0 ;Start timer 1 BACK: JNB TF0,BACK ;until timer rolls over CLR TR0 ;Stop the timer 1 CPL P1.5 ; Comp. p1.5 to get high and low CLR TF0 ;Clear timer 1 flag SJMP AGAIN ;Reload timer 4. Write a sub routine to create a time delay of 20 ms by assuming an oscillator running at 12 MHZ controls an Intel 8051 micro controller. Solution: Look at the following steps. (a) If C/T =0, then clock source to the timer 1 = osc freq/12 = 12 MHZ/12 = 1 MHZ (b)for 20 ms delay the Timer register (TH1, TL1) value = 1/1us * 20 ms = 20,000 (c)timer register (TH1 &TL1) value =65,536-20,000=45,536(d) =B1E0 (H) (d)configure timer 1 to operate in mode 1 and choose the oscillator /12 as clock i/p. C/T=0, GATE =0, TF1=0 (e)place value B1E0h into the timer 1 register and wait until the overflow flag is set to 1 Subroutine: DELAY: MOV TMOD, #10H //MODE 1, 16BIT TIMER CLR TF1 // CLEAR TIMER 1 OVERFLOW FLAG

16 Mod-3: Interrupts,Timer operation,serial communication 16 CLR ET1 //CLEAR TIMER 1 INTERRUPT FLAG LCALL DELAY: MOV TH1, #B1H // STORE UPPER BYTE OF COUNT MOV TL1, #E0H // STORE LOWER BYTE OF COUNT SETB TR1 // ENABLE TIMER 1 WAIT: JNB TF1, WAIT // 8-bit Time Mode (mode 2) Timer mode "2" is an 8-bit auto-reload mode. What is that, you may ask? Simple. When a timer is in mode 2, THx holds the "reload value" and TLx is the timer itself. Thus, TLx starts counting up. When TLx reaches 255 and is subsequently incremented, instead of resetting to 0 (as in the case of modes 0 and 1), it will be reset to the value stored in THx. For example, let us say TH0 holds the value FDh and TL0 holds the value FEh. If we were to watch the values of TH0 and TL0 for a few machine cycles this is what we see: As you can see, the value of TH0 never changed. In fact, when you use mode 2 you almost always set THx to a known value and TLx is the SFR that is constantly incremented. The following are the characteristics and operations of mode 2: 1. It is an 8-bit timer; therefore, it allows only values of 00 to FFH to be loaded into the timer s register TH 2. After TH is loaded with the 8-bit value, the 8051 gives a copy of it to TL Then the timer must be started This is done by the instruction SETB TR0 for timer 0 and SETB TR1 for timer 1 3. After the timer is started, it starts to count up by incrementing the TL register

17 Mod-3: Interrupts,Timer operation,serial communication 17 It counts up until it reaches its limit of FFH When it rolls over from FFH to 00, it sets high the TF (timer flag) 4. When the TL register rolls from FFH to 0 and TF is set to 1, TL is reloaded automatically with the original value kept by the TH register To repeat the process, we must simply clear TF and let it go without any need by the programmer to reload the original value This makes mode 2 an auto-reload, in contrast with mode 1 in which the programmer has to reload TH and TL. Steps to program in mode 2: To generate a time delay 1. Load the TMOD value register indicating which timer (timer 0 or timer 1) is to be used, and the timer mode (mode 2) is selected. 2. Load the TH registers with the initial count value. 3. Start timer. 4. Keep monitoring the timer flag (TF) with the JNB TFx, target instruction to see whether it is raised. Get out of the loop when TF goes high. 5. Clear the TF flag and 6. Go back to Step 4, since mode 2 is auto reload. Programming examples : 1. Assume XTAL = MHz, find the frequency of the square wave generated on pin P1.0 in the following program. Program: Solution: MOV TMOD, #20H ; T1/8-bit/auto reload MOV TH1, #5 ; TH1 = 5 SETB TR1 ; start the timer 1 BACK: JNB TF1, BACK ; till timer rolls over CPL P1.0 ; P1.0 to high, low CLR TF1 ; clear Timer 1 flag SJMP BACK ; mode 2 is auto-reload First notice the target address of SJMP. In mode 2 we do not need to reload TH since it is autoreload. Now (256-05) us = us = us 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 = us = us and the frequency = khz. 2. Assuming that clock pulses are fed into pin T1, write a program for counter 1 in mode 2 to count the pulses and display the state of TL1, count on P2, which connects to 8 LEDs.

18 Mod-3: Interrupts,Timer operation,serial communication 18 AGAIN: BACK: MOV TMOD,#60H ;counter1,mode2 MOV TH1,#00H SETB P3.5 ;make T1 input SETB TR1 MOV A, TL1 MOV P2,A JNB TF1,BACK CLR TR1 CLR TF1 SJMP AGAIN 3. Generate a square wave of 2 KHz on P1.2 using Timer 1 in mode 2.Assume XTAL=12MHz. Look at the following steps. (a) T = 1 / f = 1 / 2 khz = 500 us the period of square wave. (b) 1 / 2 of it for the high and low portion of the pulse is 250 us. (c) 250 us / 1 us = 250 and = 6 d which in hex is 06H. (d) TH = 06H. Program MOVE TMOD,#20H MOV TH1,#06H SETB TR1 BACK: JNB TF1,BACK CLR TR1 CLR TF1 SJMP BACK 4. Assuming that clock pulses are fed in to the pin T1,write a program for counter 1 in mode 2 to count the pulses and display the state of TL1 count on P2 which connects to 8 LEDs. Solution: Here we set a counter to count the pulses from T1 Program MOV TMOD,#60H ;Counter 1 mode 2 MOV TH1,#00H SETB P3.5 ;Make T1 as input pin AGAIN: SETB TR1 BACK: MOV A,TL1 MOV P2,A JNB TF1,BACK

19 Mod-3: Interrupts,Timer operation,serial communication 19 CLR TR1 CLR TF1 SJMP AGAIN Split Timer Mode (mode 3) Timer mode "3" is a split-timer mode. When Timer 0 is placed in mode 3, it essentially becomes two separate 8-bit timers. That is to say, Timer 0 is TL0 and Timer 1 is TH0. Both timers count from 0 to 255 and overflow back to 0. All the bits that are related to Timer 1 will now be tied to TH0.

20 Mod-3: Interrupts,Timer operation,serial communication 20 Note: Timers of 8051 do starting and stopping by either software or hardware control. In using software to start and stop the timer where GATE=0. The start and stop of the timer are controlled by way of software by the TR (timer start) bits TR0 and TR1. The SETB instruction starts it, and it is stopped by the CLR instruction. These instructions start and stop the timers as long as GATE=0 in the TMOD register. The hardware way of starting and stopping the timer by an external source is achieved by making GATE=1 in the TMOD register Serial Communication One of the 8051 s many powerful features is it s integrated UART, otherwise known as a serial port. The fact that the 8051 has an integrated serial port means that you may very easily read and write values to the serial port. If it were not for the integrated serial port, writing a byte to a serial line would be a rather tedious process requiring turning on and off one of the I/O lines in rapid succession to properly "clock out" each individual bit, including start bits, stop bits, and parity bits. The 8051 includes a hardware UART to support serial asynchronous communications so that, typically, the product can support RS-232 standard communication. The (Universal

21 Mod-3: Interrupts,Timer operation,serial communication 21 Asynchronous Reveiver and Transmitter) block diagram is shown in figure. In our examples the BAUD clocks are, in fact, a single clock source provided by Timer/Counter 1. Fig: UART Block Diagram The UART can be configured for 9-bit data transmission and reception. Here 8 bits represent the data byte (or character) and the ninth bit is the parity bit. The Following figure shows a block diagram for the UART transmitter, where the ninth bit is used as the parity bit. Fig: block Diagram of UART Receiver using 9 th bit

22 Mod-3: Interrupts,Timer operation,serial communication 22 SBUF is an SFR register which can be written to, so as to hold the next data byte to be transmitted. Also it can be read from to get the latest data byte received by the serial port. SBUF is thus effectively two registers: one for transmitting and one for receiving. The SCON (Serial Control) register is an SFR register, used for configuring and monitoring the serial port status. This lets us tell the 8051 how many data bits we want, the baud rate we will be using, and how the baud rate will be determined. First, let s present the "Serial Control" (SCON) SFR and define what each bit of the SFR represents: Bit Name Bit Addres Explanation of Function 7 SM0 9Fh Serial port mode bit 0 6 SM1 9Eh Serial port mode bit 1. 5 SM2 9Dh Mutliprocessor Communications Enable (explained later) 4 REN 9Ch Receiver Enable. This bit must be set in order to receive characters. 3 TB8 9Bh Transmit bit 8. The 9th bit to transmit in mode 2 and 3. 2 RB8 9Ah Receive bit 8. The 9th bit received in mode 2 and 3. 1 TI 99h Transmit Flag. Set when a byte has been completely transmitted. 0 RI 98h Receive Flag. Set when a byte has been completely received. Additionally, it is necessary to define the function of SM0 and SM1 by an additional table: SM0 SM1 Serial Mode Explanation Baud Rate bit Shift Register Oscillator / bit UART Set by Timer 1 (*) bit UART Oscillator / 64 (*) bit UART Set by Timer 1 (*) (*) Note: The baud rate indicated in this table is doubled if PCON.7 (SMOD) is set. 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, also known as multiprocessor communication enable bit. When set, it enables multiprocessor communication in mode 2 and 3, and eventually mode 1. It should be cleared in mode 0.

23 Mod-3: Interrupts,Timer operation,serial communication 23 REN - Reception Enable bit enables serial reception when set. When cleared, serial reception is disabled. TB8 - Transmitter bit 8. Since all registers are 8-bit wide, this bit solves the problem of transmiting the 9th bit in modes 2 and 3. It is set to transmit a logic 1 in the 9th bit. RB8 - Receiver bit 8 or the 9th bit received in modes 2 and 3. Cleared by hardware if 9th bit received is a logic 0. Set by hardware if 9th bit received is a logic 1. TI - Transmit Interrupt flag is automatically set at the moment the last bit of one byte is sent. It's a signal to the processor that the line is available for a new byte transmite. It must be cleared from within the software. RI - Receive Interrupt flag is automatically set upon one byte receive. It signals that byte is received and should be read quickly prior to being replaced by a new data. This bit is also cleared from within the software. Serial Communication: Different modes o Mode - 0 Shift register mode. Serial data enters and exists through RXD. 8-bits are transmitted/recieved. Pin TXD is connected to the internal shift frequency pulse source to supply shift pulses to external circuits. The shift frequency or baud rate is fixed at 1/2 of the oscillator frequency. o Mode - 1 Standard UART 10 bits are transmitted (through TXD) or recieved through (RXD), a start bit(0), 8 data bits (LSB first), and a stop bit(1). Once recieved, the stop bits goes into RB8 in special function register SCON.The baud rate is variable. o Mode - 2 Multiprocessor Mode. 11 bits are transmitted through TXD or recieved through RXD, a start bit (0), 8 data bits (LSB first), a programmable 9th bit and a stop bit(1). On transmission, the 9th data bit (TB8 in SCON)

24 Mod-3: Interrupts,Timer operation,serial communication 24 can be assigned the value 0 or 1. Or, for example, the parity bit (P in the PSN) could be moved into TB8. On receive, the 9th bit goes into RB8 in SFR SCON, which the stop bit is ignored. The bandwidth is programmable to either 1/32 or 1/64 of oscillator frequency. o Mode bits are transmitted through TXD or received through RXD: a start bit, 8 data bits (LSB first), a programmable 9th bit, and a stop bit (1). In fact, Mode 3 is same as Mode 2 in all respects except the baud rate. The baud rate in Mode 3 is variable. The SCON SFR allows us to configure the Serial Port. Thus, well go through each bit and review its function. The first four bits (bits 4 through 7) are configuration bits. Baud rate in the 8051 The 8051 transfers and receives data serially at many different baud rates. The baud rate in the 8051 is programmable. This is done with the help of Timer 1. Before we discuss how to do that, we will look at the relationship between the crystal frequency and the baud rate in the As discussed in earlier, the 8051 divides the crystal frequency by 12 to get the machine cycle frequency. In the case of XTAL = MHz, the machine cycle frequency is khz ( MHz / 12 = khz). The 8051 s serial communication UART circuitry divides the machine cycle frequency of khz by 32 once more before it is used by Timer 1 to set the baud rate. Therefore, khz divided by 32 gives 28,800 Hz. When Timer 1 is used to set the baud rate it must be programmed in mode 2,that is 8-bit, auto-reload. The data rate is generated by timer-1 using the following formula. Where, SMOD is the 7th bit of PCON register fosc is the crystal oscillator frequency of the microcontroller It can be noted that fosc/ (12 X [256- (TH1)]) is the timer overflow frequency in timer mode-2, which is the auto-reload mode. If timer-1 is not run in mode-2, then the baud rate is,

25 Mod-3: Interrupts,Timer operation,serial communication 25 Timer-1 can be run using the internal clock, fosc/12 (timer mode) or from any external source via pin T1 (P3.5) (Counter mode). Example: If standard baud rate is desired, then MHz crystal could be selected. To get a standard 9600 baud rate, the setting of TH1 is calculated as follows. Assuming SMOD to be 0' or or In mode-1, if SM2 is set to 1, no receive interrupt (RI) is generated unless a valid stop bit is received. To get baud rates compatible with the PC, we must load TH1 with the values shown in Table. SBUF register SBUF is an 8-bit register used solely for serial communication in the For a byte of data to be transferred via the TxD line, it must be placed in the SBUF register. Similarly, SBUF holds the byte of data when it is received by the 8051 s RxD line. SBUF can be accessed like any other register in the Look at the following examples of how this register is accessed: The moment a byte is written into SBUF, it is framed with the start and stop bits and transferred serially via the TxD pin. Similarly, when the bits are received serially via RxD, the 8051 deframes it by eliminating the stop and start bits, making a byte out of the data received, and then placing it in the SBUF.

26 Mod-3: Interrupts,Timer operation,serial communication 26 Writing to the Serial Port Once the Serial Port has been properly configured as explained above, the serial port is ready to be used to send data and receive data. If you thought that configuring the serial port was simple, using the serial port will be a breeze. To write a byte to the serial port one must simply write the value to the SBUF (99h) SFR. For example, if you wanted to send the letter "A" to the serial port, it could be accomplished as easily as: MOV SBUF,#A Upon execution of the above instruction the 8051 will begin transmitting the character via the serial port. Obviously transmission is not instantaneous--it takes a measureable amount of time to transmit. And since the 8051 does not have a serial output buffer we need to be sure that a character is completely transmitted before we try to transmit the next character. The 8051 lets us know when it is done transmitting a character by setting the TI bit in SCON. When this bit is set we know that the last character has been transmitted and that we may send the next character, if any. Consider the following code segment: CLR TI ; Be sure the bit is initially clear MOV SBUF,#A ;Send the letter A to the serial port JNB TI,$ ;Pause until the TI bit is set. The above three instructions will successfully transmit a character and wait for the TI bit to be set before continuing. The last instruction says "Jump if the TI bit is not set to $"--$, in most assemblers, means "the same address of the current instruction." Thus the 8051 will pause on the JNB instruction until the TI bit is set by the 8051 upon successful transmission of the character. Reading the Serial Port Reading data received by the serial port is equally easy. To read a byte from the serial port one just needs to read the value stored in the SBUF (99h) SFR after the 8051 has automatically set the RI flag in SCON. For example, if your program wants to wait for a character to be received and subsequently read it into the Accumulator, the following code segment may be used: JNB RI,$ ;Wait for the 8051 to set the RI flag MOV A,SBUF ;Read the character from the serial port The first line of the above code segment waits for the 8051 to set the RI flag; again, the 8051 sets the RI flag automatically when it receives a character via the serial port. So as long as the bit is not set the program repeats the "JNB" instruction continuously. Once the RI bit is set upon character reception the above condition automatically fails and program flow falls through to the "MOV" instruction which reads the value.

27 Mod-3: Interrupts,Timer operation,serial communication 27 Programming the 8051 to transfer data serially In programming the 8051 to transfer character bytes serially, the following steps must be taken. 1. The TMOD register is loaded with the value 20H, indicating the use of Timer 1 in mode 2 (8- bit auto-reload) to set the baud rate. 2. The TH1 is loaded with one of the values in Table to set the baud rate for serial data transfer (assuming XTAL = MHz). 3. The SCON register is loaded with the value 50H, indicating serial mode 1, where an 8-bit data is framed with start and stop bits. 1. TR1 is set to 1 to start Timer TI is cleared by the CLR TI instruction. 3. The character byte to be transferred serially is written into the SBUF register. a. The TI flag bit is monitored with the use of the instruction JNB TI, xx to see if the character has been transferred completely. 4. To transfer the next character, go to Step 5. Write a program to transfer the message YES serially at 9600 baud, 8-bit data, 1 stop bit. Do this continuously.

28 Mod-3: Interrupts,Timer operation,serial communication 28 Write a program to continually transmit the character A out the serial port. ORG 0H MOV SCON, #40H ;serial port mode 1 ;configure timer 1 in auto-reload mode for 9600 baud MOV TMOD, #20H ;timer mode 2 MOV TH1, #0FDH ;reload value for 9600 baud MOV TL1, #0FDH SETB TR1 ;start timer LOOP: MOV SBUF, #'A' ;transmit character WAIT4TI: JNB TI, WAIT4TI ;wait for end of transmission CLR TI JMP LOOP ;re-transmit END Importance of the Tl flag To understand the importance of the role of TI, look at the following sequence of steps that the 8051 goes through in transmitting a character via TxD. 1. The byte character to be transmitted is written into the SBUF register. 2. The start bit is transferred. 3. The 8-bit character is transferred one bit at a time.

29 Mod-3: Interrupts,Timer operation,serial communication 29 a. The stop bit is transferred. It is during the transfer of the stop bit that the 8051 raises the TI flag (TI =1), indicating that the last character was transmitted and it is ready to transfer the next character. b. By monitoring the TI flag, we make sure that we are not overloading the SBUF register.if we write another byte into the SBUF register before TI is raised, the untransmitted portion of the previous byte will be lost. In other words, when the 8051 finishes transferring a byte, it raises the TI flag to indicate it is ready for the next character. 4. After SBUF is loaded with a new byte, the TI flag bit must be forced to 0 by the CLR TI instruction in order for this new byte to be transferred. From the above discussion we conclude that by checking the TI flag bit, we know whether or not the 8051 is ready to transfer another byte. More importantly, it must be noted that the TI flag bit is raised by the 8051 itself when it finishes the transfer of data, whereas it must be cleared by the programmer with an instruction such as CLR TI. It also must be noted that if we write a byte into SBUF before the TI flag bit is raised, we risk the loss of a portion of the byte being transferred. The TI flag bit can be checked by the instruction JNB TI,... or we can use an interrupt. Programming the 8051 to receive data serially In the programming of the 8051 to receive character bytes serially, the following steps must be taken. 1. The TMOD register is loaded with the value 20H, indicating the use of Timer 1 in mode 2 (8-bit auto-reload) to set the baud rate. 2. TH1 is loaded with one of the values in Table 10-4 to set the baud rate (assum ing XTAL = MHz). 3. The SCON register is loaded with the value 50H, indicating serial mode 1, where 8-bit data is framed with start and stop bits and receive enable is turned on. 4. TR1 is set to 1 to start Timer RI is cleared with the CLR RI instruction. a. The RI flag bit is monitored with the use of the instruction JNB RI, xx to see if an entire character has been received yet. 6. When RI is raised, SBUF has the byte. Its contents are moved into a safe place. 7. To receive the next character, go to Step 5. Program the 8051 to receive bytes of data serially, and put them in PI. Set the baud rate at 4800, 8-bit data, and 1 stop bit.

30 Mod-3: Interrupts,Timer operation,serial communication 30 Importance of the Rl flag bit In receiving bits via its RxD pin, the 8051 goes through the following steps. 1. It receives the start bit indicating that the next bit is the first bit of the character byte it is about to receive. 2. The 8-bit character is received one bit at time. When the last bit is received, a byte is formed and placed in SBUF. 3. The stop bit is received. When receiving the stop bit the 8051 makes RI = 1, indicating that an entire character byte has been received and must be picked up before it gets overwritten by an incoming character. 4. By checking the RI flag bit when it is raised, we know that a character has been received and is sitting in the SBUF register. We copy the SBUF contents to a safe place in some other register or memory before it is lost. 5. After the SBUF contents are copied into a safe place, the RI flag bit must be forced to 0 by the CLR RI instruction in order to allow the next received character byte to be placed in SBUF. Failure to do this causes loss of the received character. From the above discussion we conclude that by checking the RI flag bit we know whether or not the 8051 has received a character byte. If we fail to copy SBUF into a safe place, we risk the loss of the received byte. More importantly, it must be noted that the RI flag bit is raised by the 8051, but it must be cleared by the programmer with an instruction such as CLR RI. It also must be noted that if we copy SBUF into a safe place before the RI flag bit is raised, we risk copying garbage. The RI flag bit can be checked by the instruction JNB RI, xx or by using an interrupt. 1. Write a program in which the 8051 reads data from P1 and writes it to P2 continuously while giving a copy of it to the serial COM port to be transferred serially. Assume that XTAL= Set the baud rate at 9600.

31 Mod-3: Interrupts,Timer operation,serial communication 31 Solution: ORG 0 LJMP MAIN ; main program, initialization MAIN: MOV P1,#OFFH ;make P1 an input port MOV TMOD,#20H ;timer 1,mode 2 (auto reload) MOV TH1,#OFDH ;9600 baud rate MOV SCON,#50H ;8-bit, 1 stop, REN enabled SETB TR1 ;start timer 1 BACK: MOV A,P1 MOV P2,A MOV SBUF,A ;A has a copy of data HERE: JNB TI,HERE ;jump if TI is high CLR TI SJMP BACK END 2. Write a program in which the 8051 gets data from P1 and sends it to P2 continuously while incoming data from the serial port is sent to P0. Assume that XTAL = Set the baud rate at Solution ORG 00H ; main program, initialization MAIN: MOV P1,#0FFH ;make P1 an input port MOV TMOD,#20H ;timer 1, mode 2 (auto reload) MOV TH1,#OFDH ;9600 baud rate MOV SCON,#50H ;8-bit,1 stop, REN enabled SETB TR1 ;start timer 1 BACK: MOV A,P1 MOV P2,A HERE: JNB RI,HERE MOV A,SBUF MOV P0,A CLR RI SJMP BACK END

32 Mod-3: Interrupts,Timer operation,serial communication 32 REVIEW QUESTIONS 1. Explain the different serial communication modes in Explain the function and operating modes of timer in Explain the interrupt structure of 8051 microcontroller Explain how interrupts are prioritized.

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

اصول ميکروکامپيوترها استاد درس: دکتر http://ee.iust.ac.ir/rahmati/index.htm rahmati@iust.ac.ir ا درس Email و Website برای تکاليف و... : http://eel.iust.ac.ir/rahmati/ ١ هجدهم فصل ا شنايی با تايمرهای 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

MCS-51 Serial Port A T 8 9 C 5 2 1

MCS-51 Serial Port A T 8 9 C 5 2 1 MCS-51 Serial Port AT89C52 1 Introduction to Serial Communications Serial vs. Parallel transfer of data Simplex, Duplex and half-duplex modes Synchronous, Asynchronous UART Universal Asynchronous Receiver/Transmitter.

More information

The 8051 microcontroller has two 16-bit timers/counters called T0 and T1.

The 8051 microcontroller has two 16-bit timers/counters called T0 and T1. Counters and Timers: The 8051 microcontroller has two 16-bit timers/counters called T0 and T1. As their names suggest, timer counts internal clock pulse i.e. machine cycle to provide delay. Counter counts

More information

INTERRUPTS PROGRAMMING

INTERRUPTS PROGRAMMING INTERRUPTS PROGRAMMING 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

CoE3DJ4 Digital Systems Design. Chapter 5: Serial Port Operation

CoE3DJ4 Digital Systems Design. Chapter 5: Serial Port Operation CoE3DJ4 Digital Systems Design Chapter 5: Serial Port Operation Serial port 8051 includes an on-chip serial port Hardware access to the port is through TXD and RXD (Port 3 bits 1 and 0) Serial port is

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

8051 Timers and Serial Port

8051 Timers and Serial Port 8051 Timers and Serial Port EE4380 Fall 2001 Class 10 Pari vallal Kannan Center for Integrated Circuits and Systems University of Texas at Dallas Timer: Mode 1 Operation (recap) 16 bit counter. Load the

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

Serial I-O for Dinesh K. Sharma Electrical Engineering Department I.I.T. Bombay Mumbai (version 14/10/07)

Serial I-O for Dinesh K. Sharma Electrical Engineering Department I.I.T. Bombay Mumbai (version 14/10/07) Serial I-O for 8051 Dinesh K. Sharma Electrical Engineering Department I.I.T. Bombay Mumbai 400 076 (version 14/10/07) 1 Motivation Serial communications means sending data a single bit at a time. But

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

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

Department of EIE / Pondicherry Engineering College. Timer/Counters. Department of EIE / Pondicherry Engineering College 1

Department of EIE / Pondicherry Engineering College. Timer/Counters. Department of EIE / Pondicherry Engineering College 1 Timer/Counters Department of EIE / Pondicherry Engineering College 1 The 8051 has two internal sixteen bit hardware Timer/Counters. Each Timer/Counter can be configured in various modes, typically based

More information

e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: Serial Port Programming in Assembly Module No: CS/ES/12 Quadrant 1 e-text

e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: Serial Port Programming in Assembly Module No: CS/ES/12 Quadrant 1 e-text e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: Serial Port Programming in Assembly Module No: CS/ES/12 Quadrant 1 e-text In this lecture, serial communication control register

More information

8051 Serial Communication

8051 Serial Communication 8051 Serial Communication Basics of serial communication Parallel: transfers eight bits of data simultaneously over eight data lines expensive - short distance fast Serial : one bit at a time is transferred

More information

Chapter 6 Interrupts. (I. Scott Mackenzie) By: Masud-ul-Hasan

Chapter 6 Interrupts. (I. Scott Mackenzie) By: Masud-ul-Hasan Chapter 6 Interrupts (I. Scott Mackenzie) 1 Interrupts An interrupt is the occurrence of an event that causes a temporary suspension of a program while the condition is serviced by another program. It

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

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

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

CHAPTER TIMER PROGRAMMING

CHAPTER TIMER PROGRAMMING CHAPTER 9 8051 TIMER PROGRAMMING 8051 Timers The 8051 has two timers/counters, they can be used as Timers to generate a time delay Event counters to count events happening outside the microcontroller Both

More information

CHAPTER 11 INTERRUPTS PROGRAMMING

CHAPTER 11 INTERRUPTS PROGRAMMING CHAPTER 11 INTERRUPTS PROGRAMMING Interrupts vs. Polling An interrupt is an external or internal event that interrupts the microcontroller To inform it that a device needs its service A single microcontroller

More information

CoE3DJ4 Digital Systems Design. Chapter 6: Interrupts

CoE3DJ4 Digital Systems Design. Chapter 6: Interrupts CoE3DJ4 Digital Systems Design Chapter 6: Interrupts Interrupts An interrupt is the occurrence of an event that causes a temporary suspension of a program while the condition is serviced by another program.

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

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

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

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

e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: Interrupt Handling Module No: CS/ES/13 Quadrant 1 e-text

e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: Interrupt Handling Module No: CS/ES/13 Quadrant 1 e-text e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: Interrupt Handling Module No: CS/ES/13 Quadrant 1 e-text 1. Interrupt An interrupt is the occurrence of a condition--an event --

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

8051SERIAL PORT PROGRAMMING

8051SERIAL PORT PROGRAMMING 8051SERIAL PORT PROGRAMMING Basics of Serial Communication Computers transfer data in two ways: Parallel Often 8 or more lines (wire conductors) are used to transfer data to a device that is only a few

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

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

Timers and interrupts

Timers and interrupts Timers and interrupts CSCI 255: Introduction to Embedded Systems Keith Vertanen Copyright 2011 Timers Overview Creating fixed pauses Calculate length of events Counts events Generate baud rate for serial

More information

Timer-1 can be run using the internal clock, fosc/12 (timer mode) or from any external source via pin T1 (P3.5) (Counter mode).

Timer-1 can be run using the internal clock, fosc/12 (timer mode) or from any external source via pin T1 (P3.5) (Counter mode). EC 6504 MICROPROCESSOR AND MICROCONTROLLER Electronics and Communication Engineering Fifth Semester UNIT-V Part A 1. List the modes of Timer in 8051. [N/D16] The timers available in 8051 are Timer 0 (T0)

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

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

8051 Serial Port. EE4380 Fall02 Class 10. Pari vallal Kannan. Center for Integrated Circuits and Systems University of Texas at Dallas

8051 Serial Port. EE4380 Fall02 Class 10. Pari vallal Kannan. Center for Integrated Circuits and Systems University of Texas at Dallas 8051 Serial Port EE4380 Fall02 Class 10 Pari vallal Kannan Center for Integrated Circuits and Systems University of Texas at Dallas Serial Comm. - Introduction Serial Vs Parallel Transfer of data Simplex,

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

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

ELEG3923 Microprocessor Ch.10 Serial Port Programming

ELEG3923 Microprocessor Ch.10 Serial Port Programming Department of Electrical Engineering University of Arkansas ELEG3923 Microprocessor Ch.10 Serial Port Programming Dr. Jingxian Wu wuj@uark.edu OUTLINE 2 Basics of Serial Communication Serial port programming

More information

Chapter 09. Programming in Assembly

Chapter 09. Programming in Assembly Chapter 09 Programming in Assembly Lesson 05 Programming Examples for Timers Programming TMOD Register 3 Write instructions to run T0 in Mode 0, external count inputs, internal start/stop control ANL TMOD,

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

e-pg Pathshala Subject: Computer Science Paper: Embedded System Module: Interrupt Programming in Embedded C Module No: CS/ES/20 Quadrant 1 e-text

e-pg Pathshala Subject: Computer Science Paper: Embedded System Module: Interrupt Programming in Embedded C Module No: CS/ES/20 Quadrant 1 e-text e-pg Pathshala Subject: Computer Science Paper: Embedded System Module: Interrupt Programming in Embedded C Module No: CS/ES/20 Quadrant 1 e-text In this lecture embedded C program for interrupt handling

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

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

Experiment# 8: Photo-Interrupter Control

Experiment# 8: Photo-Interrupter Control Experiment# 8: Photo-Interrupter Control I. Objective 1. Study the schematic diagram of photo interrupter (PH1, and PH2) and the pulse generator circuit. 2. To demonstrate the control applications of photo-interrupter,

More information

Department of Electronics and Instrumentation Engineering Question Bank

Department of Electronics and Instrumentation Engineering Question Bank www.examquestionpaper.in Department of Electronics and Instrumentation Engineering Question Bank SUBJECT CODE / NAME: ET7102 / MICROCONTROLLER BASED SYSTEM DESIGN BRANCH : M.E. (C&I) YEAR / SEM : I / I

More information

8051 Microcontroller Interrupts

8051 Microcontroller Interrupts 8051 Microcontroller Interrupts There are five interrupt sources for the 8051, which means that they can recognize 5 different events that can interrupt regular program execution. Each interrupt can be

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

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 Peripherals. On-Chip Memory Timers Serial Port Interrupts. Computer Engineering Timers

8051 Peripherals. On-Chip Memory Timers Serial Port Interrupts. Computer Engineering Timers 8051 Peripherals On-Chip Memory Timers Serial Port Interrupts Computer Engineering 2 2-1 8051 Timers 8051 Timers The 8051 has 2 internal 16-bit timers named Timer 0 and Timer 1 Each timer is a 16-bit counter

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

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

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

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

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

Chapter C2051 Architecture and Serial Communication Link

Chapter C2051 Architecture and Serial Communication Link Chapter- 2 89C2051 Architecture and Serial Communication Link ABSTRACT This chapter provides the details of 89C2051 microcontroller and description on Serial Communication Facility presented by 89C2051

More information

Understanding the basic building blocks of a microcontroller device in general. Knows the terminologies like embedded and external memory devices,

Understanding the basic building blocks of a microcontroller device in general. Knows the terminologies like embedded and external memory devices, Understanding the basic building blocks of a microcontroller device in general. Knows the terminologies like embedded and external memory devices, CISC and RISC processors etc. Knows the architecture and

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

Q 1 a) Attempt any THREE of the following: 12 TMOD.7 TMOD.6 TMOD.5 TMOD.4 TMOD.3 TMOD.2 TMOD.1 TMOD.0 GATE C/T M1 M0 GATE C/T M1 M0

Q 1 a) Attempt any THREE of the following: 12 TMOD.7 TMOD.6 TMOD.5 TMOD.4 TMOD.3 TMOD.2 TMOD.1 TMOD.0 GATE C/T M1 M0 GATE C/T M1 M0 Page 1 of 33 Q 1 a) Attempt any THREE of the following: 12 Q 1 a i) Describe Timer modes of 8051. Ans: Timer 0 and Timer 1 can both be used as either Counters or Timers. There are 4 different operating

More information

Serial communication

Serial communication Serial communication CSCI 255: Introduction to Embedded Systems Keith Vertanen Copyright 2011 Serial communication Terminology RS-232 protocol Baud rates Flow control Example Overview Develop functions

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

Fig 1. Block diagram of a microcomputer

Fig 1. Block diagram of a microcomputer MICRO CONTROLLERS www.bookspar.com VTU NOTES QUESTION PAPERS UNIT - 1 Computer: A computer is a multipurpose programmable machine that reads binary instructions from its memory, accepts binary data as

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

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

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) Summer 2016 EXAMINATIONS.

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) Summer 2016 EXAMINATIONS. Summer 2016 EXAMINATIONS Subject Code: 17534 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 answer scheme. 2) The

More information

The Final Word on 8051 Microcontroller

The Final Word on 8051 Microcontroller The Final Word on 8051 Microcontroller This is a book about the Intel 8051 microcontroller and its large family of descendants. It is intended to give you, the reader, some new techniques for optimizing

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

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

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

8051 Interrupt Organization

8051 Interrupt Organization Interrupt Interrupts of 8051 Introduction 8051 Interrupt organization Processing Interrupts Program Design Using Interrupts Timer Interrupts Serial Port Interrupts External Interrupts Interrupt Timings

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

8-bit Microcontroller with 2/4-Kbyte Flash AT89LP2052 AT89LP4052

8-bit Microcontroller with 2/4-Kbyte Flash AT89LP2052 AT89LP4052 Features Compatible with MCS 51 Products 20 MIPS Throughput at 20 MHz Clock Frequency and 2.4V, 85 C Operating Conditions Single Clock Cycle per Byte Fetch 2/4K Bytes of In-System Programmable (ISP) Flash

More information

8051 I/O and 8051 Interrupts

8051 I/O and 8051 Interrupts 8051 I/O and 8051 Interrupts Class 7 EE4380 Fall 2002 Pari vallal Kannan Center for Integrated Circuits and Systems University of Texas at Dallas Agenda 8051 I/O Interfacing Scanned LED displays LCD displays

More information

THE 8051 MICROCONTROLLER Simple comparison: Pentium vs. 8051

THE 8051 MICROCONTROLLER Simple comparison: Pentium vs. 8051 THE 8051 MICROCONTROLLER Simple comparison: Pentium vs. 8051 FEATURE 8051 PENTIUM COMMENT Clock Speed 12Mhz. typical 1,000 MHz. (1GHz.) but 60MHz. ICs available 8051 internally divides clock by 12 so for

More information

Timer programming

Timer programming 5.8051 Timer programming In this tutorial, we are going to discuss the Timer module of 8051. First, we will see what are timers, their working and later we will configure the 8051 timers to generate the

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

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

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

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

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) WINTER 17 EXAMINATION Subject Name: Microcontroller Model Answer Subject Code: 17534 I m p o r t a n t I n s t r u c t i o n s t o e x a m i n e r s : 1) The answers should be examined by key words and

More information

UNIT 5. Microcontrollers. Syllabus

UNIT 5. Microcontrollers. Syllabus UNIT 5 Microcontrollers Syllabus Architecture of 8051 Signals Operational features Memory and I/O addressing Interrupts Instruction set Applications. OVERVIEW The past three decades have seen the introduction

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

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

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

How to use the PSoC based 16C450 Replacement

How to use the PSoC based 16C450 Replacement How to use the PSoC based 16C450 Replacement Matthew Burns Eric Ponce August 2017 (Updated April 2018) 1 Overview The PSoC based 16C450 Replacement is intended to replace the 16C450 serial communication

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

8051 MICROCONTROLLER

8051 MICROCONTROLLER What is a Microcontroller? UNIT 5 8051 MICROCONTROLLER A Microcontroller is a programmable digital processor with necessary peripherals. Both microcontrollers and microprocessors are complex sequential

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

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

INTEGRATED CIRCUITS DATA SHEET. P89C738; P89C739 8-bit microcontrollers Dec 15. Product specification File under Integrated Circuits, IC20

INTEGRATED CIRCUITS DATA SHEET. P89C738; P89C739 8-bit microcontrollers Dec 15. Product specification File under Integrated Circuits, IC20 INTEGRATED CIRCUITS DATA SHEET File under Integrated Circuits, IC20 1997 Dec 15 CONTENTS 1 FEATURES 2 GENERAL DESCRIPTION 3 ORDERING INFORMATION 4 BLOCK DIAGRAM 5 FUNCTIONAL DIAGRAM 6 PINNING INFORMATION

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

SANKALCHAND PATEL COLLEGE OF ENGINEERING, VISNAGAR. ELECTRONICS & COMMUNICATION DEPARTMENT Question Bank- 1

SANKALCHAND PATEL COLLEGE OF ENGINEERING, VISNAGAR. ELECTRONICS & COMMUNICATION DEPARTMENT Question Bank- 1 SANKALCHAND PATEL COLLEGE OF ENGINEERING, VISNAGAR ELECTRONICS & COMMUNICATION DEPARTMENT Question Bank- 1 Subject: Microcontroller and Interfacing (151001) Class: B.E.Sem V (EC-I & II) Q-1 Explain RISC

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 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

MICROPROCESSOR & MICROCONTROLLER

MICROPROCESSOR & MICROCONTROLLER a) From road north to East From road east to north From road south to west From road west to south From road west to north b) From road north to East From road south to west From road south to north From

More information

8051 Single Board Monitor Programming. Minmon - Yeralan & Ahluwalia. PaulMon1 & PaulMon2 - Paul Stoffregen

8051 Single Board Monitor Programming. Minmon - Yeralan & Ahluwalia. PaulMon1 & PaulMon2 - Paul Stoffregen 8051 Single Board Monitor Programming Monitor Program Available Monitor Program Minmon - Yeralan & Ahluwalia Programming and Interfacing the 8051 Microcontroller PaulMon1 & PaulMon2 - Paul Stoffregen http://www.pjrc.com/tech/8051

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

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