
VMX51C1020
_________________________________________________________________________________________________
www.ramtron.com
page 70 of 80
Setting up INT0 and INT1 Interrupts
The IT0 and IT1 bits of the TCON register define
whether external interrupts 0 and 1 will be edge
or level triggered.
When an interrupt condition occurs on INT0 or
INT1, the associated interrupt flag IE0 or IE1 will
be set. The interrupt flag is automatically
cleared when the interrupt is serviced.
T
ABLE
122:
(TCON)
T
IMER
0,
T
IMER
1
T
IMER
/C
OUNTER CONTROL
-
SFR
88
H
7
6
TF1
TR1
3
2
IE1
IT1
Bit
Mnemonic
Function
7
TF1
Timer 1 overflow flag set by hardware
when Timer 1 overflows. This flag can be
cleared by software and is automatically
cleared when interrupt is processed.
6
TR1
Timer 1 Run control bit. If cleared Timer 1
stops.
5
TF0
Timer 0 overflows flag set by hardware
when Timer 0 overflows. This flag can be
cleared by software and is automatically
cleared when interrupt is processed.
4
TR0
Timer 0 Run control bit. If cleared timer 0
stops.
3
IE1
Interrupt 1 edge flag. Set by hardware
when falling edge on external INT1 is
observed. Cleared when interrupt is
processed.
2
IT1
Interrupt 1 type control bit. Selects falling
edge or low level on input pin to cause
interrupt.
1
IE0
Interrupt 0 edge flag. Set by hardware
when falling edge on external pin INT0 is
observed. Cleared when interrupt is
processed.
0
IT0
Interrupt 0 type control bit. Selects falling
edge or low level on input pin to cause
interrupt.
5
4
TF0
TR0
1
IE0
0
IT0
INT0 example
The following provides example code for
interrupt setup and module configuration.
//---------------------------------------------------------------------------
// Sample C code to setup INT0
//---------------------------------------------------------------------------
#pragma TINY
#include <vmixreg.h>
at 0x0100 void main (void) {
// INT0 Config
TCON |= 0x01; //Interrupt on INT0 will be caused by a High->Low
//edge on the pin
// Enable INT0 interrupts
IEN0 |= 0x80;
// Enable all interrupts
IEN0 |= 0x01;
// Enable interrupt INT0
// Wait for INT0…
do
{
}while(1);
//Wait for INT0 interrupts
}//end of main function
//---------------------------------------------------------------------------
// Interrupt Function
void int_ext_0 (void) interrupt 0
{
IEN0 &= 0x7F;
// Disable all interrupts
/* Put the Interrupt code here*/
IEN0 |= 0x80;
// Enable all interrupts
}
//---------------------------------------------------------------------------
INT1 example
The following code example shows the INT1
interrupt setup and module configuration:
//-------------------------------------------------------------------------
// Sample C code to setup INT1
//-------------------------------------------------------------------------
#pragma TINY
#include <vmixreg.h>
at 0x0100 void main (void) {
// INT1 Config
TCON |= 0x04; //Interrupt on INT1 will be caused by a High->Low
//edge on the pin
// Enable INT1 interrupts
IEN0 |= 0x80;
IEN0 |= 0x04;
// Wait for INT1…
do
{
}while(1);
//Wait for INT1 interrupts
// Interrupt function
void int_ext_1 (void) interrupt 2
{
IEN0 &= 0x7F;
// Disable all interrupts
/* Put the Interrupt code here*/
IEN0 |= 0x80;
// Enable all interrupts
}
// Enable all interrupts
// Enable interrupt INT1