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

28035的 LIN 模块通讯问题

28035的LIN模块,用作SCI兼容模式,参考controlsuit的几个例子,写了一段简单的代码,结果出现一个问题:如果利用缓存模式,填满LinaRegs.LINTD0和LinaRegs.LINTD1 共8个 char,然后不管使用loopback还是对外部发送, 结果总是丢失 LinaRegs.LINTD0.bit.TD0  这个char,实在搞不懂怎么回事。

代码如下(仅对寄存器初始化,然后填充TD缓存) :

void Init(void)
{

EALLOW; // This is needed to write to EALLOW protected registers

LinaRegs.SCIGCR0.bit.RESET = 0; //Into reset
LinaRegs.SCIGCR0.bit.RESET = 1; //Out of reset

LinaRegs.SCIGCR1.bit.SWnRST = 0; //Into software reset

//SCI Configurations
LinaRegs.SCIGCR1.bit.COMMMODE = 0; //Idle-Line Mode
LinaRegs.SCIGCR1.bit.TIMINGMODE = 1; //Asynchronous Timing
LinaRegs.SCIGCR1.bit.PARITYENA = 1; //Parity Check
LinaRegs.SCIGCR1.bit.PARITY = 1; //Even Parity
LinaRegs.SCIGCR1.bit.STOP = 0; //One Stop Bit
LinaRegs.SCIGCR1.bit.CLK_MASTER = 1; //Enable SCI Clock
LinaRegs.SCIGCR1.bit.LINMODE = 0; //SCI Mode
LinaRegs.SCIGCR1.bit.SLEEP = 0; //Ensure Out of Sleep
LinaRegs.SCIGCR1.bit.MBUFMODE = 1; //Buffered Mode
LinaRegs.SCIGCR1.bit.LOOPBACK = 1; //Internal Loopback
LinaRegs.SCIGCR1.bit.CONT = 1; //Continue on Suspend
LinaRegs.SCIGCR1.bit.RXENA = 1; //Enable RX
LinaRegs.SCIGCR1.bit.TXENA = 1; //Enable TX

//Ensure IODFT is disabled
LinaRegs.IODFTCTRL.bit.IODFTENA = 0x0;

//Set transmission length
LinaRegs.SCIFORMAT.bit.CHAR = 7; //Eight bits
LinaRegs.SCIFORMAT.bit.LENGTH = 7;

//Set baudrate
LinaRegs.BRSR.bit.SCI_LIN_PSL =194; //9600 bps for SYSCLKOUT = 60 MHz
LinaRegs.BRSR.bit.M =5;

LinaRegs.SCIGCR1.bit.SWnRST = 1; //bring out of software reset

EDIS;

while(LinaRegs.SCIFLR.bit.IDLE == 1);

LinaRegs.LINTD1.bit.TD7 = 0x08;
LinaRegs.LINTD1.bit.TD6 = 0x07;
LinaRegs.LINTD1.bit.TD5 = 0x06;
LinaRegs.LINTD1.bit.TD4 = 0x05;
LinaRegs.LINTD0.bit.TD3 = 0x04;
LinaRegs.LINTD0.bit.TD2 = 0x03;
LinaRegs.LINTD0.bit.TD1 = 0x02;
LinaRegs.LINTD0.bit.TD0 = 0x01;

}

然后,从监视器看到的情况是这样的,TD是对的,RD就是 RD0 那里总是收不到数据,如果是对外发送,用示波器观察,也是发少一个数。

请教究竟是怎么回事?

mangui zhang:

详细看看这个文档 SPRUGE2A

顺便给你分享了  到付件中

28035的LIN模块,用作SCI兼容模式,参考controlsuit的几个例子,写了一段简单的代码,结果出现一个问题:如果利用缓存模式,填满LinaRegs.LINTD0和LinaRegs.LINTD1 共8个 char,然后不管使用loopback还是对外部发送, 结果总是丢失 LinaRegs.LINTD0.bit.TD0  这个char,实在搞不懂怎么回事。

代码如下(仅对寄存器初始化,然后填充TD缓存) :

