IBM H8 user manual Sci, Isscitxfree

Page 39

HTEB1

User manual

3.3 SCI

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

 

 

#define

CK_INT

0x00

 

 

#define

CK_INT_OUT

0x01

 

 

#define

CK_EXT

0x02

 

 

#define

IS_SCI_RDF

 

(SSR & 0x40)

 

#define

CLEAR_SCI_RDF

SSR = (SSR & ~0x40)

#define

IS_SCI_TX_FREE

(SSR & 0x80)

 

#define

V24_BRR(x)

((unsigned char)(((CPU_CLK+16*x)/32/x) - 1))

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 =

(TERECK_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.2

Page 39

07/2002

Image 39
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