Hitach i Europ e Lt d . ISS UE : A PPS /55/1.0
3 of 20
ITU Channel 2 counts up to 160 rows (1 complete frame) and then outputs the FLM (first line marker) to tell
the LCD driver to reset to row 1. It also causes a CPU interrupt which resets the DMA source address to the
beginning of LCD RAM. This re-starts the display of the frame.
ITU Channel 3 counts up to 9 rows and then toggles the M (drive invert) pin which ensures that the overall
drive to the LCD has no DC offset.
Once the ITU, TPC and DMA have been setup, the only task the CPU needs to do is to reset the DMA address
and count at the end of each frame. This translates to a small Interrupt service Routine which will be called
every 13mS. *Note that the DMA minimum transfer word size is 8 bits. This means only 4 bits of each transfer
are valid. Consequently The LCD RAM allocated is twice the size (240 x 160 / 8 x 2 = 9600 bytes) of the
actual data required. The upper 4 bits of each byte are valid and the bottom 4 bits are don’t care. The lower 4
bits could be used to save a second frame and a simple “swap” function could be written to swap the nibbles in
the LCD RAM to switch between screens.
The rest of the code provides a simple demonstration of the panel and SH7032 working together. By
connecting a serial link between SCI0 (User Serial Port) and a host PC running a terminal emulator (19200
bps, 8data bits, no parity) such as Windows™ Terminal, it is possible to download pictures and perform some
of simple graphics commands. (note the command letters must be in lower case)
The operation is as follows.
• c - clear screen
• t - draw a spiral. This is done using a for loop, floating point sin & cos and the plot
function contained in USERCODE.C
• i - Invert screen. This swaps pixels from 1 to 0 and vice versa
• y - Switch display on. This enables DISP ON and VEEON lines, all of the timers and
the DMA transfer of data to the TPC.
• n - Switches the display off. Disables the functions as described as above. This feature
is useful for comparing execution time of code with the display on and off
• downloading pictures
Specially converted pictures may be downloaded over the terminal. The format is described
in section 4 of this application note (graphics file conversion). To download the picture simply
select “SEND TEXT FILE” ,click on your selected file to download and click OK. The
picture takes approximately 5 seconds to download at 19200 baud.
*Remember to set the program counter to the reset vector value (contained at H’A00 0000) before executing
the program.
Section 2 - SH1 / 7032 Code generation
To dramatically ease the SH7032 code generation process the following support tools were used:-
• Hitachi Work Bench. This is an application development environment which provides the user
with a code editing front end and project building facilities. This significantly simplifies and
speeds up code generation where many source files are used. It generates all of the necessary
command line switches and calls the compiler/assembler/librarian/linker for the relevant source
files automatically.
• Stenkil MakeApp. With the continuing improvements of on chip peripherals for embedded
microcontrollers, it becomes necessary to use additional code generation tools to help set up the
associated registers with each peripherals. This utility generates all of the required initialisation
code and access functions (eg. interrupt handlers) in C - source format. It also supports rule
checking such illegal settings (eg. two functions for one pin) are not accidentally selected.
• Hitachi/MCS Super H C-Compiler. The EVB7032 as standard comes supplied with a free copy
of the Cygnus/Gnu compiler which is supported by third parties. The compiler used for this
application note is the Hitachi/MCS compiler which is sold and supported by Hitachi Europe Ltd.
It is an optimising C-compiler/assembler/Librarian and linker code generation tool. It also has the
benefit of being compatible with Hitachi Workbench above.