IBM H8 user manual PMR1 &= ~KEYALL

Page 34

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

Image 34
Contents Hitachi H8/Tiny 3664F Preface Table of Contents System Development Kit content Hardware descriptionFeatures Board overview Board overviewJumpers and switches JP4, D/A CONOrientation Operation Connectors X1 SubD9, Pin Operation RemarkX3 LCD-CON SV1 SV2 SV3 SV4 PIN Installing the HTEB1 Start-Up instructionsTest program Software Installation Creating a program using IAR-EWH8 Development EnvironmentHTEB1 HTEB1 HTEB1 HTEB1 HTEB1 HTEB1 HTEB1 Download the code using FDT HTEB1 HTEB1 HTEB1 HTEB1 HTEB1 HTEB1 HTEB1 Workflow Examples Key’s and LED’s LEDSPEEDINIT4PMR1 &= ~KEYALL RunningLightInit Init keys and LEDs TimerAInit LCD Clearlcdrs Setlcdrw Lcddatactrl = Lcdin Setlcden HTEB1 SCI IsscitxfreeInit sci with 9600Baud, 8N1 A/D + PWM Lcddatactrl = Lcdin Setlcden Calculate av of last 15 values AT-Keyboard-Interface Setlcdrw Lcddatactrl = Lcdin Setlcden Mask = Msg buffer Tables Scan-Codes MFII-Keyboard Numeric Keypad Main Scan-Code Keypad Function Scan-Code Examples DatasheetsPrograms DemoAppendix B Schematic Appendix C Board layout HTEB1 HTEB1 HTEB1