- UID
- 145509
- 性别
- 男
|
我的芯片MC9S12DG128,首先把我的CAN发送驱动提供给大家,是调通了的
但存在这样一个问题,当连续发多条消息时,中间必须加延时,否则只能发出一条消息
想请问大家这是什么原因?谢谢!!
unsigned char CAN0SendFrame(unsigned long id, unsigned char priority, unsigned char length, unsigned char *txdata ){
unsigned char index;
unsigned char txbuffer = {0};
if (!CAN0TFLG) /* Is Transmit Buffer full?? */
return ERR_BUFFER_FULL;
CAN0TBSEL = CAN0TFLG; /* Select lowest empty buffer */
txbuffer = CAN0TBSEL; /* Backup selected buffer */
/* Load Id to IDR Registers */
*((unsigned long *) ((unsigned long)(&CAN0TXIDR0)))= id;
for (index=0;index
*(&CAN0TXDSR0 + index) = txdata[index]; /* Load data to Tx buffer
* Data Segment Registers
*/
}
CAN0TXDLR = length; /* Set Data Length Code */
CAN0TXTBPR = priority; /* Set Priority */
CAN0TFLG = txbuffer; /* Start transmission */
while ( (CAN0TFLG & txbuffer) != txbuffer); /* Wait for Transmission
* completion
*/
return NO_ERR;
} |
|