void Init(void)
{

EALLOW; // This is needed to write to EALLOW protected registers

LinaRegs.SCIGCR0.bit.RESET = 0; //Into reset
LinaRegs.SCIGCR0.bit.RESET = 1; //Out of reset

LinaRegs.SCIGCR1.bit.SWnRST = 0; //Into software reset

//SCI Configurations
LinaRegs.SCIGCR1.bit.COMMMODE = 0; //Idle-Line Mode
LinaRegs.SCIGCR1.bit.TIMINGMODE = 1; //Asynchronous Timing
LinaRegs.SCIGCR1.bit.PARITYENA = 1; //Parity Check
LinaRegs.SCIGCR1.bit.PARITY = 1; //Even Parity
LinaRegs.SCIGCR1.bit.STOP = 0; //One Stop Bit
LinaRegs.SCIGCR1.bit.CLK_MASTER = 1; //Enable SCI Clock
LinaRegs.SCIGCR1.bit.LINMODE = 0; //SCI Mode
LinaRegs.SCIGCR1.bit.SLEEP = 0; //Ensure Out of Sleep
LinaRegs.SCIGCR1.bit.MBUFMODE = 1; //Buffered Mode
LinaRegs.SCIGCR1.bit.LOOPBACK = 1; //Internal Loopback
LinaRegs.SCIGCR1.bit.CONT = 1; //Continue on Suspend
LinaRegs.SCIGCR1.bit.RXENA = 1; //Enable RX
LinaRegs.SCIGCR1.bit.TXENA = 1; //Enable TX

//Ensure IODFT is disabled
LinaRegs.IODFTCTRL.bit.IODFTENA = 0x0;

//Set transmission length
LinaRegs.SCIFORMAT.bit.CHAR = 7; //Eight bits
LinaRegs.SCIFORMAT.bit.LENGTH = 7;

//Set baudrate
LinaRegs.BRSR.bit.SCI_LIN_PSL =194; //9600 bps for SYSCLKOUT = 60 MHz
LinaRegs.BRSR.bit.M =5;

LinaRegs.SCIGCR1.bit.SWnRST = 1; //bring out of software reset

EDIS;

while(LinaRegs.SCIFLR.bit.IDLE == 1);

LinaRegs.LINTD1.bit.TD7 = 0x08;
LinaRegs.LINTD1.bit.TD6 = 0x07;
LinaRegs.LINTD1.bit.TD5 = 0x06;
LinaRegs.LINTD1.bit.TD4 = 0x05;
LinaRegs.LINTD0.bit.TD3 = 0x04;
LinaRegs.LINTD0.bit.TD2 = 0x03;
LinaRegs.LINTD0.bit.TD1 = 0x02;
LinaRegs.LINTD0.bit.TD0 = 0x01;

}

然后,从监视器看到的情况是这样的,TD是对的,RD就是 RD0 那里总是收不到数据,如果是对外发送,用示波器观察,也是发少一个数。

请教究竟是怎么回事?

HH Y:

回复 mangui zhang:

谢谢!

这个问题解决了,只要把8个TD的赋值顺序倒过来,即TD0第一个赋值,就没事了。只是不知怎么回事,手册说TD0赋值时就开始一个发送,按理和TD0什么时候赋值是没关的。手册是英文的,我的水平不咋地,读起来费劲,有的还理解不了~~

28035的LIN模块,用作SCI兼容模式,参考controlsuit的几个例子,写了一段简单的代码,结果出现一个问题:如果利用缓存模式,填满LinaRegs.LINTD0和LinaRegs.LINTD1 共8个 char,然后不管使用loopback还是对外部发送, 结果总是丢失 LinaRegs.LINTD0.bit.TD0  这个char,实在搞不懂怎么回事。

代码如下(仅对寄存器初始化,然后填充TD缓存) :

