#include <3052f.h>
void main(void)
{
int i;
SCI1.SCR.BYTE=0; /* stop SCI1, internal clock use */
SCI1.SMR.BYTE=0; /* async. mode, 8data, 1stop, no-parity */
SCI1.BRR=40; /* 19200bps */
for( i = 220 ; i > 0 ; i--); /* wait 1bit transfer time */
SCI1.SCR.BYTE = 0x30; /* enable Tx & Rx, disable interrupt */
SCI1.SSR.BYTE &amp;amp;= 0x80; /* clear receive error flag all */
for(i=0;i<26;i++){ /* send 'ABC--XYZ' */
while(!SCI1.SSR.BIT.TDRE); /* send enable? */
SCI1.TDR='A'+i;
SCI1.SSR.BIT.TDRE = 0; /* now data sending */
}
while(!SCI1.SSR.BIT.RDRF); /* data recieve? */
SCI1.SSR.BIT.RDRF = 0; /* clear receive data flag */
SCI1.TDR=SCI1.RDR; /* echo back */
SCI1.SSR.BIT.TDRE = 0; /* now data sending */
while(!SCI1.SSR.BIT.TDRE);
SCI1.TDR = 0x0a; /* yes then send
SCI1.SSR.BIT.TDRE = 0;
} }
}
No comments:
Post a Comment