Home > other >  DSP28377d SCI communication RXBUF used to be deposited in the data
DSP28377d SCI communication RXBUF used to be deposited in the data

Time:11-22



Configure the following

/*
C
* sci.*
* Created on: on July 25, 2020,
* the Author: 25446
*/


# include "RS485. H"

//interrupt void ScibInterrupt ();
Void RS485_Init (Uint16 baud)
{


EALLOW;
CpuSysRegs. PCLKCR7. Bit. SCI_B=1;//can make GPIO clock
EDIS.

//GPIO initialization
EALLOW;

GpioCtrlRegs. GPAPUD. Bit. GPIO18=0;//open the pull mode
GpioCtrlRegs. GPAPUD. Bit. GPIO19=0;//open the pull mode
GpioCtrlRegs. GPADIR. Bit. GPIO19=0;//RX set to enter
GpioCtrlRegs. GPADIR. Bit. GPIO18=1;//TX output is set to
GpioCtrlRegs. GPAGMUX2. Bit. GPIO18=0;
GpioCtrlRegs. GPAGMUX2. Bit. GPIO19=0;
GpioCtrlRegs. GPAMUX2. Bit. GPIO18=2;//reuse for the output of the SCIB
GpioCtrlRegs. GPAMUX2. Bit. GPIO19=2;//reuse for the SCIB input
EDIS.


//GPIO initialization
EALLOW;
GpioCtrlRegs. GPBMUX2. Bit. GPIO57=0;
GpioCtrlRegs. GPBDIR. Bit. GPIO57=1;
GpioCtrlRegs. GPBPUD. Bit. GPIO57=0;
GpioDataRegs. GPBSET. Bit. GPIO57=1;
EDIS.

EALLOW;
//data format configuration
ScibRegs. SCICCR. All=0 x0007;//a stop bit and white parity 8 bits of data no address



//the interrupt Settings
ScibRegs. SCICTL1. All=0 x0003;//SCI to send and receive to awaken SCI

ScibRegs. SCICTL2. All=0 x0003;//can make rx interrupt
ScibRegs. SCICTL2. Bit. TXINTENA=1;//ban send interrupt
ScibRegs. SCICTL2. Bit. RXBKINTENA=1;//that can receive interrupt
ScibRegs. SCICTL1. All=0 x0023;//SCI to send and receive to awaken SCI

//configuration baud rate
ScibRegs. SCIHBAUD. All=0 x0000;
ScibRegs. SCILBAUD. All=0 x0035;//set the baud rate of 9600

SciaRegs. SCIFFTX. All=0 xe040;
SciaRegs. SCIFFRX. All=0 x2044;
SciaRegs. SCIFFCT. All=0 x0;


EDIS.




}


Void RS485_SendByte (int data)//send a single
{

//while (ScibRegs SCICTL2. Bit. TXRDY!=1);
While (ScibRegs. SCIFFTX. Bit TXFFST!=0);
ScibRegs. SCITXBUF. All=data;//0 - seven data

}

Void RS485_SendString (char * MSG)//send the string
{
int i;
I=0;
While (MSG [I]!='\ 0')
{
RS485_SendByte (MSG [I]);
i++;
}
}

CodePudding user response:

PC has been sending data
  • Related