This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F28377D: 官方例程配置uart与串口助手通讯不成功

Part Number: TMS320F28377D
Other Parts Discussed in Thread: C2000WARE

在官方例程里面用了SCID,引脚配置按照datasheet 配置,但是就是通讯不上,串口助手一直显示接收为空,新手上路,请问是什么原因

#include "F28x_Project.h" // Device Headerfile and Examples Include File

// Prototype statements for functions found within this file.
void scid_echoback_init(void);
void scid_fifo_init(void);
void scid_xmit(int a);
void scid_msg(char *msg);

// Global counts used in this example
Uint16 LoopCount;
#define RX_EN GpioDataRegs.GPACLEAR.bit.GPIO15 = 1;
#define TX_EN GpioDataRegs.GPASET.bit.GPIO15 = 1;
void main(void)
{

Uint16 ReceivedChar;
char *msg;

// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the F2837xS_SysCtrl.c file.
InitSysCtrl();

// Step 2. Initialize GPIO:
// This example function is found in the F2837xS_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
InitGpio();

// For this example, only init the pins for the SCI-A port.
// GPIO_SetupPinMux() - Sets the GPxMUX1/2 and GPyMUX1/2 register bits
// GPIO_SetupPinOptions() - Sets the direction and configuration of the GPIOS
// These functions are found in the F2837xS_Gpio.c file.
/* Enable PLL */
EALLOW;
CpuSysRegs.PCLKCR7.bit.SCI_D = 1U;
EDIS;

/* Init the pins for the SCI-D port. */
GPIO_SetupPinMux(94U, GPIO_MUX_CPU1, 6U);
GPIO_SetupPinOptions(94U, GPIO_INPUT, GPIO_PUSHPULL); /* SCI-D_RX */
GPIO_SetupPinMux(93U, GPIO_MUX_CPU1, 6U);
GPIO_SetupPinOptions(93U, GPIO_OUTPUT, GPIO_PUSHPULL); /* SCI-D_TX */
EALLOW;

GpioCtrlRegs.GPAMUX1.bit.GPIO15 = 0;
GpioCtrlRegs.GPAPUD.bit.GPIO15 = 0;
GpioCtrlRegs.GPADIR.bit.GPIO15 = 1;
GpioDataRegs.GPACLEAR.bit.GPIO15 = 1;

EDIS;

// Step 3. Clear all __interrupts and initialize PIE vector table:
// Disable CPU __interrupts
DINT;

// Initialize PIE control registers to their default state.
// The default state is all PIE __interrupts disabled and flags
// are cleared.
// This function is found in the F2837xS_PieCtrl.c file.
InitPieCtrl();

// Disable CPU __interrupts and clear all CPU __interrupt flags:
IER = 0x0000;
IFR = 0x0000;

// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
// This will populate the entire table, even if the __interrupt
// is not used in this example. This is useful for debug purposes.
// The shell ISR routines are found in F2837xS_DefaultIsr.c.
// This function is found in F2837xS_PieVect.c.
InitPieVectTable();

// Step 4. User specific code:

LoopCount = 0;

scid_fifo_init(); // Initialize the SCI FIFO
scid_echoback_init(); // Initialize SCI for echoback

msg = "\r\n\n\nHello World!\0";
scid_msg(msg);

msg = "\r\nYou will enter a character, and the DSP will echo it back! \n\0";
scid_msg(msg);

for(;;)
{
msg = "\r\nEnter a character: \0";
scid_msg(msg);

// Wait for inc character
while(ScidRegs.SCIFFRX.bit.RXFFST == 0) { } // wait for XRDY =1 for empty state

// Get character
ReceivedChar = ScidRegs.SCIRXBUF.all;

// Echo character back
msg = " You sent: \0";
scid_msg(msg);
scid_xmit(ReceivedChar);

LoopCount++;
}

}

// Test 1,SCIA DLB, 8-bit word, baud rate 0x000F, default, 1 STOP bit, no parity
void scid_echoback_init()
{
// Note: Clocks were turned on to the SCIA peripheral
// in the InitSysCtrl() function
// unsigned long u32BRR = 0UL;
ScidRegs.SCICCR.all =0x0007; // 1 stop bit, No loopback
// No parity,8 char bits,
// async mode, idle-line protocol
ScidRegs.SCICTL1.all =0x0003; // enable TX, RX, internal SCICLK,
// Disable RX ERR, SLEEP, TXWAKE
ScidRegs.SCICTL2.all =0x0003;
ScidRegs.SCICTL2.bit.TXINTENA =1;
ScidRegs.SCICTL2.bit.RXBKINTENA =1;

//
// SCIA at 9600 baud
// @LSPCLK = 50 MHz (200 MHz SYSCLK) HBAUD = 0x02 and LBAUD = 0x8B.
// @LSPCLK = 30 MHz (120 MHz SYSCLK) HBAUD = 0x01 and LBAUD = 0x86.
//
ScidRegs.SCIHBAUD.all =0x0002;
ScidRegs.SCILBAUD.all =0x008B;
// u32BRR = (200000000/ (115200UL * 8UL) );

// ScidRegs.SCIHBAUD.all = (u32BRR & 0x0000FF00UL) >> 8;
//ScidRegs.SCILBAUD.all = u32BRR & 0x000000FFUL;

ScidRegs.SCICTL1.all =0x0023; // Relinquish SCI from Reset
}

// Transmit a character from the SCI
void scid_xmit(int a)
{
while (ScidRegs.SCIFFTX.bit.TXFFST != 0) {}
ScidRegs.SCITXBUF.all =a;
}

void scid_msg(char * msg)
{
int i;
i = 0;
TX_EN;
while(msg[i] != '\0')
{
scid_xmit(msg[i]);
i++;
}
RX_EN;
}

// Initialize the SCI FIFO
void scid_fifo_init()
{
ScidRegs.SCIFFTX.all=0xE040;
ScidRegs.SCIFFRX.all=0x2044;
ScidRegs.SCIFFCT.all=0x0;
}