我的CAN发送程序如下:
UINT8 u8CAN_SendFrame(UINT32 u32ID, UINT8 u8Prio, UINT8 u8Length, UINT8 *u8TxData)
{
/* Transmission buffer */
UINT8 u8TxBuffer = {0};
/* Index to data within the transmission buffer */
UINT8 u8Index;
if (!CAN0TFLG) /* Retrun if Transmit Buffer is full */
return ERR_BUFFER_FULL;
CAN0TBSEL = CAN0TFLG; /* Select lowest empty buffer */
u8TxBuffer = CAN0TBSEL; /* Backup selected buffer */
*((UINT32 *) ((UINT32)(&CAN0TXIDR0)))= u32ID; /* Load Id to IDR Registers */
/* Load data to Data Segment Registers */
for (u8Index=0;u8Index<u8Length;u8Index++) {
*(&CAN0TXDSR0 + u8Index) = u8TxData[u8Index];
}
CAN0TXDLR = u8Length; /* Set Data Length Code */
CAN0TXTBPR = u8Prio; /* Set Priority */
CAN0TFLG = u8TxBuffer; /* Start transmission */
while ( (CAN0TFLG & u8TxBuffer) != u8TxBuffer);/* Wait for Transmission completion */
return NO_ERR;
}
问题:1。当发送不成功时,也就是CAN0TFLG相应的位没有被置位,程序就会在while ( (CAN0TFLG & u8TxBuffer) != u8TxBuffer);
处进入死循环,那么此时CAN控制器是会将报文重新发送呢,还是一直在等待对方的ACK回应呢?
2。还有,我检查了控制器中的CAN同步寄存器位,发现它为未同步状态,可之前初始化时是同步成功的啊,为何会出错呢?
谢谢指点,急求解答
没有人能帮帮忙吗 ,自己顶一下
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |