Intel 8XC196K Series User Manual page 177

Table of Contents

Advertisement

8XC196K x , J x , CA USER'S MANUAL
void receive(void)
{
wsr = WINDOW_SELECT;
status_temp |= SP_STATUS;
/*
If the input buffer is full, the last character will be ignored,
and the BEL character is output to the terminal.
if(end_rec_buff+1==begin_rec_buff || (end_rec_buff==RECEIVE_BUF_SIZE-1 &&
!begin_rec_buff))
{
;
/*
input overrun code
}
else
{
/*
The next statement makes the buffer circular by starting over when the
index reaches the end of the buffer.
if(++end_rec_buff > RECEIVE_BUF_SIZE - 1) end_rec_buff=0;
receive_buff[end_rec_buff]=sbuf_rx;
}
status_temp &= (~RI_BIT);
int putchar(int c)
{
/*
remain in loop while the buffer is full.
the end of buffer index to make sure it does not overrun the
beginning of buffer index.
when the end index is one less than the beginning index and at the
end of the buffer when the beginning index may be equal to 0 and
the end buffer index may be at the buffer end.
while((end_trans_buff+1==begin_trans_buff)||
(end_trans_buff==TRANSMIT_BUF_SIZE -1 && !begin_trans_buff));
trans_buff[end_trans_buff]=c;
if(++end_trans_buff>TRANSMIT_BUF_SIZE - 1)
end_trans_buff=0;
if(status_temp & TI_BIT) int_pend1 |= 0x08;
}
unsigned char getchar()
{
while(begin_rec_buff==end_rec_buff);
if(++begin_rec_buff>RECEIVE_BUF_SIZE - 1)
begin_rec_buff=0;
return(receive_buff[begin_rec_buff]);
main()
{
char c;
wsr=WINDOW_SELECT;
sp_baud = BAUD_REG;
sp_con = 0x09;
status_temp=SP_STATUS;
7-16
/*
serial interrupt routine
/*
image SP_STATUS into status_temp
*/
/*
clear RI bit in status_temp.
The while instruction checks the case
/* set baud rate as described in Figure 7-7 on page 7-10*/
/* mode 1, no parity, receive enabled, no 9th bit */
*/
*/
/*
place character in buffer
This is done by checking
*/
/*
put character in buffer
/*
make buffer appear circular */
/* If transmit buffer was empty,
then cause an interrupt to
start transmitting.
/*
remain in loop while there is
not a character available. */
/*
make buffer appear circular */
/*
return the character in buffer */
*/
*/
*/
*/
*/
*/

Advertisement

Table of Contents
loading

Table of Contents