Peder Alm

TXE0 flag in CANTFLG never set after CAN message sent and message send forever

Discussion created by Peder Alm on Sep 13, 2006
Latest reply on Sep 13, 2006 by Peder Alm
Code:
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<length;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; }

 When I try to send a CAN message using the CAN0SendFrame (APPNOTE AN3034), my message send not one time but the same message forever. And the TXE0 flag never set in the last while statment and the program never go further. How can the message be sent over and over again? What to do?
 
(using MC9S12XDT256)

Outcomes