SCC Application Notes
7-19
AMD
/*********************************************************************
/* Initializing the Z8530 asynchronuously
/* (using pointer referring to memory map I/O device)
/**************************************************************************
#include
#define
#define
#define
#define
#define
"stdio.h"
spaddress
dpaddress
rxbit
txbit
tablesize
0x22FS5
0x22F87
2
1
16
/* status port address */
/* dataport address */
/* receive ready bit */
/* transmit ready bit */
main ()
{
unsigned char table[tablesize];
unsigned long *ptspa, *ptdpa;
unsigned char value;
int i;
/* data table for initialization */
table[0]=0x9;
table[l]=0xC0;
table[2]=0x3;
table[3]=0x41;
table[4]=0x4;
table[5]=0x4C;
table[6]=0x5;
table[7]=0x28;
table[8]=0xB.
table[9]=0x56;
table[l0]=0xC;
table[ll]=0xC;
table[l2]=0xD;
table[13]=0;
table[l4]=0xE;
table[l5]=0x7;
/* address WR9 */
/* hardware reset SCC */
/* address WR3 */
/* set # of bits etc. */
/* address WR4 */
/* misc mode */
/* address WR5 */
/* bits/char and TXEN */
/* address WRIi */
/* select baud generator */
/* address WR12 */
/* upper TC */
/* address WR13 */
/* lower TC */
/* address WR14 */
/* set DTR/REQ enable baud generator */
/* output data from table to perfore initialization */
ptspa=spaddress;
ptdpa=dpaddress;
value=*ptspa; /* read status to set the set state machine */
for (i--0; i<tablesize; i++) /* perform initialization */
*ptspa=table[i];
/* pointer to status port address */
/* pointer to data port address */
/* receive and echo character routine */
for ( ;;)
{
while (((*ptspa) & rxbit) == 0); /* wait for receive ready bit */
value=*ptdpa;
while (((*ptspa) & txbit) == 0); /* wait for transmit ready bit */
*ptdpa--value'
/* receive character */
/* transmit character */
Figure 7-10. SCC Initialization - Memory Mapped