Intel 8XC196NT User Manual page 191

Table of Contents

Advertisement

8XC196NT USER'S MANUAL
#define TRANSMIT_BUF_SIZE 20
#define RECEIVE_BUF_SIZE 20
#define WINDOW_SELECT
#define FREQUENCY (long)16000000
#define BAUD_RATE_VALUE 9600
#define BAUD_REG ((unsigned int)(FREQUENCY/((long)BAUD_RATE_VALUE*16)-1)+0x8000)
#define RI_BIT
0x40
#define TI_BIT
0x20
unsigned char status_temp;
/*
image of SP_STATUS to preserve the RI and TI bits on a read.
/*
receive and transmit buffers and their indexes
unsigned char trans_buff[TRANSMIT_BUF_SIZE];
unsigned char receive_buff[RECEIVE_BUF_SIZE];
char begin_trans_buff,end_trans_buff;
char end_rec_buff,begin_rec_buff;
/*
declares and locates the special function registers
volatile register unsigned char port2_reg, port2_dir, port2_mode;
volatile register unsigned char wsr;
volatile unsigned char sbuf_tx, sbuf_rx, SP_STATUS, sp_con;
volatile unsigned char int_mask1, int_pend1;
volatile unsigned int sp_baud;
#pragma locate(sbuf_tx=0xba,sbuf_rx=0xb8,SP_STATUS=0xb9h)
#pragma locate(sp_con=0xbb,sp_baud=0xbc)
#pragma locate(int_mask1=0x13,int_pend1=0x12)
#pragma locate(wsr=0x14)
#pragma locate(port2_reg = 0xcd)
#pragma locate(port2_dir = 0xcb)
#pragma locate(port2_mode = 0xc9)
void transmit(void)
{
wsr = WINDOW_SELECT;
status_temp |= SP_STATUS;
/*
transmit a character if there is a character in the buffer
if(begin_trans_buff!=end_trans_buff)
{
sbuf_tx=trans_buff[begin_trans_buff];
/*
The next statement makes the buffer circular by starting over when the
index reaches the end of the buffer.
if(++begin_trans_buff>TRANSMIT_BUF_SIZE - 1)begin_trans_buff=0;
status_temp &= (~TI_BIT);
}
}
7-14
0x1F
/* 16 MHz
/*
serial interrupt routine
/*
image SP_STATUS into status_temp
/*
clear TI bit in status_temp.
*/
*/
*/
*/
/*
transmit character
*/
*/
*/
*/
*/
*/

Advertisement

Table of Contents
loading

Table of Contents