Discussion in "8051 Discussion Forum" started by    kirangowle    Jan 1, 2011.
Sat Jan 01 2011, 03:16 pm
#1
Hi,

I m finding difficulty in explaining the function of interrupts in 8051, How shall i demonstrate them the use of interrupt, advantage, efficiently etc.
Do you have any ideas or programs with interrupt and with out interrupts to show how interrupt efficiently works.
Sat Jan 01 2011, 04:21 pm
#2
hi kirangowle

How shall i demonstrate them the use of interrupt, advantage, efficiently etc.


interrupt is the most important part of controller any controller without interrupt is nothing interrupt make the machine most useful
basic purpose of interrupts are multitasking
there are 6 interrupt sources in 8051
1) reset interrupt
2) external interrupt 0
3) timer 0 interrupt
4) external interrupt 1
5) timer 0 interrupt
6) serial interrupt
first interrupt is controlled by hardware software can't control it
if u connect the pin9 RST to Vcc for a while then controller will reset
other 5 interrupts are controlled by software
by default its priority is in the same way as i write above
u can changed it by using IP (Interrupt Priority) register
interrupts can be enabled by using IE(Interrupt Enable) register
let say u nned a application in which u need 7-segment multiplexing with serial communication then if u use polling method then in one time u can do one job only
but in interrupt u can do now two jobs
if u check the RI flag in serial port then u has to wait on a line while(RI==0);
but in interrupt when data come in SBUF an interrupt generate and control goes to interrupt function so we not need to check the flag and wait on a line

now let say u want 7-seg multiplexing on any port u can use timer interrupts set the timer interval and mode and run it when it overflow it raise the flag high and interrupt occur in interrupt function u can refresh ur display
if u want to count specific no of pulses using timer as a counter then u also can do that using timer interrupt too configure that as a counter just

external interrupt0 and 1 uses to check is some one press a key or not or any sensor give low output or not
lt say u make a digital clock and u want to set its time u can use push button on interrupt pin that is P3.2 and P3.3 as this pin goes low interrupt occur and there u can set ur clock time
interrupt is an emergency case it is just like an ambulance that has permission to break the laws of signals in case of emergency
controller leave the main function when any interrupt occur and go to the relevant interrupt function after that it come back to main so in this way controller can do multitasking that is useful thing when ur doing coding
in fact interrupt is the best way of coding

Do you have any ideas or programs with interrupt and with out interrupts to show how interrupt efficiently works.


let say we discuss serial interrupt only here basic idea is same for all type of interrupts
without interrupt in c
#include <reg51.h>
void main (void)
{
unsigned char a;
SCON=0X50;    //9600 bps @ 11.0592MHZ 
TMOD=0X20;
TH1=0XFD;
TL1=0XFD;
TR1=1;
while(1)
{
while(RI==0);  // wait here to raise the flag
a=SBUF;
RI=0;
// other functions are called here
conv();
read();
display();
;
;
;
;
}
}


using interrupt in c
#include <reg51.h>
unsigned char a;
void serial (void) interrupt 4
{
if(RI==1)
{
a=SBUF;
;
;
;
RI=0;
}
else
{
TI=0;
}

}

void main (void)
{
SCON=0X50;    //9600 bps @ 11.0592MHZ 
TMOD=0X20;
TH1=0XFD;
TL1=0XFD;
TR1=1;
IE=0X90;   //enable global interrupt along with  serial
while(1)
{
conv();
read();
display();
;
;
;
;
}
}
Sat Jan 01 2011, 05:07 pm
#3
Hi Mojaka,

Thanks, Very nicely stated about the interupts.
Sat Jan 01 2011, 07:22 pm
#4
Good explanation majoka... write your own book.... I will do publicity for you
Sat Jan 01 2011, 10:02 pm
#5
@ kirangowle
welcome dear
@ coolmirza143
i want to write a book in which practical interfacing is described
not a theory practical based
Mon Jan 03 2011, 10:37 am
#6
Hi mojaka,

Practical interfacing means ADC, 7 segment, RTC etc..
Do it for all the interfacing should be on same board, along with the programmer, There is huge demand in collages as well as corporate world also to train the freshers.
Mon Jan 03 2011, 11:25 am
#7
hi kirangowle

Practical interfacing means ADC, 7 segment, RTC etc..


yes ur r right adc ,RTC ,steeper, servo,lcds,keypads,eeproms,pc key board ..... and many more

Do it for all the interfacing should be on same board, along with the programmer, There is huge demand in collages as well as corporate world also to train the freshers.


yes all can be done on same board
but it need sources , time and many more its in fact a team work
Mon Jan 03 2011, 11:57 am
#8


hi kirangowle

Practical interfacing means ADC, 7 segment, RTC etc..


yes ur r right adc ,RTC ,steeper, servo,lcds,keypads,eeproms,pc key board ..... and many more

Do it for all the interfacing should be on same board, along with the programmer, There is huge demand in collages as well as corporate world also to train the freshers.


yes all can be done on same board
but it need sources , time and many more its in fact a team work

majoka



Majoka never feel alone... i am with you start your work i will help you as much i could....


off topic:

I am visiting Islamabad in next week will come in sector H-8 and G-4 in AIOU and HEC offices.... hope to meet you there...
Mon Jan 03 2011, 12:30 pm
#9
thank u coolmirza143
Mon Jan 03 2011, 12:34 pm
#10
you are welcome my friend...

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Bobbyerilar
Thu Mar 28 2024, 08:08 am
pb58
Thu Mar 28 2024, 05:54 am
Clarazkafup
Thu Mar 28 2024, 02:24 am
Walterkic
Thu Mar 28 2024, 01:19 am
Davidusawn
Wed Mar 27 2024, 08:30 pm
Richardsop
Tue Mar 26 2024, 10:33 pm
Stevencog
Tue Mar 26 2024, 04:26 pm
Bernardwarge
Tue Mar 26 2024, 11:15 am