A/D + Pwm - Hitachi Network Adapter H8 User Manual

Lowcost evaluation board
Table of Contents

Advertisement

HTEB1
User manual

3.4 A/D + PWM

This sample shows the usage of the A/D converter. We sample the voltage
of P1/P2, filter it and show the result on the LCD. On D/A-Con you will see
a reversed voltage at P2 – built with a RC-filter from TOW (P76).
/*------------------------------------------------------------------
** AD_PWM Demo shows some funcions of the A/D converter
** and the use of PWM (= inverse output from P2) at D/A-Con
**-----------------------------------------------------------------*/
#include "mydefs.h"
#include "stdlib.h"
void wait(u16 wastetime)
{
while(wastetime--);
}
/*
LCD-Port / Bits on TinyEvalBoard
RS = P75, R/W
*/
// some defines for easy access
#define CLEAR_LCD_RS
#define SET_LCD_RS
#define CLEAR_LCD_RW
#define SET_LCD_RW
#define CLEAR_LCD_EN
#define SET_LCD_EN
#define LCD_DATA_PORT (PDR5)
#define LCD_DATA_CTRL (PCR5)
#define LCD_OUT
#define LCD_IN 0x00
#define LCD_WAIT
void LCDWriteCmd(u8 cmd)
{
CLEAR_LCD_RS;
CLEAR_LCD_RW;
SET_LCD_EN;
LCD_DATA_PORT = cmd;
LCD_WAIT;
CLEAR_LCD_EN;
LCD_WAIT;
}
void LCDWriteData(u8 data)
{
SET_LCD_RS;
CLEAR_LCD_RW;
SET_LCD_EN;
LCD_DATA_PORT = data;
LCD_WAIT;
CLEAR_LCD_EN;
LCD_WAIT;
}
u8 LCDReadStatus(void)
{
u8 status;
CLEAR_LCD_RS;
SET_LCD_RW;
Issue 0.2
// with further includes!
// for abs()
// local LCD port delay
= P74, EN
= P20, DATA = P5
(PDR7 &= ~0x20)
(PDR7 |= 0x20)
(PDR7 &= ~0x10)
(PDR7 |= 0x10)
(PDR2 &= ~0x01)
(PDR2 |= 0x01)
0xff
{wait(100);}
// write cmd to LCD port
// write data to LCD port
// get the LCD status register
Page 41
07/2002

Advertisement

Table of Contents
loading

This manual is also suitable for:

H8/tiny 3664fHteb1

Table of Contents