Intel Microcontroller Microscope & Magnifier User Manual


 
8XC196NP, 80C196NU USER’S MANUAL
10-24
10.8 PROGRAMMING EXAMPLES FOR EPA CHANNELS
The three programming examples provided in this section demonstrate the use of the EPA channel
for a compare event, for a capture event, and for generation of a PWM signal. The programs dem-
onstrate the detection of events by a polling scheme, by interrupts, and by the PTS. All three ex-
amples were created using ApBUILDER, an interactive application program available through
Intel Literature Fulfillment.
These sample program were written in the C programming language.
ASM versions are also available from
ApBUILDER.
NOTE
The initialization file (80c196np.h) used in these examples is available from
the Intel Applications BBS.
10
.8.1 EPA Compare Event Program
Th
is example C program demonstrates an EPA compare event. It sets up EPA channel 0 to toggle
its output pin whenever timer 1 is zero. This program uses no interrupts; a polling scheme detects
th
e EPA event. The program initializes EPA channel 0 for a compare event.
#pragma model(EX)
#include <80c1
96np.h>
#define COMPARE
0x40
#define RE_ENABLE
0x08
#define TOGGLE_PIN
0x30
#define USE_TIMER1
0x00
#define EPA0_INT_BI
T 7
void init_epa0()
{
epa0_con =
COMPARE
¦
TOGGLE_PIN ¦
RE_ENABLE ¦
USE_TIMER1;
epa0_time = 0;
setbit(p1_reg, 0); /* int reg */
clrbit(p1_dir, 0)
; /* make output pin */
setbit(p1_mode, 0)
;/* select EPA mode */
}
void init_timer1()
{
t1control =
COUNT_ENABLE
¦
COUNT_UP ¦
CLOCK_INTERNAL ¦
DIVIDE_BY_1;
}