// Lauflicht ueber Port 2 // Walter Waldner, 1998/07
#include <reg167.h>
void warten(unsigned int w);
const unsigned int dauer = 0x2000;
void main(void)
{
unsigned int x;
// Pins 2.0 bis 2.7 als Ausgaenge
DP2 = 0x00FF;
ODP2 = 0x0000;
// Timer 3 konfigurieren
T3CON = 0x0007;
while (1)
{
for (x=1; x<=0x0080; x=x<<1)
{
P2 = x;
warten(dauer);
}
for (x=0x0040; x>=0x0002; x=x>>1)
{
P2 = x;
warten(dauer);
}
}
}
void warten(unsigned int w)
{
T3 = 0;
T3R = 1;
while (T3 <= w);
T3R = 0;
}