Product Warranty
The warranty period against defects in materials and workmanship are as set out in the
accompanying Customer Information sheet.
Limitation of Warranty
The foregoing warranty does not cover damage caused by fair wear and tear, abnormal
storage conditions, incorrect use, accidental misuse, neglect, corruption, misapplication,
addition or modification or by the use with other hardware or software, as the case may
be, with witch the product is incompatible. No warranty of fitness for a particular purpose
is offered. The user assumes the entire risk of using the product. Any liability of embesso
GmbH is limited exclusively to the replacement of defective material or workmanship.
Trademarks
All brand or product names used in this manual are trademarks or registered trademarks
of their respective companies or organisations.
Microsoft is a registered trademark and Windows and Windows NT are trademarks of
Microsoft Corporation. IBM is a registered trademark of International Business Machines
Corporation.
Cautions
This document may be, wholly or partially, subject to change without notice. All rights
reserved. No one is permitted to reproduce or duplicate, in any form, a part or this entire
document without embesso GmbH written permission.
Restrictions
Please refer to the restrictions of all components and tool suppliers.
Hardware Considerations
Grounding: This hardware is designed for use with equipment that is fully grounded.
Ensure that all equipment used is appropriately grounded. Failure to do so could lead to
danger for the operator or damage the equipment.
Electrostatic Discharge Precautions: This hardware contains devices that are sensitive to
electrostatic discharge. Ensure appropriate precautions are observed during handling and
accessing connections. Failure to do so could result in damage to the equipment.
Electromagnetic Compatibility: This product can cause radio frequency noise when used
in the residential area. In such cases the user of the equipment my be required to take
appropriate countermeasures under his responsibility.
Support
Support by embesso GmbH is provided only for the supplied hardware. Any software
tools are supported from their supplier. Please notice that maybe some software tools
coming with this kit are only unsupported freeware and no support will be given.
For embesso support please contact: support@embesso.com
Thank you for purchasing our product. If you take care on the different
hints in this manual you will have great success in software development
with this microcontroller. Please refer to the documents listed in appendix.
The System Development Kit
contains the following parts:
Carefully remove the board from the shipping carton. Check first if there
are any damages before power on the evaluation board.
1.2 Hardware description
The Hitachi-Tiny-Eval-Board (HTEB1) is a low cost multifunctional
evaluation board for the Hitachi Tiny H8/3664F microcontroller. It can be
used stand alone for software development and testing or as a simple
target board. You can use the Flash-Download-Tool (FDT) for
programming the target code or work with a debug system (E10T) at the
provided connector. The board allows the designer immediately to start
with the software development before his own final target system is
available.
This eval-kit provides some additional hardware e.g. 8 LED’s, a 2*16
Character LCD, 4 key’s, a PC-AT-keyboard connector, an I2C-connector
and more for hard- and software evaluation. All peripherals are used by
some software application notes. Please refer chapter 3.
Issue 0.2Page 407/2002
HTEB1
User manual
1.3 Features
• Contains H8/3664F microcontroller
• In-Circuit serial Flash programming
• All resources available for evaluation
• All pins routed to connectors
• 9.8304 MHz main crystal
• 32.768 kHz sub crystal
• UART interface with MAX232 level converter and SubD-9 (female)
connector
• 8 User LEDs
• 2*16 characters LCD with LED backlight (switchable)
• Additional connector for external LCD
• 4 user keys
• PC-AT-Keyboard interface
• 2 potentiometer connected to A/D-channel 0/1
• Reset button
• 1 switch user/prog(programming)
• E10T-debug-connector
• +5V voltage regulator on board
Issue 0.2Page 507/2002
HTEB1
Prog/Run
User manual
1.4 Board overview
2*16 char LCD with
LED backlight
Ext.-LCD
connector
Contrast
8 user LEDs
DA connector
RS232
connector
SubD0
female
Power 7,5 V9V DC
I2C
connector
E10T
connector
Crystal
socket
AT/PS2
keyboard
connector
+
-
P1 = ADC 0
P2 = ADC 1
4 user keys Reset button
Figure 1 Board overview
Issue 0.2Page 607/2002
switch
HTEB1
User manual
1.5 Jumpers and switches
JP1 is used for switching the serial interface from 1:1
to crossed connection. If you connect a 1:1 cable (like
the cable that comes with the kit) use the default
setting. If you connect a crossed cable set the jumper
to alternate setting.
JP3 is used for the LCD-LED backlight. If the jumper is
closed (1-2) the backlight will be ON. Remove the
jumper (=open) if backlight operation is not
necessary.
JP2 is used for I2C interface
JP4 is used as an output for the DAC or for PWM
JP1Operation
1-3, 2-41:1 operation
1-2, 3-4Crossed connection
JP3Operation
ClosedLED backlight ON
OpenLED backlight OFF
JP2, I2C-CONOperation
1+5V
2SDA
3SCL
4GND
JP4, D/A CONOperation
1D/A Output (PWM)
2GND
Issue 0.2Page 707/2002
HTEB1
User manual
S_PROG/RUN switches between RUN- and
PROG(PROGRAMMING) mode.
KEY_1 (T1) to KEY_4 (T4) are user keys.
RESET_KEY (T7) is for reset.
OrientationOperation
LEFTPROG(programming) mode
RIGHTRUN mode
Main crystal (Q1) can be changed to another
frequency. Therefore a crystal socket is provided.
Please refer to the microcontroller hardware
documentation for recommended devices. The crystal
type should be a HC49 / HC49U type. Eventually
change the capacitors C6/C7 if necessary. If you
change the crystal frequency take care on possible
changes by flash download tool (see FDT manual).
Figure 1.5 crystal socket
Issue 0.2Page 807/2002
HTEB1
User manual
1.6 Connectors
X1, Serial communication, SubD-9 female
X2, Power connector, for cable connection
X4, MiniDIN (PS2)
X2, PinOperation
1GND
2DC power supply,
7,5 – 9 VDC,
approx. 180mA
with LED backlight
X1 (SubD9), Pin OperationRemark
1(DTR,DSR, DTS)Connected to X1.4, X1.6
2TXDConnected to JP1.1
3RXDConnected to JP1.3
4DTRConnected to X1.1, X1.6
5GND
6DSRConnected to X1.1, X1.4
7RTSConnected to X1.8
8CTSConnected to X1.7
9n.c.Not connected
X4 (Mini-Din)
µC-PinOperation
Pin
1P17(can be Data or Clk)
5P16(can be Clk or Data)
3GND
4Vcc
2,6n.c.
Installing the HTEB1 requires a power supply and a serial connection to a
host computer (common PC). The serial communications cable for
connecting the HTEB1 to a host computer is supplied and has 1:1
connectivity.
PC with COM1/2
Power supply
7,5-9V DC
Figure 1.8 shows how to connect the HTEB1 to a PC and to a power supply
1.7.2Power Supply
The HTEB1 hardware requires a power supply of 7,5V DC at minimum.
Please don’t use a power supply with more the 9V DC because the on
board voltage regulator becomes very hot!
The HTEB1 power consumption is about 180mA with LCD-backlight ON.
Since total power consumption can vary widely due to external
connectors, H8/3664F port state, use a power supply capable of providing
at least 300mA at +7,5V DC.
The design includes circuitry for reversed polarity protection.
Please watch on GND (ground) connection between power supply, evalboard and PC.
Issue 0.2Page 1207/2002
HTEB1
User manual
1.7.3Test program
The HTEB1 is supplied with a short demo application when delivered. If
you power up the eval-board for the first time, you will see a start up
message and some LEDs lighting.
If no message appear, please set the switch “Prog/Run” to “Run-Mode”
(right position) and power up the board or, if already done, press the
reset-button.
The demo application contains a small “Running-Light” application. The
keys can be used for control the state, P2 is used as speed control. First
press the key T3 (RUN) for starting demo application. Then you can check
the functionality by pressing the keys KEY T1 to KEY T4 or change the
value of potentiometer P2.
[…]
Figure of the Demo application. “Running Light”
Any time you want to reset the application press the reset-button. If you
want to reload the demo application later (after reprogrammed the evalboard) you can find the code on CD-R in the directory
“X:\examples\flashdemo\runlight.a37” (For X use the appropriate char
from your CD-ROM).
Issue 0.2Page 1307/2002
HTEB1
User manual
1.7.4Software Installation
Software development on embesso-HTEB1 requires some software tools to
be installed on your PC. All tools can be found on CD-R. Some of them
must be installed separately. Please refer on installation / setup
requirements.
You will find the following tools:
EWH8:IAR Embedded Workbench with a limited version of the IAR
C compiler for all Hitachi Tiny controllers, assembler, linker
and library generator
FDT:A powerful freeware flash tool (flash-writer) from HMSE
Installation hints:
EWH8:Install EWH8 by start \programs\iar\autorun.exe . Follow
the instructions in setup and look at the readme.txt file.
FDT:Next install \programs\fdt\ftd15.exe. Then the plugin
fdt3664f.exe must be installed. Follow the setup
instructions. A documentation will be found in fdt_man.pdf.
If you have installed these tools please refer to the next lessons for
workflow.
NOTE: Most freeware tools are unsupported versions! Please refer
to manuals or hints on website for FAQ’s!
It is strongly recommended to refer all additional documents like
H8/3664F hardware manual and H8 programming manual. Please see the
application notes and several readme files on CD-R. Sometimes you
should watch on the Hitachi, HMSE and IAR websites for tool upgrading,
news and latest versions of all tools.
Software development can be done with a integrated embedded
workbench like IAR-EWH8. This software contains an editor, some tools
for organization and a tool chain for compiling, assembling and linking
programs.
Start IAR Embedded Workbench on your PC. The following window will
appear:
Now select File / New and select “Project”
Issue 0.2Page 1507/2002
HTEB1
User manual
Press OK and a file window will appear. Here first create a new directory
(e.g. c:\MyTinyTest) and type the project filename “MyTinyTest”. After
that click CREATE.
Now a new project is created and we must do some settings. In the
window select under targets: “RELEASE”.
Issue 0.2Page 1607/2002
HTEB1
User manual
Now select release with the right mouse button. A popup appears. Select
Options… and do the following settings:
In selection ICCH8/List select the List file box.
In section XLINK/Output select under Format “motorola” as the output
format.
Issue 0.2Page 1707/2002
HTEB1
User manual
On the CD-R you will find a file called “hteb1.xcl”. That file must be used
as the xlink input file. Please copy it to your target directory and select in
section Input/XCL file name the file hteb1.xcl.
Issue 0.2Page 1807/2002
HTEB1
User manual
All other options can be changed later.
Click on OK.
Now select File/new/source file and type in the following program:
/* MyTinyTest */
#include "ioh83664.h"
void main(void)
{
unsigned int x=0;/* counter */
unsigned char c=0;/* holds port output */
PCR8 = 0xff;/* port is output */
PDR8 = c;/* all LED's on (inverse) */
while (1)
{
while (--x);/* wait ... */
c++;/* increment c */
PDR8 = c;/* to port */
}
}
Issue 0.2Page 1907/2002
HTEB1
User manual
After that save it under MyTinyTest.c
Now we must add this file to our project. Please select Project/Files and
add the file MyTinyTest.c.
Issue 0.2Page 2007/2002
HTEB1
User manual
After that click on DONE.
Now you can select Projet/Build ALL (or F9) and all files are compiled and
linked. The message window shows if your project is error free or if there
are any errors.
Issue 0.2Page 2107/2002
HTEB1
User manual
The target file for download can be found in directory
c:\mytinytest\release\exe\mytinytest.a37.
Please see chapter “FDT” for information about downloading this file to
target system.
Issue 0.2Page 2207/2002
HTEB1
User manual
2.2 Download the code using FDT
After compiling and linking (error free!), the target code (mytinytest.mot)
should be downloaded to target board. Therefore we use a freeware tool
from HMSE : FDT.
Even FDT must be prepared for a new workspace.
Issue 0.2Page 2307/2002
HTEB1
User manual
Please start FDT and select „New Workspace“. Here we use the project
name “MyTinyTest”.
You can choose a location for all workspace files. Select on subdirectory
from „MyTinyTest“.
Click ok and a further window will appear:
Select „Yes“
Issue 0.2Page 2407/2002
HTEB1
User manual
First time users should use the wizard!
Fill in the following things:
Issue 0.2Page 2507/2002
HTEB1
User manual
Issue 0.2Page 2607/2002
HTEB1
User manual
Issue 0.2Page 2707/2002
HTEB1
User manual
Now a workspace is created and you can add your target file to
„TargetFiles“:
Select Project/Add new files to project… and search for file:
c:\hew2\mytinytest\mytinytest\release\mytinytest.mot.
Issue 0.2Page 2807/2002
HTEB1
User manual
Now make a double click on \targetfiles\mytinytest and the file content of
mytinytest.mot will appear in hex format in the right window.
First press the reset button at the target board, hold it down and move
Prog/Run-switch to prog position (left). After that release the reset button.
With Image/Download image (Ctrl-P) you one can start the connection
setup to target board and start downloading image file.
Now press Ctrl-P (Download) on FDT and the download process will start.
Watch on progress bar while download.
When the download is finished press Alt-C to disconnect the PC
connection.
On target board, move Prog/Run-switch to run position (right) press down
the reset button and release reset button.
Congratulations! Now your first program is running!
You will see the LED’s flickering.
Issue 0.2Page 2907/2002
HTEB1
User manual
Now you can do some additional functions in HEW. After compiling and
linking only go to FDT, update your download file with the command
Freshen all Target files (Ctrl-T), reconnect the link and repeat the
download process.
Issue 0.2Page 3007/2002
HTEB1
User manual
2.3 Workflow
Issue 0.2Page 3107/2002
HTEB1
User manual
3 Examples
HTEB1 is provided with some demonstration code.
On the supplied CD-R you should find a complete prepared workspace for
IAR-EWH8.
\examples\demoapp\demoapp.prj
Please copy the complete directory to your hard disk in a directory
c:\H8TinyIAR, so you will finally have the following directory (per
example) “c:\H8TinyIAR\examples\demoapp\” with all application notes
included.
Then start IAR-Ewh8 and select “open existing workspace”. Select one of
the projects and do your exercises.
For all projects we need the same header file containing some definitions
and the include file for the target microcontroller H8/3664F. So if you
want to work with these files don’t forget to include the file “mydefs.h”
first in your project file:
#ifndef _MYDEFS_H_
#define _MYDEFS_H_
#include "ioh83664.h"// select processortype here
#include "inh8.h"
#include "icclbutl.h"
#define CPU_CLK 9830400// select clk for diff. calc.
#ifndef NULL
#define NULL 0x00
#endif
#ifndef FALSE
#define FALSE 0x00
#endif
#ifndef TRUE
#define TRUE 0x01
#endif
typedef unsigned char u8;
typedef unsigned int u16;
#endif
Issue 0.2Page 3207/2002
HTEB1
User manual
3.1 Key’s and LED’s
The first demo program shows the usage of LEDs and keys on HTEB1. For
time-controlling we use TIMER_A as an periodic interval timer. The
interrupt service routine (isr) is checking the state of the keys, actualising
the LED port and reading out the AD1-channel to determine the running
light speed. If you want to do some experiments, first check out to find if
other LED pattern maybe in form of a table read out or calculate them by
functions developed by yourself. If speed control should be changed, first
change the calculation of the A/D-conversion value to timer ticks.
/*-----------------------------------------------------------------** KeysLEDs.c contains some sample code for using LEDs and Key's
** on TinyEvalBoard
** in addition Timer_A is used for timer tick with irq
**-----------------------------------------------------------------*/
void RunningLightUpdate(void)// check for keypresse
{// and update LEDs
u8 dummy;
u16 adval;
if (!(KeyCode & KEY_RELEASED))
{
if ((KeyCode & KEY_1)==KEY_1) LED_Dir = 1;
else if ((KeyCode & KEY_4)==KEY_4) LED_Dir = 0;
else if ((KeyCode & KEY_2)==KEY_2) LED_Run = 0;
else if ((KeyCode & KEY_3)==KEY_3) LED_Run = 1;
KeyCode |= KEY_RELEASED;
Issue 0.2Page 3307/2002
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)
{
}
}
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
}
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
}
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)
{
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
}
1s-Irq-intervall @ SubClock (32.678 Hz)
void main(void)
{
Issue 0.2Page 3407/2002
HTEB1
User manual
RunningLightInit(); // Init key's and LEDs
Timer_A_Init();// init & start timer_A
while(1);// just wait ...
}
Issue 0.2Page 3507/2002
HTEB1
User manual
3.2 LCD
One of the highlights of the HTEB1 is the 2*16 character LCD with
backlight. Simple functions are provided here to demonstrate the usage of
the LCD. Please refer to the LCD manual for further information (e.g.
commands, other character sets etc.).
The demo source contains some definitions to reset and initialise the
display. Then we make some simple write outs.
/*-----------------------------------------------------------------** LCDDemo shows some funcions of the LCD on the TinyEvalBoard
** Please refer to LCD datasheet for further details
**-----------------------------------------------------------------*/
#include "mydefs.h"// find further includes there!
u16 cnt=0;
CLEAR_LCD_RS;
CLEAR_LCD_RW;
CLEAR_LCD_EN;
PCR7 |= 0x30;// Set RS+RW = Output
PCR2 |= 0x01;// Set EN = Output
LCD_DATA_CTRL = LCD_OUT; // Set DDR to Output
LCDWriteCmd(0x38); // 8Bit-IF, 2 Lines, 5x7 character font
while(--cnt);
LCDWriteCmd(0x38); // 8Bit-IF, 2 Lines, 5x7 character font
while(--cnt);
LCDWriteCmd(0x38); // 8Bit-IF, 2 Lines, 5x7 character font
while(--cnt);
LCDWriteCmd(0x38); // 8Bit-IF, 2 Lines, 5x7 character font
while(--cnt);
SCI is used here for a simple RS232 (V24) terminal connection. Please use
a terminal program like HyperTerm (included in Windows), select
Baudrate 9600 Baud, 8 Databits, No Parity and 1 Stopbit (8N1). After
connection and setup, hit some keys and you will see a message
responding on every keycode sent.
/*
**----------------------------------------------------------------------**
** main.c - contains C entry point main()
**
** This file was generated by HEW IAR Icch8 project generator
**
**----------------------------------------------------------------------*/
#include "mydefs.h"// see file for further include
/* some defines */
#define TIE 0x80
#define RIE 0x40
#define TE 0x20
#define RE 0x10
#define MPIE 0x08
#define TEIE 0x04
void V24Init (u16 Baudrate)
{
SCR3 = 0x00;// disable all
SSR = 0x00;// clear all errorbits
SMR = 0x00;// 8N1 + /1 clock
BRR = V24_BRR(Baudrate);// set baud
PMR1 |= 0x02;// P22 = TxD Output
SCR3 = (TE|RE|CK_INT);// Ints und Data disabled, internal clock
}
u8 V24NewChar(void)// check for new char on V24
{
if (IS_SCI_RDF)// Receive buffer full?
{
return TRUE;
}
return FALSE;
}
u8 V24GetChar(u8* data)// simple GetChar via V24
{
u8 idx;
if (IS_SCI_RDF)// Receive buffer full?
{
*data = RDR;// yes, get data
CLEAR_SCI_RDF;// clear RDRF-Bit
Issue 0.2Page 3907/2002
HTEB1
User manual
return TRUE;
}
return FALSE;
}
u8 V24PutChar(u8 c)// simple PutChar via V24
{
if (IS_SCI_TX_FREE)// Tx register free ?
{
TDR = c;// yes, put data in tx register
return TRUE;
}
return FALSE;
}
u8 V24Write(u8 *s)// simple Write(string) via V24
{
while (*s != 0)// while not end of string
{
if (V24PutChar(*s) == TRUE) s++; // PutChar
}
return TRUE;
}
u8 V24WriteLn(u8 *s)// simple WriteLine (string + CR/LF)
{
u8 ret = FALSE;
ret = V24Write(s);
ret |= V24Write("\n\r");
return ret;
}
void ShowUse(void)// simple menu
{
V24WriteLn("\n\n\rV24-DemoProgram");
V24WriteLn("-1- Line 1");
V24WriteLn("-2- Line 2");
V24Write("make your choise :");
}
void main(void)
{
char c;
V24Init(9600);// init sci with 9600Baud, 8N1
ShowUse();// display start msg
while(1) // loop ...
{
if (V24GetChar(&c)==TRUE)
{
}
}
if (c=='1')
{
V24WriteLn("\n\n\rGreat! This was '1'");
}
else if (c=='2')
{
V24WriteLn("\n\n\rSuper! '2'");
}
else
{
V24WriteLn("\n\n\rSorry! Only '1' or '2' are supported!");
}
ShowUse();
}
Issue 0.2Page 4007/2002
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"// with further includes!
#include "stdlib.h"// for abs()
void wait(u16 wastetime)// local LCD port delay
{
while(wastetime--);
}
/*
LCD-Port / Bits on TinyEvalBoard
RS = P75, R/W= P74, EN= P20, DATA = P5
u16 cnt=0;
CLEAR_LCD_RS;
CLEAR_LCD_RW;
CLEAR_LCD_EN;
PCR7 |= 0x30;// Set RS+RW = Output
PCR2 |= 0x01;// Set EN = Output
LCD_DATA_CTRL = LCD_OUT; // Set DDR to Output
// required 3 times pls. ref. data sheet
LCDWriteCmd(0x38); // 8Bit-IF, 2 Lines, 5x7 character font
while(--cnt);
LCDWriteCmd(0x38); // 8Bit-IF, 2 Lines, 5x7 character font
while(--cnt);
LCDWriteCmd(0x38); // 8Bit-IF, 2 Lines, 5x7 character font
while(--cnt);
LCDWriteCmd(0x38); // 8Bit-IF, 2 Lines, 5x7 character font
while(--cnt);
LCDWriteCmd(0x0c); // DisplayOn, CursorOff, BlinkingOff
LCDReadStatus();
LCDWriteCmd(0x06); // Enter Mode, AutoIncrement
LCDReadStatus();
LCDWriteCmd(0x14); // MoveCursor right
LCDReadStatus();
LCDWriteCmd(0x80); // Set DD RAM Address = 0x00
LCDReadStatus();
}
// writesomedata from 1st position in #line (0/1)
void LCDWriteLine(u8 line, u8 *data)
{
LCDWriteCmd(0x80 + line*0x40);// select line
while (*data)
{
LCDWriteData(*data);
data++;
}
}
#define ADDR_A (*(volatile unsigned short *)(0xFFB0))
#define ADDR_B (*(volatile unsigned short *)(0xFFB2))
TCRV0 = 0x08|0x01;// Clear by CompMatchA; IntClk/8
TCRV1 = 0x01;// Clk/2, no external Trigger
TCSRV = 0x08|0x01;// 0=onCompMatchA, 1=onCompMatchB (output on P76)
TCORA = 100;// set periode to 100 => 10.000Hz
TCORB = 75;// set init dutycycle to 75%
}
void main(void)
{
u16 val;
LCDInit();// init ports and LCD
Test_Timer_V();// for PWM-Output
while(1)// do forever...
{
val = Average(0,Read_AD(0));
ShowHexValue(val,0);
val = Average(1,Read_AD(1));
ShowHexValue(val,1);
PWM-Output at TMOV (P76)
val /= 10;// max. 1023/10 = 102
TCORB = (unsigned char)(val & 0xff); // set PWM-output
Delay();
}
}
Issue 0.2Page 4307/2002
HTEB1
User manual
3.5 AT-Keyboard-Interface
This demo shows the usage of the PS2 (mini-DIN) interface on HTEB1.
Please connect an AT-keyboard (MF102) to this port. You will see the
keycodes, provided by the keyboard on the LCD. Please refer to the code
table for keycode translation in your own projects.
/*-----------------------------------------------------------------** AT-Keyb shows the PS2-Interface to an AT-Keyboard
**-----------------------------------------------------------------*/
#include "mydefs.h"// with further includes!
void wait(u16 wastetime)// local LCD port delay
{
while(wastetime--);
}
/*
LCD-Port / Bits on TinyEvalBoard
RS = P75, R/W= P74, EN= P20, DATA = P5
u16 cnt=0;
CLEAR_LCD_RS;
CLEAR_LCD_RW;
CLEAR_LCD_EN;
PCR7 |= 0x30;// Set RS+RW = Output
PCR2 |= 0x01;// Set EN = Output
LCD_DATA_CTRL = LCD_OUT; // Set DDR to Output
// required 3 times pls. ref. data sheet
LCDWriteCmd(0x38); // 8Bit-IF, 2 Lines, 5x7 character font
while(--cnt);
LCDWriteCmd(0x38); // 8Bit-IF, 2 Lines, 5x7 character font
while(--cnt);
LCDWriteCmd(0x38); // 8Bit-IF, 2 Lines, 5x7 character font
while(--cnt);
LCDWriteCmd(0x38); // 8Bit-IF, 2 Lines, 5x7 character font
while(--cnt);
LCDWriteCmd(0x0c); // DisplayOn, CursorOff, BlinkingOff
LCDReadStatus();
LCDWriteCmd(0x06); // Enter Mode, AutoIncrement
LCDReadStatus();
LCDWriteCmd(0x14); // MoveCursor right
LCDReadStatus();
LCDWriteCmd(0x80); // Set DD RAM Address = 0x00
LCDReadStatus();
}
// writesomedata from 1st position in #line (0/1)
void LCDWriteLine(u8 line, u8 *data)
{
LCDWriteCmd(0x80 + line*0x40);// select line
while (*data)
{