![Renesas Asynchronous SH7145F Скачать руководство пользователя страница 15](http://html1.mh-extra.com/html/renesas/asynchronous-sh7145f/asynchronous-sh7145f_application-note_1439948015.webp)
SH7145F
Asynchronous Serial Data Transmission/Reception
REJ06B0357-0100O/Rev.1.00
March 2004
Page 15 of 17
Function
: init_sci
Operation : Initialize serial (sci1)
Asynchronous receive operation
-Data
: 8bit
-Stop bit
: 1bit
-Parity bit : No
**************************************************************/
void init_sci(void)
{
unsigned long i;
P_STBY.MSTCR1.BIT.MSTP17 = 0;
/* disable SCI1 standby mode
*/
/* Initialize SCI Asynchronous mode *
*/
P_SCI1.SCR_1.BYTE &= 0x03 ;
/* clear TIE,RIE,TE,RE,MPIE,TEIE
*/
P_SCI1.SCR_1.BIT.CKE = 0;
/* clock:internal,SCK:output
*/
P_SCI1.SMR_1.BYTE = 0x00;
/* 8bit,No parity,1stop bit
*/
//
CA = 0;
/* Asynchronous mode
*/
//
CHR = 0;
/* data length 8bits
*/
//
PE = 0;
/* No parity
*/
//
OE = 0;
/* (=0)even parity
*/
//
STOP = 0;
/* 1 stop bit
*/
//
CKS = 0;
/* clock source=P
φ
(25MHz)
*/
P_SCI1.BRR_1 = 40;
/* 19200bps@25MHz(Peripheral)
*/
P_SCI1.SDCR_1.BIT.DIR = 0;
/* LSB first send
*/
for( i=0; i < 0x0300 ; i++);
/* Wait 1bit
*/
P_SCI1.SCR_1.BIT.TIE = 0;
/* TXI1 interrupt disable
*/
P_SCI1.SCR_1.BIT.RIE = 0;
/* RXI1,ERI interrupt disable
*/
/* Initialize SCI1 PORT
*/
P_PORTA.PACRL2.BIT.PA4MD = 1;
/* set TXD1(PA4:134pin@SH7145)
*/
P_PORTA.PACRL2.BIT.PA3MD = 1;
/* set RXD1(PA3:133pin@SH7145)
*/
P_SCI1.SCR_1.BYTE |= 0x30;
/* TE=RE=1,Transmit and Receive Enable */
}
/******************************************************************************/
/*
Function
: rcv_sci
*/
/*
Operation
: Serial data receive and send function calls
*/
/*
Argument
: None
*/
/*
Value returned : None
*/
/******************************************************************************/
unsigned char rcv_sci(unsigned char rev_count)
{
while(P_SCI1.SSR_1.BIT.RDRF == 0);
/* Wait until reception finishes
*/
Rev_data[rev_count] = P_SCI1.RDR_1;
/* get receive data
*/