How to reconfigure Flexcan mailbox

cancel
Showing results for 
Search instead for 
Did you mean: 

How to reconfigure Flexcan mailbox

Jump to solution
916 Views
niranjanravi
Contributor V

Hi,

   I am working on FRDM tower boards to establish CAN bus communication.  I was successful in my approach to send and receive data between two FRDM tower boards using CAN bus. However, I am not able to understand few parts.

1. What is a mailbox? Is this the CAN ID for the device or this specifies the memory location?

2. In flexcan_interrupt_transfer.c example, 

/* Set Rx Masking mechanism. */
FLEXCAN_SetRxMbGlobalMask(EXAMPLE_CAN, FLEXCAN_RX_MB_STD_MASK(rxIdentifier, 0, 0)); 

is used. Why does there have to be  a masking?

Now I am trying a receive data from a different board into my tower board using CAN bus. But the other board does not have flexCAN, it works like a simple CAN. My other board is sending its CAN ID, Node ID and data altogether where I need to mask it in tower board side to get individual ID.

I am not able to get a clear idea of how FlexCAN works.I checked but could not find any documentation which would explain me the basics of flexcan. It would be great if someone could point me in the right direction in above questions and documentation as well.

Board: twrKf120

Example: flexcan_interrupt_transfer

Thank you

Thanks and Regards

Niranjan

Tags (2)
1 Solution
558 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Hi Niranjan,

Please check the following link:

https://www.nxp.com/docs/en/reference-manual/K21P144M120SF5RM.pdf

I was wrong , the chapter is the 48, I will put the chapters corrected bellow.

1.- Please check the section 48.4, there there explain the structure of the mailbox.

2.- Please check the section 48.3.5, this is the register write in this function.

Also, for your second question check the section.

48.3.35 Rx FIFO structure

I think the RTR bit should help you to do what you want.

Best Regards,

Alexis Andalon

View solution in original post

6 Replies
558 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Hi Niranjan,

1.- Please check the section 52.4, there explain the structure of the mailbox.

2.- Please check the section 52.3.5, this is the register write in this function.

3.- FlexCAN works the same as CAN, only include some extra functionality.

As a suggestion, first I will try the loopback example and after that try connecting with the other board.

Best Regards,

Alexis Andalon

558 Views
niranjanravi
Contributor V

Hi,

   adding one more question to below one:

FlexCan has a global Mask function (SetRxMbGlobalMask) but I wanted to use filter function as well. I could not see a default function like that? Can you tell me whether I have to write up a particular function to filter out the IDs or any workaround is possible in existing functions?

The id which I am looking to filter out is 0x760. I am not bothered about the rest of the IDs from the other device. 

Thank you

Thanks and Regards

Niranjan

0 Kudos
559 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Hi Niranjan,

Please check the following link:

https://www.nxp.com/docs/en/reference-manual/K21P144M120SF5RM.pdf

I was wrong , the chapter is the 48, I will put the chapters corrected bellow.

1.- Please check the section 48.4, there there explain the structure of the mailbox.

2.- Please check the section 48.3.5, this is the register write in this function.

Also, for your second question check the section.

48.3.35 Rx FIFO structure

I think the RTR bit should help you to do what you want.

Best Regards,

Alexis Andalon

558 Views
niranjanravi
Contributor V

Hi,

    Thank you for your inputs. I was able to get a partial code get working. 

Now I am facing issue in the TxIdentifier [mailbox] .  The frame holds id and data in flexcan. The destination CAN ID to which I had to send the data is 1002F801(Hex value).

So I mapped 1002F801(Hex value) to my frame.id parameter(like frame.id = 0x1002F801 ) in flexcan code , its not sending the frame like how i expect. 

I used an external SLCAN adapter to visualize it . I could see the CAN ID as 178 and 05 C9 is my value which i am sending. 

pastedImage_2.png

I checked MCU xpresso code and I could find this 

pastedImage_3.png

Few puzzling things are:

1.frame.id = 0x1002F801 is good enough to map the destination frame id? Or any work around is needed over here? Not sure how.

2. With respect to Tx, does TxIdentifier can be different from frame id? Because in the example code I could see frame.id being derived from TxIdentifer(29 bit identifier mask) [I also have a 29 bit identifier in my case in both sides].

Whereas, I know the destination id [1002F801] to which I need to send the data. Any simple approach is possible?

Any pointers would be helpful.

Thank you

Thanks and Regadrs

Niranjan

0 Kudos
558 Views
niranjanravi
Contributor V

Hi,

   Please ignore the above post. I got it figured. It was an issue with base and extended frame formats.

Thank you

Regards

Niranjan

0 Kudos
558 Views
niranjanravi
Contributor V

Hi,

    Thank you for your reply. It would be great if you could attach the document which you are referring to. I am not able to find it

Thank you

Regards

Niranjan

0 Kudos