HTEB1

User manual

}

 

if (LED_Speed) LED_Speed--;

// decrement speed counter

if (!LED_Speed)

// if zero ...

{

 

LED_Speed = LED_SPEED_INIT;

// re init speed counter

if (LED_Run)

 

{

 

if (LED_Dir)

// right

{

 

LED_Out >>= 1;

// shift right

if (!LED_Out) LED_Out = 0x80; // if empty, set to 0x80

}

 

else

 

{

 

LED_Out <<= 1;

// shift left

if (!LED_Out) LED_Out = 0x01; // if empty, set to 0x01

}

 

}

 

}

 

PDR8 = ~LED_Out;

// output (invert)

}

 

void PrepKeyPort(void)

// prepare key-port-bits

{

 

PMR1 &= ~KEY_ALL;

// Port1 = I/O (0) for all keys

PCR1 &= ~KEY_ALL;

// Port1 = input(0) for all keys

PUCR1 = KEY_ALL;

// PullUps = on for all keys

}

 

void RunningLightInit(void)

// prepare LED-port and vars

{

 

PrepKeyPort();

 

PDR8 = 0xff;

// all LED's off

PCR8 = 0xff;

// all out's

LED_Out = 0x01;

// start value

LED_Run = 0x01;

// run

LED_Dir = 0x00;

// dir = left

LED_Speed = LED_SPEED_INIT;

// start speed

}

 

/****************************************

TimerA-Interrupt (1s) increments var c and output

the value of c to LED's (inverted)

****************************************/

interrupt [TIMER_A] void Timer_A_Isr(void)

{

static u8 c;

 

 

 

KeyCheck();

//

check

for key pressed

RunningLightUpdate();

 

 

 

IRR1 &= ~0x40;

//

clear

irq-flag

}

 

 

 

/****************************************

TimerA-Test

setup : CLK/8 (=1µs @ 8MHz) at P10 (TMOW) 1s-Irq-intervall @ SubClock (32.678 Hz)

****************************************/

void Timer_A_Init(void)

{

PCR8 = 0xff;

// P8 = output

TMA = 0x0c;

// Reset PrescalerW

TMA = 0x4b;

// CLK/8 on P10, 1/32s-interval (Clk=Prescaler W)

PMR1 = 0x01;

// set TMOW (P10) = Output

IENR1 = 0x40;

// enable TimerA-Interrupt

set_interrupt_mask(0);

// enable all interrupts

}

 

void main(void)

 

{

 

Issue 0.2

Page 34

07/2002

Page 34
Image 34
IBM H8 user manual PMR1 &= ~KEYALL