3027 views|3 replies

6547

Posts

0

Resources
The OP
 

TMS320F28335——SCI serial port [Copy link]

1. IO Configuration

  Taking SCIA as an example: GPIO35--SCITXDA GPIOA36--SCIRXDA is used

  Using registers:

  GPBPUD: Set pull-up GPIO32-GPIO63 corresponding bit 0 enables pull-up

  GPBQSEL1:

  GPBMUX1: IO mode selection

  The code is as follows:

GpioCtrlRegs.GPBPUD.bit.GPIO36 = 0; // Enable pull-up for GPIO28 (SCIRXDA) //Enable internal pull
-up GpioCtrlRegs.GPBPUD.bit.GPIO35 = 0; // Enable pull-up for GPIO29 (SCITXDA) //Enable internal pull-up
GpioCtrlRegs.GPBQSEL1.bit.GPIO36 = 3; // Asynch input GPIO28 (SCIRXDA) //Set to asynchronous input mode

GpioCtrlRegs.GPBMUX1.bit.GPIO36 = 1; // Configure GPIO28 for SCIRXDA operation //Configure as peripheral mode
GpioCtrlRegs.GPBMUX1.bit.GPIO35 = 1; // Configure GPIO29 for SCITXDA operation //Configure as peripheral mode
Set FIFO register:

  

Copy code
void scia_fifo_init()
{
SciaRegs.SCIFFTX.all=0xE040;//Enable FIFO; Clear the transmit interrupt flag; Disable FIFO transmit interrupt;
//The transmit interrupt level is defined as 0;
SciaRegs.SCIFFRX.all=0x204f;//Clear FIFO overflow flag; Clear overflow receive interrupt flag; Disable
//FF receive interrupt; The receive interrupt level is 16;
SciaRegs.SCIFFCT.all=0x0;//SCITXBUF to shift register transfer without delay

}
Copy code
Set SCI related registers: Register description see http://www.ti.com/lit/ug/sprufz5a/sprufz5a.pdf

Copy code
void scia_echoback_init()
{
// Note: Clocks were turned on to the SCIA peripheral
// in the InitSysCtrl() function

SciaRegs.SCICCR.all =0x0007; // 1 stop bit, No loopback
// No parity,8 char bits,
// async mode, idle-line protocol
SciaRegs.SCICTL1.all =0x0003; // enable TX, RX, internal SCICLK,
// Disable RX ERR, SLEEP, TXWAKE
SciaRegs.SCICTL2.all =0x0003;
SciaRegs.SCICTL2.bit.TXINTENA =1;//Enable receive interrupt
SciaRegs.SCICTL2.bit.RXBKINTENA =1;//Enable transmit interrupt
# if (CPU_FRQ_150MHZ)
SciaRegs.SCIHBAUD =0x0001; // 9600 baud @LSPCLK = 37.5MHz.
SciaRegs.SCIHBAUD =0x00E7;
#endif
#if (CPU_FRQ_100MHZ)
SciaRegs.SCIHBAUD =0x0001; // 9600 baud @LSPCLK = 20MHz.
SciaRegs.SCILBAUD =0x0044;
#endif
SciaRegs.SCICTL1.all =0x0023; // Relinquish SCI from Reset
}
Copy code
Baud rate calculation method:

A byte occurs:

  

void scia_xmit(int a)
{
while (SciaRegs.SCIFFTX.bit.TXFFST != 0) {}
SciaRegs.SCITXBUF=a;

}
Use SICA to send and serial port interrupt to receive:

  The configuration parameters are as follows:

  

Copy code
static void Init_SCI_A(Uint32 Baud)
{
//Init IO
Uint16 BRR=0;
EALLOW;
GpioCtrlRegs.GPBPUD.bit.GPIO36 = 0; // Enable pull-up for GPIO28 (SCIRXDA)
GpioCtrlRegs.GPBPUD.bit.GPIO35 = 0; // Enable pull-up for GPIO29 (SCITXDA)
GpioCtrlRegs.GPBQSEL1.bit.GPIO36 = 3; // Asynch input GPIO28 (SCIRXDA)
GpioCtrlRegs.GPBMUX1.bit.GPIO36 = 1; // Configure GPIO28 for SCIRXDA operation
GpioCtrlRegs. GPBMUX1.bit.GPIO35 = 1; // Configure GPIO29 for SCITXDA operation
EDIS;

//set RX interrput function
EALLOW;
PieVectTable.SCIRXINTA = &SciaRxIsr;
EDIS;

//set SCIA register
SciaRegs.SCICCR.all =0x0007; // 1 stop bit, No loopback
// No parity,8 char bits,
// async mode, idle-line protocol
SciaRegs.SCICTL1.all =0x0003; // enable TX, RX, internal SCICLK,
// Disable RX ERR, SLEEP, TXWAKE
SciaRegs.SCICTL2.bit.TXINTENA =0;//close TX interrput
SciaRegs.SCICTL2.bit.RXBKINTENA =1;
//set Baud BRR= LSPCLK/( Baud*8)-1
BRR = SCI_LSPCLK/(Baud*8)-1;
SciaRegs.SCIHBAUD = (BRR>>8); // 9600 baud @LSPCLK = 37.5MHz.
SciaRegs.SCILBAUD = (BRR&0x00ff);
// SciaRegs.SCIHBAUD =0x0001; // 9600 baud @LSPCLK = 37.5MHz.
// SciaRegs.SCILBAUD =0x00E7;
SciaRegs.SCICTL1.all =0x0023; // Relinquish SCI from Reset

EALLOW;
//set SCI interrput Group
PieCtrlRegs.PIECTRL.bit.ENPIE = 1; // Enable the PIE block
PieCtrlRegs.PIEIER9.bit.INTx1=1; // PIE Group 9, int1 enable SCIA_RX
//PieCtrlRegs.PIEIER9.bit.INTx2=1; // PIE Group 9, INT2 enable SCIA_TX
EDIS;
}
Copy code
  Send data code:

  

Copy code
//send one byte data
static void scia_xmit(int a)
{
while (SciaRegs.SCIFFTX.bit.TXFFST != 0) {}
SciaRegs.SCITXBUF=a;
}

//send string
void scia_msg(char * msg)
{
int i;
i = 0;
while(msg != '\0')
{
scia_xmit(msg);
i++;
}
}

image.png (45.65 KB, downloads: 0)

image.png
This post is from DSP and ARM Processors

Latest reply

Is SCI also a serial port? Is it the same as UART?   Details Published on 2020-1-6 13:41
 

2618

Posts

0

Resources
2
 

Nice sharing, thank you

This post is from DSP and ARM Processors
 
 

7170

Posts

195

Resources
3
 

Is SCI also a serial port? Is it the same as UART?

This post is from DSP and ARM Processors

Comments

SCI (Serial Communication Interface) means "serial communication interface", which is a general term for serial communication technology relative to parallel communication. It was first proposed by Motorola. UART (Universal Asynchronous Receiver & Transmitter) is a serial communication interface.  Details Published on 2020-1-6 16:21
 
 
 

6547

Posts

0

Resources
4
 
Common Ze 1 posted on 2020-1-6 13:41 Is SCI also a serial port? Is it the same as UART?

SCI (Serial Communication Interface) means "serial communication interface", which is a general term for serial communication technology relative to parallel communication and was first proposed by Motorola.
UART (Universal Asynchronous Receiver & Transmitter) is a protocol for serial communication, which specifies the baud rate, start/stop bit, data bit, check bit format, and various asynchronous handshake signals of serial communication.

This post is from DSP and ARM Processors
 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list