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

28032的SCI通信乱码

哪位能帮我看下sci通讯发送出来的数据是乱码,找了好久都不知道是哪里出错了。外部晶振20MHZ,波特率设置的是115200

InitPll(6,2);

SysCtrlRegs.LOSPCP.all = 0x0002;

int main(void)
{
char *msg;
InitSysCtrl();
InitSciaGpio();
DINT;
InitPieCtrl();

// Disable CPU interrupts and clear all CPU interrupt flags:
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();

EALLOW;
PieVectTable.SCIRXINTA = &sciarx_isr;

EDIS;
PieCtrlRegs.PIECTRL.bit.ENPIE = 1;
IER |= M_INT9;
PieCtrlRegs.PIEIER9.bit.INTx1 = 1;
EINT;
ERTM;

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

for(;;)
{
msg = "\r\n0123456789\n\0";
scia_msg(msg);
DSP28x_usDelay(4000000);
}
return 0;
}
void scia_echoback_init()
{

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 =0x0000; // 9600 baud @LSPCLK = 15MHz (60 MHz SYSCLK).
SciaRegs.SCILBAUD =0x000F;//0x0F(115200)

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) {}
while (SciaRegs.SCICTL2.bit.TXEMPTY == 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;
SciaRegs.SCIFFTX.all = 0x8000;
}
char Scia_recvchar()
{
return SciaRegs.SCIRXBUF.all;
}
interrupt void sciarx_isr()
{
data = Scia_recvchar();
PieCtrlRegs.PIEACK.all |= M_INT9;
}

Seven Han:

试试将波特率设置小点。

哪位能帮我看下sci通讯发送出来的数据是乱码,找了好久都不知道是哪里出错了。外部晶振20MHZ,波特率设置的是115200

InitPll(6,2);

SysCtrlRegs.LOSPCP.all = 0x0002;

int main(void)
{
char *msg;
InitSysCtrl();
InitSciaGpio();
DINT;
InitPieCtrl();

// Disable CPU interrupts and clear all CPU interrupt flags:
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();

EALLOW;
PieVectTable.SCIRXINTA = &sciarx_isr;

EDIS;
PieCtrlRegs.PIECTRL.bit.ENPIE = 1;
IER |= M_INT9;
PieCtrlRegs.PIEIER9.bit.INTx1 = 1;
EINT;
ERTM;

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

for(;;)
{
msg = "\r\n0123456789\n\0";
scia_msg(msg);
DSP28x_usDelay(4000000);
}
return 0;
}
void scia_echoback_init()
{

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 =0x0000; // 9600 baud @LSPCLK = 15MHz (60 MHz SYSCLK).
SciaRegs.SCILBAUD =0x000F;//0x0F(115200)

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) {}
while (SciaRegs.SCICTL2.bit.TXEMPTY == 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;
SciaRegs.SCIFFTX.all = 0x8000;
}
char Scia_recvchar()
{
return SciaRegs.SCIRXBUF.all;
}
interrupt void sciarx_isr()
{
data = Scia_recvchar();
PieCtrlRegs.PIEACK.all |= M_INT9;
}

quanfa he:

回复 Seven Han:

改了,结果也是一样。SCI编程需要注意什么呢。我用示例代码,修改倍频系数后,数据也同样不对。

哪位能帮我看下sci通讯发送出来的数据是乱码,找了好久都不知道是哪里出错了。外部晶振20MHZ,波特率设置的是115200

InitPll(6,2);

SysCtrlRegs.LOSPCP.all = 0x0002;

int main(void)
{
char *msg;
InitSysCtrl();
InitSciaGpio();
DINT;
InitPieCtrl();

// Disable CPU interrupts and clear all CPU interrupt flags:
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();

EALLOW;
PieVectTable.SCIRXINTA = &sciarx_isr;

EDIS;
PieCtrlRegs.PIECTRL.bit.ENPIE = 1;
IER |= M_INT9;
PieCtrlRegs.PIEIER9.bit.INTx1 = 1;
EINT;
ERTM;

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

for(;;)
{
msg = "\r\n0123456789\n\0";
scia_msg(msg);
DSP28x_usDelay(4000000);
}
return 0;
}
void scia_echoback_init()
{

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 =0x0000; // 9600 baud @LSPCLK = 15MHz (60 MHz SYSCLK).
SciaRegs.SCILBAUD =0x000F;//0x0F(115200)

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) {}
while (SciaRegs.SCICTL2.bit.TXEMPTY == 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;
SciaRegs.SCIFFTX.all = 0x8000;
}
char Scia_recvchar()
{
return SciaRegs.SCIRXBUF.all;
}
interrupt void sciarx_isr()
{
data = Scia_recvchar();
PieCtrlRegs.PIEACK.all |= M_INT9;
}

Seven Han:

回复 quanfa he:

注意检查下时钟配置,串口助手设置,另外TI例程是验证过的。

哪位能帮我看下sci通讯发送出来的数据是乱码,找了好久都不知道是哪里出错了。外部晶振20MHZ,波特率设置的是115200

InitPll(6,2);

