IBM H8 user manual Msg buffer

Page 47

HTEB1

User manual

keyReadIndex++;

if (keyReadIndex >= cKeyBufSize) keyReadIndex = 0; return KeyCode;

}

u8 buffer[17] = " KeyCode : 0000 \0";

// msg buffer

//convert int to ASCII-HEX void ShowCode(u16 code)

{

u8 *data, c;

data = &buffer[14];

 

 

// last digit = start address

while (code)

 

 

 

{

 

 

 

*data = '0';

 

// default = '0'

c = code & 0x000f;

 

// check digit

if (c)

 

 

// if > 0 chk for value

{

 

 

 

if (c < 10) *data = '0'+c;

// 0..9

else *data = 'A'+c-10;

 

// a..f

}

 

 

 

data--;

 

 

// next digit

code >>= 4;

 

 

 

}

 

 

 

LCDWriteLine(1,buffer);

 

// show result

}

 

 

 

void KeyTest(void)

 

 

 

{

 

 

 

u8 c;

 

 

 

u16 KeyCode;

 

 

 

PMR1 = cKEYCLK;

// P16 irq-input

PMR1 &= ~cKEYDATA;

// P17 i/o-pin

 

IEGR1 &= ~0x04;

 

// IRQ_2 on falling edge

IENR1 = 0x04;

 

// enable IRQ_2

set_interrupt_mask(0);

// enable all interrupts

LCDWriteLine(0, "PC-Keyboard-Test");

 

LCDWriteLine(1, "press any key...");

 

while (1)

 

 

 

{

 

 

 

if (kbhit())

// if new key ...

{

 

 

 

KeyCode = GetKey();

// get codes

ShowCode(KeyCode);

// display code

}

 

 

 

}

 

 

 

}

 

 

 

void main(void)

 

 

 

{

 

 

 

LCDInit();

// init ports and LCD

KeyTest();

// go to keyboard test

}

 

 

 

 

 

 

 

Issue 0.2

Page 47

07/2002

Image 47
Contents Hitachi H8/Tiny 3664F Preface Table of Contents Hardware description System Development Kit contentFeatures Board overview Board overviewJP4, D/A CON Jumpers and switchesOrientation Operation X1 SubD9, Pin Operation Remark ConnectorsX3 LCD-CON SV1 SV2 SV3 SV4 PIN Start-Up instructions Installing the HTEB1Test program Software Installation Development Environment Creating a program using IAR-EWH8HTEB1 HTEB1 HTEB1 HTEB1 HTEB1 HTEB1 HTEB1 Download the code using FDT HTEB1 HTEB1 HTEB1 HTEB1 HTEB1 HTEB1 HTEB1 Workflow Examples LEDSPEEDINIT4 Key’s and LED’sPMR1 &= ~KEYALL RunningLightInit Init keys and LEDs TimerAInit LCD Clearlcdrs Setlcdrw Lcddatactrl = Lcdin Setlcden HTEB1 Isscitxfree SCIInit 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 Demo DatasheetsPrograms ExamplesAppendix B Schematic Appendix C Board layout HTEB1 HTEB1 HTEB1