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

F28035 SCI通讯乱码

各位好,今天使用F28035的SCIa通讯,一直出现乱码。电路板的晶振的6M,程序是从官网例程里面拷贝的。

使用官网的例程数据正常,把程序复制到我原来的程序里面,根据6M的晶振设置波特率9600之后,一直是乱码。

下面是程序:

1、时钟配置_6M

系统时钟:

//#define DSP28_DIVSEL 0 // Enable /4 for SYSCLKOUT
#define DSP28_DIVSEL 1 // Disable /4 for SYSCKOUT
//#define DSP28_DIVSEL 2 // Enable /2 for SYSCLKOUT
//#define DSP28_DIVSEL 3 // Enable /1 for SYSCLKOUT

//#define DSP28_PLLCR 12 // Uncomment for 60 MHz devices [60 MHz = (10MHz * 12)/2]
//#define DSP28_PLLCR 11
#define DSP28_PLLCR 10
//#define DSP28_PLLCR 9

外设时钟:

//GpioCtrlRegs.GPAMUX2.bit.GPIO18 = 3; // GPIO18 = XCLKOUT
SysCtrlRegs.LOSPCP.all = 0x0002;

// XCLKOUT to SYSCLKOUT ratio. By default XCLKOUT = 1/4 SYSCLKOUT
//XCLKOUT与SYSCLKOUT的比例。 默认情况下,XCLKOUT = 1/4 SYSCLKOUT
SysCtrlRegs.XCLK.bit.XCLKOUTDIV=2;

2、SCI设置

参数:

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

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

引脚:

void InitSciaGpio()
{
EALLOW;

/* Enable internal pull-up for the selected pins */
// Pull-ups can be enabled or disabled disabled by the user.
// This will enable the pullups for the specified pins.

GpioCtrlRegs.GPAPUD.bit.GPIO28 = 0; // Enable pull-up for GPIO28 (SCIRXDA)
// GpioCtrlRegs.GPAPUD.bit.GPIO7 = 0; // Enable pull-up for GPIO7 (SCIRXDA)

GpioCtrlRegs.GPAPUD.bit.GPIO29 = 0; // Enable pull-up for GPIO29 (SCITXDA)
// GpioCtrlRegs.GPAPUD.bit.GPIO12 = 0; // Enable pull-up for GPIO12 (SCITXDA)

/* Set qualification for selected pins to asynch only */
// Inputs are synchronized to SYSCLKOUT by default.
// This will select asynch (no qualification) for the selected pins.

GpioCtrlRegs.GPAQSEL2.bit.GPIO28 = 3; // Asynch input GPIO28 (SCIRXDA)
// GpioCtrlRegs.GPAQSEL1.bit.GPIO7 = 3; // Asynch input GPIO7 (SCIRXDA)

/* Configure SCI-A pins using GPIO regs*/
// This specifies which of the possible GPIO pins will be SCI functional pins.

GpioCtrlRegs.GPAMUX2.bit.GPIO28 = 1; // Configure GPIO28 for SCIRXDA operation
// GpioCtrlRegs.GPAMUX1.bit.GPIO7 = 2; // Configure GPIO7 for SCIRXDA operation

GpioCtrlRegs.GPAMUX2.bit.GPIO29 = 1; // Configure GPIO29 for SCITXDA operation
// GpioCtrlRegs.GPAMUX1.bit.GPIO12 = 2; // Configure GPIO12 for SCITXDA operation

EDIS;
}

其他的程序都是跟官网一样。

正常数据:

Hello World!
You will enter a character, and the DSP will echo it back!

Enter a character: You sent: l
Enter a character:

乱码:

?
卫?
0

0鹞

>

?0
0

请教各位,多谢!

ss s:

回复 Seven Han:

你好,配置完全按照例程改就好了,多谢!

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