I have know the work in loopback mode,this is FlexCAN performs an internal loop
back that can be used for self test operation.
But how can I get the data from I send!
I don't know that
Receiving CAN data messages
When a CAN data message is received it is placed in a free receive buffer and the owner task is notified of the fact via an interrupt event. It can then pick up the data by calling the generic fnRead(). It is not necessary to specify the read length since data should be read as a block from a single buffer, however there are a number of options available.
...... case INTERRUPT_EVENT: // on an interrupt event
switch (ucInputMessage[MSG_INTERRUPT_EVENT]) {
case CAN_RX_MSG:: // A CAN rx. message is waiting
Length = fnRead(CAN_interface_ID, ucInputMessage,
(0 | GET_CAN_RX_TIME_STAMP | GET_CAN_RX_ID));
// collect the message along with some details
break; ......
Can that more detail, tell me how to do in utasker?
??
the freecale give me some code:
this the interrupt
MCF_GPIO_PASPAR=MCF_GPIO_PASPAR_SYNCA_CANRX|MCF_GPIO_PASPAR_SYNCB_CANTX;
/* FlexCAN Soft Reset */
MCF_FlexCAN_CANMCR = MCF_FlexCAN_CANMCR_SOFTRST;
while ((MCF_FlexCAN_CANMCR & MCF_FlexCAN_CANMCR_SOFTRST) != 0x0) {}
/* initialize FlexCANs */
init_flexcan();
/* initialize FlexCAN interrupts */
init_flexcan_interrupts();
/* zero message in receive buffer 1 */
* (vuint32 *) (FLEXCAN_BUFFERS + 0x18) = 0x00000000;
* (vuint32 *) (FLEXCAN_BUFFERS + 0x1C) = 0x00000000;
printf("DONE\n\r");
printf("Received buffer before sending: 0x%08x 0x%08x\n\r", * (vuint32 *) (FLEXCAN_BUFFERS + 0x18), * (vuint32 *) (FLEXCAN_BUFFERS + 0x1C));
/* transmit a message from transmit buffer 0 */
* (vuint32 *) (FLEXCAN_BUFFERS + 0x8) = 0xABCD0022;
* (vuint32 *) (FLEXCAN_BUFFERS + 0xC) = 0xBABA1234;
MCF_FlexCAN_CANMCR &= ~(MCF_FlexCAN_CANMCR_HALT); //leave HALT
/* await for synchronisation */
for (i=1;i<255;i++) {}
//from some reason, this didn't work in loopback mode
//while (MCF_CAN_CANMCR0 & MCF_CAN_CANMCR_NOTRDY == MCF_CAN_CANMCR_NOTRDY) {}
* (vuint16 *) FLEXCAN_BUFFERS = 0x0C08; //write CODE for transmission of 8 bytes
/*********************************************************************************************/
__declspec(interrupt)
void Rx_Buffer1(void)
{
/* display received data */
printf("Received data after sending: 0x%08x 0x%08x\n\r", * (vuint32 *) (FLEXCAN_BUFFERS + 0x18), * (vuint32 *) (FLEXCAN_BUFFERS + 0x1C));
MCF_FlexCAN_IFLAG|= MCF_FlexCAN_IFLAG_BUF1I;
}