Download Print this page

Renesas Asynchronous SH7145F Application Note page 15

Asynchronous serial data transmission/reception

Advertisement

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

Advertisement

loading