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

28335 SCI 发送问题

各位,在调试28335 SCI发送时发现以下问题,看看有没有解决的办法,先描述下问题

使用查询方式发送,比如我要发送 0x01 0x02 0x03 三个数据,执行完ScibRegs。SCITXBUF = SendBuf[i]&0xFF;后只发送0x01 0x02,执行完第二次发送0x03 0x01 0x02,是什么原因第一次不直接发送三个数据?

代码如下“

#define SCI ScibRegs

初始化:

SCI.SCIFFTX.all=0xE040;

//ScibRegs.SCIFFCT.bit.FFTXDLY = 8;
SCI.SCIFFRX.all=0x206F;
SCI.SCIFFRX.bit.RXFFIL = 5; //in protocal. num of needing to recieved is 9

//SCI FIFO Control Register
SCI.SCIFFCT.all=0x0;
//SCI Communication Control Register
SCI.SCICCR.all =0x0007; // 1 stop bit, No loopback
//No parity,8 char bits,
// async mode, idle-line protocol
//SCI Control Register 1
SCI.SCICTL1.all = 0x0003; //enable TX, RX, internal SCICLK,
// Disable RX ERR, SLEEP, TXWAKE
//SCI Control Register 2
SCI.SCICTL2.bit.TXINTENA = 0;
SCI.SCICTL2.bit.RXBKINTENA = 1; //enable rx interrupt

//Baud=LPSCLK/((BRR+1)x8) ->BRR= (LPSCLK/(Baud x 8))-1 (1<=BRR<= 65535)
//Baud=LPSCLK/16 -> BRR = 0
BaudRate = SCI_PRD;
BaudRate = (BaudRate >> 8);
SCI.SCIHBAUD = BaudRate; // 115200 baud @LSPCLK = 37.5MHz.
BaudRate = SCI_PRD;
BaudRate = (BaudRate & 0x00FF);
SCI.SCILBAUD = BaudRate;
SCI.SCICTL1.all = 0x0023; // Relinquish SCI from Reset
SCI.SCIFFTX.bit.TXFIFOXRESET = 1; SCI.SCIFFRX.bit.RXFIFORESET = 1;

发送:

for(i=0;i<3;i++)
{
while (SCI.SCICTL2.bit.TXRDY != 1) ;
SCI.SCITXBUF = SendBuf[i]&0xFF;
}

mangui zhang:改为如下呢:SCI.SCITXBUF = SendBuf[i]&0xFF;
while (SCI.SCICTL2.bit.TXRDY != 1) ;

各位,在调试28335 SCI发送时发现以下问题,看看有没有解决的办法,先描述下问题

使用查询方式发送,比如我要发送 0x01 0x02 0x03 三个数据,执行完ScibRegs。SCITXBUF = SendBuf[i]&0xFF;后只发送0x01 0x02,执行完第二次发送0x03 0x01 0x02,是什么原因第一次不直接发送三个数据?

代码如下“

#define SCI ScibRegs

初始化:

SCI.SCIFFTX.all=0xE040;

//ScibRegs.SCIFFCT.bit.FFTXDLY = 8;
SCI.SCIFFRX.all=0x206F;
SCI.SCIFFRX.bit.RXFFIL = 5; //in protocal. num of needing to recieved is 9

//SCI FIFO Control Register
SCI.SCIFFCT.all=0x0;
//SCI Communication Control Register
SCI.SCICCR.all =0x0007; // 1 stop bit, No loopback
//No parity,8 char bits,
// async mode, idle-line protocol
//SCI Control Register 1
SCI.SCICTL1.all = 0x0003; //enable TX, RX, internal SCICLK,
// Disable RX ERR, SLEEP, TXWAKE
//SCI Control Register 2
SCI.SCICTL2.bit.TXINTENA = 0;
SCI.SCICTL2.bit.RXBKINTENA = 1; //enable rx interrupt

//Baud=LPSCLK/((BRR+1)x8) ->BRR= (LPSCLK/(Baud x 8))-1 (1<=BRR<= 65535)
//Baud=LPSCLK/16 -> BRR = 0
BaudRate = SCI_PRD;
BaudRate = (BaudRate >> 8);
SCI.SCIHBAUD = BaudRate; // 115200 baud @LSPCLK = 37.5MHz.
BaudRate = SCI_PRD;
BaudRate = (BaudRate & 0x00FF);
SCI.SCILBAUD = BaudRate;
SCI.SCICTL1.all = 0x0023; // Relinquish SCI from Reset
SCI.SCIFFTX.bit.TXFIFOXRESET = 1; SCI.SCIFFRX.bit.RXFIFORESET = 1;

发送:

for(i=0;i<3;i++)
{
while (SCI.SCICTL2.bit.TXRDY != 1) ;
SCI.SCITXBUF = SendBuf[i]&0xFF;
}

user1775662:

问题解决了吗,好像跟我的问题一样。

你用的是RS485还是RS232?

各位,在调试28335 SCI发送时发现以下问题,看看有没有解决的办法,先描述下问题

使用查询方式发送,比如我要发送 0x01 0x02 0x03 三个数据,执行完ScibRegs。SCITXBUF = SendBuf[i]&0xFF;后只发送0x01 0x02,执行完第二次发送0x03 0x01 0x02,是什么原因第一次不直接发送三个数据?

代码如下“

#define SCI ScibRegs

初始化:

SCI.SCIFFTX.all=0xE040;

//ScibRegs.SCIFFCT.bit.FFTXDLY = 8;
SCI.SCIFFRX.all=0x206F;
SCI.SCIFFRX.bit.RXFFIL = 5; //in protocal. num of needing to recieved is 9

//SCI FIFO Control Register
SCI.SCIFFCT.all=0x0;
//SCI Communication Control Register
SCI.SCICCR.all =0x0007; // 1 stop bit, No loopback
//No parity,8 char bits,
// async mode, idle-line protocol
//SCI Control Register 1
SCI.SCICTL1.all = 0x0003; //enable TX, RX, internal SCICLK,
// Disable RX ERR, SLEEP, TXWAKE
//SCI Control Register 2
SCI.SCICTL2.bit.TXINTENA = 0;
SCI.SCICTL2.bit.RXBKINTENA = 1; //enable rx interrupt

//Baud=LPSCLK/((BRR+1)x8) ->BRR= (LPSCLK/(Baud x 8))-1 (1<=BRR<= 65535)
//Baud=LPSCLK/16 -> BRR = 0
BaudRate = SCI_PRD;
BaudRate = (BaudRate >> 8);
SCI.SCIHBAUD = BaudRate; // 115200 baud @LSPCLK = 37.5MHz.
BaudRate = SCI_PRD;
BaudRate = (BaudRate & 0x00FF);
SCI.SCILBAUD = BaudRate;
SCI.SCICTL1.all = 0x0023; // Relinquish SCI from Reset
SCI.SCIFFTX.bit.TXFIFOXRESET = 1; SCI.SCIFFRX.bit.RXFIFORESET = 1;

发送:

for(i=0;i<3;i++)
{
while (SCI.SCICTL2.bit.TXRDY != 1) ;
SCI.SCITXBUF = SendBuf[i]&0xFF;
}

Seven Han:

使用fifo的话,把while (SCI.SCICTL2.bit.TXRDY != 1) ;修改为while (SCI.SCIFFTX.bit.TXFFST != 0){}。

各位,在调试28335 SCI发送时发现以下问题,看看有没有解决的办法,先描述下问题

使用查询方式发送,比如我要发送 0x01 0x02 0x03 三个数据,执行完ScibRegs。SCITXBUF = SendBuf[i]&0xFF;后只发送0x01 0x02,执行完第二次发送0x03 0x01 0x02,是什么原因第一次不直接发送三个数据?

代码如下“

#define SCI ScibRegs

初始化:

SCI.SCIFFTX.all=0xE040;

//ScibRegs.SCIFFCT.bit.FFTXDLY = 8;
SCI.SCIFFRX.all=0x206F;
SCI.SCIFFRX.bit.RXFFIL = 5; //in protocal. num of needing to recieved is 9

//SCI FIFO Control Register
SCI.SCIFFCT.all=0x0;
//SCI Communication Control Register
SCI.SCICCR.all =0x0007; // 1 stop bit, No loopback
//No parity,8 char bits,
// async mode, idle-line protocol
//SCI Control Register 1
SCI.SCICTL1.all = 0x0003; //enable TX, RX, internal SCICLK,
// Disable RX ERR, SLEEP, TXWAKE
//SCI Control Register 2
SCI.SCICTL2.bit.TXINTENA = 0;
SCI.SCICTL2.bit.RXBKINTENA = 1; //enable rx interrupt

