HTEB1
User manual
} |
|
if (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 |
{ |
|
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 |
{ |
|
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 |
} |
|
/****************************************
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 | |
} |
|
|
|
/****************************************
setup : CLK/8 (=1µs @ 8MHz) at P10 (TMOW)
****************************************/
void Timer_A_Init(void)
{
PCR8 = 0xff; | // P8 = output |
TMA = 0x0c; | // Reset PrescalerW |
TMA = 0x4b; | // CLK/8 on P10, |
PMR1 = 0x01; | // set TMOW (P10) = Output |
IENR1 = 0x40; | // enable |
set_interrupt_mask(0); | // enable all interrupts |
} |
|
void main(void) |
|
{ |
|
Issue 0.2 | Page 34 | 07/2002 |