|Serial Interrupt using 8051|
This IE register is responsible for all activating all the interrupts in 8051. For serial Interrupt we need to activate EA which is enabling activating usage of interrupts and ES for activating Serial Interrupts. So the value of IE will be
IE= 1001 0000
Every Interrupt Service Routine must be inside a sub routine followed by the respective interrupt numbers. The below table will shows the interrupt numbers for respective interrupts in 8051.
|Interrupt Number table|
STEPS TO PROGRAM SERIAL INTERRUPT:
- Initiate Timer to generate Baud rate for the Serial communication, and TH1 register should be loaded with the value 0xFD to generate baud rate of 9600 bps.
- Initiate SCON register to select the mode of serial communication, i have chosen Mode 1 since i have used timer 1 for Baud rate generation.
- Load the value 0x90 into the IE register to initiate the Serial interrupt.
- Write sub routine for the interrupt with the interrupt number 4.
Usually every key you press in your hyper terminal reaches the controller as a Hex value. This will also allow you to place conditional statements inside the subroutine to make the controller to respond only to specific key press from the terminal rather than from all the keys.
The code was built using Keil C Software
All the initialization of the Timers and Interrupts took place in the main() function of the program. In the subroutine "ser_intr" i have used a condition to check received variable from interrupt as "0x0D". This "0x0D" is a equivalent of "Enter" key in the keyboard, so whenever you press enter the Microcontroller toggle the port 0 and Send ACK back to the terminal.
You can use condition for any key in the keyboard by identifying the HEX values of the respective keys in your keypad. This will help you to perform specific tasks with each key press.
Like this tutorial? Share this with others through social sites and don't forget to follow us there. Post your queries below and we get back to you as soon as we can.