2368 views|1 replies

3836

Posts

19

Resources
The OP
 

TMS320F28379D User Experience SCI [Copy link]

1. Introduction to SCI
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. It is a universal asynchronous communication interface UART, which has basically the same asynchronous communication function as MCS-51. (The above content comes from Baidu)

2. Introduction to the SCI module of 28379D
2.1 Module functions
Basically, it is UART, and the data format is programmable. The SCI of 28398D is basically the same as other 28 series products, with two enhanced functions. One is the transmit and receive buffer, FIFO. If the transmit FIFO is enabled, the bytes to be sent can be stored in the transmit FIFO first, and then sent out together after the number of bytes in the transmit FIFO reaches the set upper limit. If the receive FIFO is enabled, the received bytes can be stored in the receive FIFO first, and then an interrupt is generated to process the received data after the number of bytes in the receive FIFO reaches the set upper limit. The other is the baud rate automatic detection function, which is generally not used.


2.2 SCI module pins of 28379D 28379D
has 4 SCIs, namely SCIA, SCIB, SCIC, and SCID. Each SCI has many sending and receiving pins, as shown in the following table:

3. SCI Configuration Steps
3.1 Configure GPIO
Configure the corresponding GPIO as the multiplexed pin of SCIx.


3.2 Configure the data format of SCI
Configure the data format for sending and receiving, generally: 1 stop bit, no parity check, no loopback, idle line mode (communication between two objects, if there are three or more, address line mode must be used), 8 data bits.


3.3 Configure baud rate
Configure baud rate, no more details.


3.4 Configuring FIFO
First, you need to enable FIFO, and then configure it as needed. For example, enable the receive FIFO interrupt, set the number of FIFO levels, and that's the basics. You can also configure some settings for baud rate self-test, but it's generally not used.


3.5 Enable SCI
reset Some flags, such as SWRESET in the SCICTL1 register, must be set to 1, etc.


3.6 Configure PIE
First enable PIE, then modify the PIE vector table, and then enable the corresponding PIE and CPU interrupts.


4. Code Example
The example uses SCIB, and the pin uses GPIO18 as Tx and GPIO19 as Rx.
4.1 Configure GPIO

EALLOW;
GpioCtrlRegs.GPAPUD.bit.GPIO18=0;//Turn on the pull-up resistor
GpioCtrlRegs.GPAPUD.bit.GPIO19=0;//Turn on the pull-up resistor
GpioCtrlRegs.GPADIR.bit.GPIO19=0;
GpioCtrlRegs.GPADIR.bit.GPIO18=1;
GpioCtrlRegs.GPAGMUX2.bit.GPIO18=0;
GpioCtrlRegs.GPAGMUX2.bit.GPIO19=0;
GpioCtrlRegs.GPAMUX2.bit.GPIO18=2;//Multiplexed as the output of SCIB
GpioCtrlRegs.GPAMUX2.bit.GPIO19=2;//Multiplexed as the input
EDIS of SCIB;

4.2 Configuration Data Format

ScibRegs.SCICCR.all = 0x0007; //1 stop bit, no parity check, no loopback test, idle line mode, 8 data bits

4.3 Configuring the baud rate

ScibRegs.SCIHBAUD.bit.BAUD=0x0000;//Baud rate 115200
ScibRegs.SCILBAUD.bit.BAUD=0x0036;//Baud rate 115200

4.4 Configuring FIFO

ScibRegs.SCIFFTX.bit.SCIFFENA = 1; // Enable FIFO
ScibRegs.SCIFFRX.bit.RXFFIENA = 1; // Enable FIFO receive interrupt
ScibRegs.SCIFFRX.bit.RXFFIL = 1; // FIFO receives byte 1
ScibRegs.SCIFFCT.all = 0x0;

4.5 Re-enabling SCI

ScibRegs.SCICTL1.all =0x0023; // Relinquish SCI from Reset restart sci

4.6 Configuring PIE

PieCtrlRegs.PIECTRL.bit.ENPIE = 1; //Enable PIE
EALLOW;
PieVectTable.SCIB_RX_INT=&ScibInterrupt; //Modify interrupt vector table
EDIS;
PieCtrlRegs.PIEIER9.bit.INTx3 = 1; //Enable PIE interrupt
IER |= M_INT9; //Enable CPU interrupt

4.7 The receive interrupt function ScibInterrupt is as follows:

interrupt void ScibInterrupt(void)
{
int i=0,data;
for(i=0;i<ScibLegnth;i++)
{
data=ScibRegs.SCIRXBUF.bit.SAR;//Received data
}
ScibRegs.SCIFFRX.bit.RXFFINTCLR=1; // Clear receive interrupt flag
PieCtrlRegs.PIEACK.all|=PIEACK_GROUP9; // Clear receive interrupt flag
}

4.8 Emission Function

int ScibSend(int data)
{
while (ScibRegs.SCIFFTX.bit.TXFFST != 0) {}
ScibRegs.SCITXBUF.bit.TXDT=0x06;
return 0;
}
5. Note

1. Please check the configuration of your project to see if the system clock is 200M. If not, the baud rate is incorrect. For specific configuration methods, please refer to Baidu

2. The code in this article is based on the hardware TMS320F28379D. If you are using other hardware, the code generally cannot be used.

This post is from Microcontroller MCU

Latest reply

The launch function... This translates   Details Published on 2020-11-9 22:17
 

7422

Posts

2

Resources
2
 

The launch function... This translates

This post is from Microcontroller MCU
 
Personal signature

默认摸鱼,再摸鱼。2022、9、28

 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews

Room 1530, Zhongguancun MOOC Times Building, Block B, 18 Zhongguancun Street, Haidian District, Beijing 100190, China Tel:(010)82350740 Postcode:100190

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