void Init(void)
{

EALLOW; // This is needed to write to EALLOW protected registers

LinaRegs.SCIGCR0.bit.RESET = 0; //Into reset
LinaRegs.SCIGCR0.bit.RESET = 1; //Out of reset

LinaRegs.SCIGCR1.bit.SWnRST = 0; //Into software reset

//SCI Configurations
LinaRegs.SCIGCR1.bit.COMMMODE = 0; //Idle-Line Mode
LinaRegs.SCIGCR1.bit.TIMINGMODE = 1; //Asynchronous Timing
LinaRegs.SCIGCR1.bit.PARITYENA = 1; //Parity Check
LinaRegs.SCIGCR1.bit.PARITY = 1; //Even Parity
LinaRegs.SCIGCR1.bit.STOP = 0; //One Stop Bit
LinaRegs.SCIGCR1.bit.CLK_MASTER = 1; //Enable SCI Clock
LinaRegs.SCIGCR1.bit.LINMODE = 0; //SCI Mode
LinaRegs.SCIGCR1.bit.SLEEP = 0; //Ensure Out of Sleep
LinaRegs.SCIGCR1.bit.MBUFMODE = 1; //Buffered Mode
LinaRegs.SCIGCR1.bit.LOOPBACK = 1; //Internal Loopback
LinaRegs.SCIGCR1.bit.CONT = 1; //Continue on Suspend
LinaRegs.SCIGCR1.bit.RXENA = 1; //Enable RX
LinaRegs.SCIGCR1.bit.TXENA = 1; //Enable TX

//Ensure IODFT is disabled
LinaRegs.IODFTCTRL.bit.IODFTENA = 0x0;

//Set transmission length
LinaRegs.SCIFORMAT.bit.CHAR = 7; //Eight bits
LinaRegs.SCIFORMAT.bit.LENGTH = 7;

//Set baudrate
LinaRegs.BRSR.bit.SCI_LIN_PSL =194; //9600 bps for SYSCLKOUT = 60 MHz
LinaRegs.BRSR.bit.M =5;

LinaRegs.SCIGCR1.bit.SWnRST = 1; //bring out of software reset

EDIS;

while(LinaRegs.SCIFLR.bit.IDLE == 1);

LinaRegs.LINTD1.bit.TD7 = 0x08;
LinaRegs.LINTD1.bit.TD6 = 0x07;
LinaRegs.LINTD1.bit.TD5 = 0x06;
LinaRegs.LINTD1.bit.TD4 = 0x05;
LinaRegs.LINTD0.bit.TD3 = 0x04;
LinaRegs.LINTD0.bit.TD2 = 0x03;
LinaRegs.LINTD0.bit.TD1 = 0x02;
LinaRegs.LINTD0.bit.TD0 = 0x01;

}

然后,从监视器看到的情况是这样的,TD是对的,RD就是 RD0 那里总是收不到数据,如果是对外发送,用示波器观察,也是发少一个数。

请教究竟是怎么回事?

Yongjie Zheng:

请问,怎么对外发送?我这里把loopback配置为0不能对外发送,是不是还要配置什么?请指教!

28035的LIN模块,用作SCI兼容模式,参考controlsuit的几个例子,写了一段简单的代码,结果出现一个问题:如果利用缓存模式,填满LinaRegs.LINTD0和LinaRegs.LINTD1 共8个 char,然后不管使用loopback还是对外部发送, 结果总是丢失 LinaRegs.LINTD0.bit.TD0  这个char,实在搞不懂怎么回事。

代码如下(仅对寄存器初始化,然后填充TD缓存) :

void Init(void)
{

EALLOW; // This is needed to write to EALLOW protected registers

LinaRegs.SCIGCR0.bit.RESET = 0; //Into reset
LinaRegs.SCIGCR0.bit.RESET = 1; //Out of reset

LinaRegs.SCIGCR1.bit.SWnRST = 0; //Into software reset

//SCI Configurations
LinaRegs.SCIGCR1.bit.COMMMODE = 0; //Idle-Line Mode
LinaRegs.SCIGCR1.bit.TIMINGMODE = 1; //Asynchronous Timing
LinaRegs.SCIGCR1.bit.PARITYENA = 1; //Parity Check
LinaRegs.SCIGCR1.bit.PARITY = 1; //Even Parity
LinaRegs.SCIGCR1.bit.STOP = 0; //One Stop Bit
LinaRegs.SCIGCR1.bit.CLK_MASTER = 1; //Enable SCI Clock
LinaRegs.SCIGCR1.bit.LINMODE = 0; //SCI Mode
LinaRegs.SCIGCR1.bit.SLEEP = 0; //Ensure Out of Sleep
LinaRegs.SCIGCR1.bit.MBUFMODE = 1; //Buffered Mode
LinaRegs.SCIGCR1.bit.LOOPBACK = 1; //Internal Loopback
LinaRegs.SCIGCR1.bit.CONT = 1; //Continue on Suspend
LinaRegs.SCIGCR1.bit.RXENA = 1; //Enable RX
LinaRegs.SCIGCR1.bit.TXENA = 1; //Enable TX

//Ensure IODFT is disabled
LinaRegs.IODFTCTRL.bit.IODFTENA = 0x0;

//Set transmission length
LinaRegs.SCIFORMAT.bit.CHAR = 7; //Eight bits
LinaRegs.SCIFORMAT.bit.LENGTH = 7;

//Set baudrate
LinaRegs.BRSR.bit.SCI_LIN_PSL =194; //9600 bps for SYSCLKOUT = 60 MHz
LinaRegs.BRSR.bit.M =5;

LinaRegs.SCIGCR1.bit.SWnRST = 1; //bring out of software reset

EDIS;

while(LinaRegs.SCIFLR.bit.IDLE == 1);

LinaRegs.LINTD1.bit.TD7 = 0x08;
LinaRegs.LINTD1.bit.TD6 = 0x07;
LinaRegs.LINTD1.bit.TD5 = 0x06;
LinaRegs.LINTD1.bit.TD4 = 0x05;
LinaRegs.LINTD0.bit.TD3 = 0x04;
LinaRegs.LINTD0.bit.TD2 = 0x03;
LinaRegs.LINTD0.bit.TD1 = 0x02;
LinaRegs.LINTD0.bit.TD0 = 0x01;

}

