Hitachi Network Adapter H8 User Manual page 43

Lowcost evaluation board
Table of Contents

Advertisement

HTEB1
User manual
{
u8 *data, *text, c,d;
if (line==0) text = &Line0[0];
else text = &Line1[0];
data = text+14;
d=3;
while (d)
{
*data = '0';
c = code & 0x000f;
if (c)
{
if (c < 10) *data = '0'+c;
else *data = 'A'+c-10;
}
data--;
code >>= 4;
d--;
}
LCDWriteLine(line,text);
}
void Delay(void)
{
long z = 0x010000;
while(--z);
}
u16 oldval[2];
u16 Average(u8 channel, u16 adval)
{
if ((abs)(oldval[channel]-adval)>10)
oldval[channel]=adval;
else
oldval[channel] = ((oldval[channel]*15)+adval)>>4;
return oldval[channel];
}
/****************************************
TimerV-Test
setup : CLK/8 (=1µs @ 8MHz)
PWM-Output at TMOV (P76)
****************************************/
void Test_Timer_V(void)
{
TCRV0 = 0x08|0x01;
TCRV1 = 0x01;
TCSRV = 0x08|0x01;
TCORA = 100;
TCORB = 75;
}
void main(void)
{
u16 val;
LCDInit();
Test_Timer_V();
while(1)
{
val = Average(0,Read_AD(0));
ShowHexValue(val,0);
val = Average(1,Read_AD(1));
ShowHexValue(val,1);
val /= 10;
TCORB = (unsigned char)(val & 0xff); // set PWM-output
Delay();
}
}
Issue 0.2
// last digit = start address
// show result
// calculate av of last 15 values
// Clear by CompMatchA; IntClk/8
// Clk/2, no external Trigger
// 0=onCompMatchA, 1=onCompMatchB (output on P76)
// set periode to 100 => 10.000Hz
// set init dutycycle to 75%
// init ports and LCD
// for PWM-Output
// do forever...
// max. 1023/10 = 102
Page 43
// default = '0'
// check digit
// if > 0 chk for value
// 0..9
// a..f
// next digit
// "manual" delay
07/2002

Advertisement

Table of Contents
loading

This manual is also suitable for:

H8/tiny 3664fHteb1

Table of Contents