//Baud=LPSCLK/((BRR+1)x8) ->BRR= (LPSCLK/(Baud x 8))-1 (1<=BRR<= 65535)
//Baud=LPSCLK/16 -> BRR = 0
BaudRate = SCI_PRD;
BaudRate = (BaudRate >> 8);
SCI.SCIHBAUD = BaudRate; // 115200 baud @LSPCLK = 37.5MHz.
BaudRate = SCI_PRD;
BaudRate = (BaudRate & 0x00FF);
SCI.SCILBAUD = BaudRate;
SCI.SCICTL1.all = 0x0023; // Relinquish SCI from Reset
SCI.SCIFFTX.bit.TXFIFOXRESET = 1; SCI.SCIFFRX.bit.RXFIFORESET = 1;

发送:

for(i=0;i<3;i++)
{
while (SCI.SCICTL2.bit.TXRDY != 1) ;
SCI.SCITXBUF = SendBuf[i]&0xFF;
}

tecman chen:

回复 user1775662:

232

各位,在调试28335 SCI发送时发现以下问题,看看有没有解决的办法,先描述下问题

使用查询方式发送,比如我要发送 0x01 0x02 0x03 三个数据,执行完ScibRegs。SCITXBUF = SendBuf[i]&0xFF;后只发送0x01 0x02,执行完第二次发送0x03 0x01 0x02,是什么原因第一次不直接发送三个数据?

代码如下“

#define SCI ScibRegs

初始化:

SCI.SCIFFTX.all=0xE040;

//ScibRegs.SCIFFCT.bit.FFTXDLY = 8;
SCI.SCIFFRX.all=0x206F;
SCI.SCIFFRX.bit.RXFFIL = 5; //in protocal. num of needing to recieved is 9

//SCI FIFO Control Register
SCI.SCIFFCT.all=0x0;
//SCI Communication Control Register
SCI.SCICCR.all =0x0007; // 1 stop bit, No loopback
//No parity,8 char bits,
// async mode, idle-line protocol
//SCI Control Register 1
SCI.SCICTL1.all = 0x0003; //enable TX, RX, internal SCICLK,
// Disable RX ERR, SLEEP, TXWAKE
//SCI Control Register 2
SCI.SCICTL2.bit.TXINTENA = 0;
SCI.SCICTL2.bit.RXBKINTENA = 1; //enable rx interrupt

//Baud=LPSCLK/((BRR+1)x8) ->BRR= (LPSCLK/(Baud x 8))-1 (1<=BRR<= 65535)
//Baud=LPSCLK/16 -> BRR = 0
BaudRate = SCI_PRD;
BaudRate = (BaudRate >> 8);
SCI.SCIHBAUD = BaudRate; // 115200 baud @LSPCLK = 37.5MHz.
BaudRate = SCI_PRD;
BaudRate = (BaudRate & 0x00FF);
SCI.SCILBAUD = BaudRate;
SCI.SCICTL1.all = 0x0023; // Relinquish SCI from Reset
SCI.SCIFFTX.bit.TXFIFOXRESET = 1; SCI.SCIFFRX.bit.RXFIFORESET = 1;

发送:

for(i=0;i<3;i++)
{
while (SCI.SCICTL2.bit.TXRDY != 1) ;
SCI.SCITXBUF = SendBuf[i]&0xFF;
}

tecman chen:

回复 Seven Han:

代码改为:for(i=0;i<3;i++){SCI.SCITXBUF = SendBuf[i]&0xFF;while(SCI.SCIFFTX.bit.TXFFST != 0){} //FIFO has word}
第一次发送 0x01 0x02 ,第二次后都是0x03 0x01 0x02

代码改为:for(i=0;i<3;i++){while(SCI.SCIFFTX.bit.TXFFST != 0){} //FIFO has wordSCI.SCITXBUF = SendBuf[i]&0xFF;}
第一次发送0x01, 第二次发送都是0x02 0x03 0x01

还是有问题

赞(0)
未经允许不得转载:TI中文支持网 » 28335 SCI 发送问题
分享到: 更多 (0)