然后,从监视器看到的情况是这样的,TD是对的,RD就是 RD0 那里总是收不到数据,如果是对外发送,用示波器观察,也是发少一个数。

请教究竟是怎么回事?

HH Y:

回复 Yongjie Zheng:

按例子就可以了,如果不是全拷贝例子的,就检查一下是不是GPIO,或者时钟忘记配置了。如果代码觉得没问题,就检查硬件

28035的LIN模块,用作SCI兼容模式,参考controlsuit的几个例子,写了一段简单的代码,结果出现一个问题:如果利用缓存模式,填满LinaRegs.LINTD0和LinaRegs.LINTD1 共8个 char,然后不管使用loopback还是对外部发送, 结果总是丢失 LinaRegs.LINTD0.bit.TD0  这个char,实在搞不懂怎么回事。

代码如下(仅对寄存器初始化,然后填充TD缓存) :

void Init(void)
{

EALLOW; // This is needed to write to EALLOW protected registers

LinaRegs.SCIGCR0.bit.RESET = 0; //Into reset
LinaRegs.SCIGCR0.bit.RESET = 1; //Out of reset

LinaRegs.SCIGCR1.bit.SWnRST = 0; //Into software reset

//SCI Configurations
LinaRegs.SCIGCR1.bit.COMMMODE = 0; //Idle-Line Mode
LinaRegs.SCIGCR1.bit.TIMINGMODE = 1; //Asynchronous Timing
LinaRegs.SCIGCR1.bit.PARITYENA = 1; //Parity Check
LinaRegs.SCIGCR1.bit.PARITY = 1; //Even Parity
LinaRegs.SCIGCR1.bit.STOP = 0; //One Stop Bit
LinaRegs.SCIGCR1.bit.CLK_MASTER = 1; //Enable SCI Clock
LinaRegs.SCIGCR1.bit.LINMODE = 0; //SCI Mode
LinaRegs.SCIGCR1.bit.SLEEP = 0; //Ensure Out of Sleep
LinaRegs.SCIGCR1.bit.MBUFMODE = 1; //Buffered Mode
LinaRegs.SCIGCR1.bit.LOOPBACK = 1; //Internal Loopback
LinaRegs.SCIGCR1.bit.CONT = 1; //Continue on Suspend
LinaRegs.SCIGCR1.bit.RXENA = 1; //Enable RX
LinaRegs.SCIGCR1.bit.TXENA = 1; //Enable TX

//Ensure IODFT is disabled
LinaRegs.IODFTCTRL.bit.IODFTENA = 0x0;

//Set transmission length
LinaRegs.SCIFORMAT.bit.CHAR = 7; //Eight bits
LinaRegs.SCIFORMAT.bit.LENGTH = 7;

//Set baudrate
LinaRegs.BRSR.bit.SCI_LIN_PSL =194; //9600 bps for SYSCLKOUT = 60 MHz
LinaRegs.BRSR.bit.M =5;

LinaRegs.SCIGCR1.bit.SWnRST = 1; //bring out of software reset

EDIS;

while(LinaRegs.SCIFLR.bit.IDLE == 1);

LinaRegs.LINTD1.bit.TD7 = 0x08;
LinaRegs.LINTD1.bit.TD6 = 0x07;
LinaRegs.LINTD1.bit.TD5 = 0x06;
LinaRegs.LINTD1.bit.TD4 = 0x05;
LinaRegs.LINTD0.bit.TD3 = 0x04;
LinaRegs.LINTD0.bit.TD2 = 0x03;
LinaRegs.LINTD0.bit.TD1 = 0x02;
LinaRegs.LINTD0.bit.TD0 = 0x01;

}

然后,从监视器看到的情况是这样的,TD是对的,RD就是 RD0 那里总是收不到数据,如果是对外发送,用示波器观察,也是发少一个数。

请教究竟是怎么回事?

Hoo Asnow:

回复 HH Y:

TD0第一个赋值,TD7最后一个赋值,感觉也有问题哇,之前有碰到过校验和错误的问题吗?

赞(0)
未经允许不得转载:TI中文支持网 » 28035的 LIN 模块通讯问题
分享到: 更多 (0)