SysCtrlRegs.LOSPCP.all = 0x0002;

int main(void)
{
char *msg;
InitSysCtrl();
InitSciaGpio();
DINT;
InitPieCtrl();

// Disable CPU interrupts and clear all CPU interrupt flags:
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();

EALLOW;
PieVectTable.SCIRXINTA = &sciarx_isr;

EDIS;
PieCtrlRegs.PIECTRL.bit.ENPIE = 1;
IER |= M_INT9;
PieCtrlRegs.PIEIER9.bit.INTx1 = 1;
EINT;
ERTM;

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

for(;;)
{
msg = "\r\n0123456789\n\0";
scia_msg(msg);
DSP28x_usDelay(4000000);
}
return 0;
}
void scia_echoback_init()
{

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 =0x0000; // 9600 baud @LSPCLK = 15MHz (60 MHz SYSCLK).
SciaRegs.SCILBAUD =0x000F;//0x0F(115200)

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) {}
while (SciaRegs.SCICTL2.bit.TXEMPTY == 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;
SciaRegs.SCIFFTX.all = 0x8000;
}
char Scia_recvchar()
{
return SciaRegs.SCIRXBUF.all;
}
interrupt void sciarx_isr()
{
data = Scia_recvchar();
PieCtrlRegs.PIEACK.all |= M_INT9;
}

quanfa he:

回复 Seven Han:

请问我要测试串口是否正确,可以用什么工具呢。dsp的串口是什么电平?485通讯芯片 用的是5v供电的。发送出来的数据也是错误的。

我测试串口配置是否正确,用的串口调试助手和USB-TTL电平。

哪位能帮我看下sci通讯发送出来的数据是乱码,找了好久都不知道是哪里出错了。外部晶振20MHZ,波特率设置的是115200

InitPll(6,2);

SysCtrlRegs.LOSPCP.all = 0x0002;

int main(void)
{
char *msg;
InitSysCtrl();
InitSciaGpio();
DINT;
InitPieCtrl();

// Disable CPU interrupts and clear all CPU interrupt flags:
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();

EALLOW;
PieVectTable.SCIRXINTA = &sciarx_isr;

EDIS;
PieCtrlRegs.PIECTRL.bit.ENPIE = 1;
IER |= M_INT9;
PieCtrlRegs.PIEIER9.bit.INTx1 = 1;
EINT;
ERTM;

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

for(;;)
{
msg = "\r\n0123456789\n\0";
scia_msg(msg);
DSP28x_usDelay(4000000);
}
return 0;
}
void scia_echoback_init()
{

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 =0x0000; // 9600 baud @LSPCLK = 15MHz (60 MHz SYSCLK).
SciaRegs.SCILBAUD =0x000F;//0x0F(115200)

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) {}
while (SciaRegs.SCICTL2.bit.TXEMPTY == 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;
SciaRegs.SCIFFTX.all = 0x8000;
}
char Scia_recvchar()
{
return SciaRegs.SCIRXBUF.all;
}
interrupt void sciarx_isr()
{
data = Scia_recvchar();
PieCtrlRegs.PIEACK.all |= M_INT9;
}

quanfa he:

回复 quanfa he:

现在发送的数据正确了。但是我用示例代码打断点运行时,发送数据有问题。第一帧数据发送不完整,只有在发送第二帧的时候才把第一帧剩下的冲刷出来

哪位能帮我看下sci通讯发送出来的数据是乱码,找了好久都不知道是哪里出错了。外部晶振20MHZ,波特率设置的是115200

InitPll(6,2);

SysCtrlRegs.LOSPCP.all = 0x0002;

int main(void)
{
char *msg;
InitSysCtrl();
InitSciaGpio();
DINT;
InitPieCtrl();

// Disable CPU interrupts and clear all CPU interrupt flags:
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();

EALLOW;
PieVectTable.SCIRXINTA = &sciarx_isr;

EDIS;
PieCtrlRegs.PIECTRL.bit.ENPIE = 1;
IER |= M_INT9;
PieCtrlRegs.PIEIER9.bit.INTx1 = 1;
EINT;
ERTM;

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

for(;;)
{
msg = "\r\n0123456789\n\0";
scia_msg(msg);
DSP28x_usDelay(4000000);
}
return 0;
}
void scia_echoback_init()
{

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 =0x0000; // 9600 baud @LSPCLK = 15MHz (60 MHz SYSCLK).
SciaRegs.SCILBAUD =0x000F;//0x0F(115200)

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) {}
while (SciaRegs.SCICTL2.bit.TXEMPTY == 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;
SciaRegs.SCIFFTX.all = 0x8000;
}
char Scia_recvchar()
{
return SciaRegs.SCIRXBUF.all;
}
interrupt void sciarx_isr()
{
data = Scia_recvchar();
PieCtrlRegs.PIEACK.all |= M_INT9;
}

Young Hu:

回复 quanfa he:

如果不完整的话,要看一下相关的error寄存器有没有置位。

赞(0)
未经允许不得转载:TI中文支持网 » 28032的SCI通信乱码
分享到: 更多 (0)