Hi , I started one transmission of MSCAN using the code as follows. However, the program is always running in the code"while ( (CAN1TFLG & txbuffer) != txbuffer);". And can not jump out. I checked the registers, and the CAN1TFLG=0b00000110. Which means TX0 buffer in not empty after I start one transmission. What is the problem?
CAN1TBSEL = CAN1TFLG; /* Select lowest empty buffer */
txbuffer = CAN1TBSEL; /* Backup selected buffer */
CAN1TFLG = txbuffer; /* Start transmission */
while ( (CAN1TFLG & txbuffer) != txbuffer); /* Wait for Transmission* completion*/