Send CAN Frame with an 16-bit MC9S12XF512MLM

Discussion created by Richard DE MIRANDA on Feb 15, 2012
Latest reply on Feb 16, 2012 by Richard DE MIRANDA

Hi everyone,


From begining, i'm sorry in advance about my english expression.


I have a little problem in programming an MCU 16-bit MC9S12XF512MLM. I have two developement tool card with the MC9S12XF512MLM that i connect with FLEXRAY and CAN module. The example give by freescale show that the two card are communicating correctly.


But when i try to send an CAN frame frome one NODE and receive the frame in the second NODE, i can't do it.


I'm using the folowing structure for sending a CAN FRAME :



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; }

 And this one for receiving the frame :


void vfnCAN_ReceivedFrame(void){    /* Length of received frame */    UINT8 u8Length;        /* Index for extracting/storing received data */    UINT8 u8Index;        /* Reception array */    UINT8 u8RxData[8];    u8Length = (CAN0RXDLR & 0x0F);  /* Extract received frame data length */      /* Read and store each of the received data */     for (u8Index=0; u8Index<u8Length; u8Index++)           u8RxData[u8Index] = *(&CAN0RXDSR0 + u8Index);     CAN0RFLG_RXF = 1;   /* Clear reception flag */     }



If you have an idea about the problem, i will be greatful.


Thanks in advance,


Best Regards,