Intel 80C196NU User Manual
10-25
EVENT PROCESSOR ARRAY (EPA)
void poll_epa0()
{
if(checkbit(int_pend, EPA0_INT_BIT))
{
if(checkbit(int_pend, EPA0_INT_BIT))
{
/* Insert user code for event channel 0 here. */
/* Since this event is absolute and re-enabled, no polling is neccessary.*/
/* Insert user code for event channel 0 here. */
/* Since this event is absolute and re-enabled, no polling is neccessary.*/
clrbit(int_pend, EPA0_INT_BIT);
}
}
void main(void)
{
/* Initialize the timers before using the epa */
init_timer1();
init_epa0();
/* EPA events can be serviced by polling int_pend or epa_pend. */
while(1)
{
/* Initialize the timers before using the epa */
init_timer1();
init_epa0();
/* EPA events can be serviced by polling int_pend or epa_pend. */
while(1)
{
poll_epa0();
}
poll_epa0();
}
}
10.8.2 EPA Capture Event Program
This example C program demonstrates an EPA capture event. It sets up EPA channel 0 to capture
edges (rising and falling) on the EPA0 pin. The program also shows how to set up an the EPA
interrupt. You can add your own code for the interrupt service routine.
edges (rising and falling) on the EPA0 pin. The program also shows how to set up an the EPA
interrupt. You can add your own code for the interrupt service routine.
#pragma model(EX)
#include <80c196np.h>
#include <80c196np.h>
#define COUNT_ENABLE
0x80
#define COUNT_UP
0x40
#define CLOCK_INTERNAL
0x00
#define DIVIDE_BY_1
0x00
#define CAPTURE
0x00
#define BOTH_EDGE
0x30
#define USE_TIMER1
0x00
#define EPA0_INT_BIT
7
void init_epa0()
{
epa0_con = CAPTURE
{
epa0_con = CAPTURE
¦
BOTH_EDGE
¦
USE_TIMER1;
setbit(p1_reg, 0); /* int reg */
setbit(p1_dir, 0); /* make input pin */
setbit(p1_mode, 0);/* select EPA mode */
setbit(int_mask, EPA0_INT_BIT);/* unmask EPA interrupts */
}
setbit(p1_dir, 0); /* make input pin */
setbit(p1_mode, 0);/* select EPA mode */
setbit(int_mask, EPA0_INT_BIT);/* unmask EPA interrupts */
}
#pragma interrupt(epa0_interrupt=EPA0_INT_BIT)
void epa0_interrupt()
{
unsigned int time_value;
void epa0_interrupt()
{
unsigned int time_value;