TI中文支持网
TI专业的中文技术问题搜集分享网站

在C28x中用SCI发送数组不显示的问题

程序是这样的

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

//#define _STANDALONE
//#define _FLASH

// Prototype statements for functions found within this file.
void InitSciGpio();
void scia_echoback_init(void);void scia_fifo_init(void);
void scia_xmit(int a);void scia_msg(char *msg);

int SdataA[]={1,2,3,4,5,6,7,8};

void main(void)
{

char *msg;
int i;

InitSysCtrl();

InitGpio();
InitSciGpio();

DINT; // Disable CPU interrupts

InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;

InitPieVectTable();

scia_fifo_init(); // Initialize the SCI FIFO
scia_echoback_init(); // Initalize SCI for echoback

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

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

for(i=0;i<8;i++)
{
msg = " You sent: \0";
scia_msg(msg);
scia_xmit(SdataA[i]);
}

}

// Test 1,SCIA DLB, 8-bit word, baud rate 0x0103, default, 1 STOP bit, no parity
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.bit.TXINTENA =1;
SciaRegs.SCICTL2.bit.RXBKINTENA =1;

SciaRegs.SCIHBAUD =0x0001; // 9600 baud @LSPCLK = 25MHz (100 MHz SYSCLK).
SciaRegs.SCILBAUD =0x0044;

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

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

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

// Initalize the SCI FIFO
void scia_fifo_init()
{
SciaRegs.SCIFFTX.all=0xE040;
SciaRegs.SCIFFRX.all=0x2044;
SciaRegs.SCIFFCT.all=0x0;

}

//===========================================================================
// No more.
//===========================================================================

数组中的数据就是发送不出来,这是为什么呢

rookiecalf:

应该是发出来了,只不过你的数据不太正确,可能对应的ascii码不是字符,你可以将上位机切换到16进制,然后使用断点调试看看

赞(0)
未经允许不得转载:TI中文支持网 » 在C28x中用SCI发送数组不显示的问题
分享到: 更多 (0)