Professional Documents
Culture Documents
Embedded C Advanced
Embedded C Advanced
1/10/2012
Microcontroller 8051
Interrupts
The C51 compiler provides a method of calling a C function when an interrupt occurs This support allows you to create interrupt service routines in C The compiler automatically generates the interrupt vector and entry and exit code for the interrupt routine
1/10/2012
Microcontroller 8051
Interrupts
The interrupt function attribute, when included in a declaration, specifies that the associated function is an interrupt function The interrupt number and the register bank are specified Additionally, you can specify the register bank used for that interrupt with the using function attribute
1/10/2012 Microcontroller 8051 3
Interrupts
1/10/2012
Microcontroller 8051
Example
unsigned int interruptcnt; unsigned char second; void timer0 (void) interrupt 1 using 2 { if (++interruptcnt == 4000) { /* count to 4000 */ second++; interruptcnt = 0; }
1/10/2012 Microcontroller 8051 5
1/10/2012
In-line assembly
>ASM and ENDASM directives are used along with #pragma directives.
1/10/2012
Microcontroller 8051
1/10/2012
Microcontroller 8051
Disabling interrupts
#pragma disable This directive instructs the compiler to disable the interrupt for the duration of the function.
1/10/2012
Microcontroller 8051
10
Function parameters
By default c functions pass up to three parameters in registers,the remaining in fixed memory locations. Parameter passing in registers can be disabled by calling #pragma NOREGPARMS.
1/10/2012
Microcontroller 8051
11
Function parameters
1/10/2012
Microcontroller 8051
12
1/10/2012
Microcontroller 8051
13
Return values
1/10/2012
Microcontroller 8051
14
I request Electronics and communication ENGINEERING students to visit my blog for more abhishek1ek.blogspot.com awhengineering.blogspot.com THANK YOU
1/10/2012 Microcontroller 8051 15