beautypg.com

Init_uart, Kbhit – Zilog Z8F0130 User Manual

Page 256

background image

Using the ANSI C-Compiler

UM013037-1212

232

Zilog Developer Studio II – Z8 Encore!
User Manual

init_uart

The

init_uart

function is a Zilog function that selects the specified UART and initial-

izes it for specified settings and returns the error status.

Synopsis

#include

int init_uart(int port, unsigned long freq, unsigned long baud);

Returns

Returns 0 if initialization is successful and 1 otherwise.

Example

#include

#include

void main()

{

init_uart(_UART0,_DEFFREQ,_DEFBAUD);

printf("Hello UART0\n"); // Write to _UART0

}

_DEFFREQ is automatically set from the IDE based on the clock frequency setting in the

Configure Target

dialog box. See the

Setup

section on page 111.

kbhit

The

kbhit

function is a Zilog function that determines whether there is receive data avail-

able on the selected UART.

Synopsis

#include

unsigned char kbhit( void ) ;

Returns

Returns 1 if there is receive data available on the selected UART; otherwise, it returns 0.

Example

#include

unsigned char hit;

void main()

{

init_uart(_UART0,_DEFFREQ,_DEFBAUD);

hit = kbhit( ) ; // Check if any character available on _UART0

}