MPC5534 CAN Filter mask register

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MPC5534 CAN Filter mask register

2,856 Views
vitra_hk
Contributor I

Hi,

I'm working on FlexCAN on MPC5534, i want  to set acceptance filter mask for CAN2_RX14 and CAN2_RX15 I've prepared the masks for both these registers and set the CAN ID's for the same. For CAN2_RX15 i need to filter 9 CAN ID's out which one CAN ID is set, the problem is i'm not receiving other 8 CAN ID's ,and MBFEN is negated. Is the any register configuration i'm missing?

Labels (1)
0 Kudos
Reply
12 Replies

1,854 Views
martin_kovar
NXP Employee
NXP Employee

Hi Hareesha,

I have created simple example for you, which shows, how to set FlexCAN. Example is described in detail, but if you have any question about it, please write me back.

Regards,

Martin

0 Kudos
Reply

1,854 Views
vitra_hk
Contributor I

Hi Martin,
I will check and revert back.

Meantime I see MBFEN flag is not written anywhere.

Regadrs,

Hareesha

0 Kudos
Reply

1,854 Views
martin_kovar
NXP Employee
NXP Employee

Hi,

this flag is set to 0 by default, so it is not necessary to set it.

Regards,

Martin

0 Kudos
Reply

1,854 Views
vitra_hk
Contributor I

Hello Martin,

The basic CAN communication code is working since many years, but only missing part was acceptance filtering has not been used, nor was enabled.  Now I am using the very same code and wanting to add MASK values to MB#14, 15.

1) Can you confirm, is the individual masking feature available in MPC5534, i.e. making MBFEN = TRUE?

2) I have no particular constraint whether to use legacy style or individual masking. I just happen to code the legacy style and hence all my above explanations include MBFEN = 0.

3) I am even reading the mask register values during run time and is reading correctly to configured values. However the entire flexCAN is showing the behavior as though there is no masking configured.

4) I request you to provide me with a sample project where the acceptance filtering is set to MB14, 15 & global. I can then refer to your code and maintain the same sequence.

Regards,

Hareesha

0 Kudos
Reply

1,854 Views
martin_kovar
NXP Employee
NXP Employee

Hi Hareesha,

I am sorry for long delay, but I was on vacation last week. I am little bit busy right now, but if you give me few days, I will create some example for you.

About you questions:

1) Yes, if you set MBFEN = 1, individual masking is available.

2) This is application dependent. There are not  particular constraints how to use legacy and individual mode.

Regards,

Martin

0 Kudos
Reply

1,854 Views
martin_kovar
NXP Employee
NXP Employee

Hi,

at first, MBFEN determines, which type of masking is used. If you set MBFEN to 0 you use legacy mode with one global mask register and RX14 and RX15 mask register (from your description it seems, you want this mode). If you set MBFEN to 1, you use individual masking for each register. You can look at the reference manual

From your description, I am not able to tell you, what is wrong. So please write me, which IDs you want to receive by MB14 and  MB15 and what mask you set.  I suppose you set this registers: CANxRX14MASK and CANxRX15MASK.

Regards,

Martin

0 Kudos
Reply

1,854 Views
vitra_hk
Contributor I

Hi Martin,

Thank for your response, i want to receive 18FEE621 and 18FEE626 on MB14  and the mask i have set is 1FFFFFF8, for MB15 i want to receive 18EA0121, 18EA0126,18EA0190, 18ECFF21, 18ECFF26,18ECFF19, 18EBFF21, 18EBFF26 ,18EBFF90 and the mask i have set is 1FF80140, also I've set MBFEN = 0.

Regards,

Hareesha

0 Kudos
Reply

1,854 Views
martin_kovar
NXP Employee
NXP Employee

Hi,

I checked your mask settings and it seems it is correct. How do you initialize MB14 and MB15? After the message is received, do you correctly handle the data? Do not forget about locking and unlocking MB while you read MB. Please look at the reference manual chapter 21.4.3.1.

pastedImage_1.png

If you still have the issue, please upload here your project (as simple as possible), which demonstrates the issue and I will try to check your configuration.

Regards,

Martin

0 Kudos
Reply

1,854 Views
vitra_hk
Contributor I

Hi Martin,

Sorry for the delayed response, so the following are my register configuration

1. CAN2_MCR register - Enable freeze mode- MDIS = 0, FRZ =1, HALT = 1, NOTRDY = 1, SOFTRST = 0, FRZACK = 1, MAXMB = 0x3F;

2. Set baud rate 250kbps PRESDIV = 3, RJW = 1, PSEG1 = 2, PSEG2 = 1, CLKSRC=0, PROPSEG=1

3. Configure Message buffer structure  CODE = 0000 (INACTIVATE for RX), IDE = 1, ID = 0x18FEEE621

4. CAN2_MCR register - Disable freeze mode- MDIS = 0, FRZ =0, HALT = 0, NOTRDY = 0, SOFTRST = 0, FRZACK = 0, MAXMB = 0x3F;

5.Enable buffer Interrupt CAN2_IMRL.BUF14M =  1

6. CAN2_MCR.MBFEN = 0;

7. Enable buffer 14 mask CAN2_RX14MASK = 0x1FFFFFF8

Regards,

Hareesha

0 Kudos
Reply

1,854 Views
martin_kovar
NXP Employee
NXP Employee

Hi Hareesha,

if you use 8MHz crystal as a source clock, it seems PSEG1 should be 1 instead of 2 and PROPSEG should be 2 instead of 1 (please look at the following document).

FlexCAN bit timing calculation

You have set MB14 CODE to 0x4 instead of 0x0 after you set IDE and ID.

The rest of the configuration also seems to be correct.

What is the second side which transmits data? Did you measure you really send all three CAN messages you want to receive by MB14?  Did you correctly implement reading data from MB14 according to reference manual?

You can try to receive data without masking. This could help you to discover, if there is a problem with masking or general problem with timing or receive data handling.

If it is possible, please share some simple project which shows your issue. From the partial information, it is nearly impossible to check the problem.

Regards,

Martin

0 Kudos
Reply

1,854 Views
vitra_hk
Contributor I

Hello Martin,

The basic CAN communication code is working since many years, but only missing part was acceptance filtering has not been used, nor was enabled.  Now I am using the very same code and wanting to add MASK values to MB#14, 15.

1) Can you confirm, is the individual masking feature available in MPC5534, i.e. making MBFEN = TRUE?

2) I have no particular constraint whether to use legacy style or individual masking. I just happen to code the legacy style and hence all my above explanations include MBFEN = 0.

3) I am even reading the mask register values during run time and is reading correctly to configured values. However the entire flexCAN is showing the behavior as though there is no masking configured.

4) I request you to provide me with a sample project where the acceptance filtering is set to MB14, 15 & global. I can then refer to your code and maintain the same sequence.

Regards,

Hareesha

0 Kudos
Reply

1,854 Views
vitra_hk
Contributor I

Hi Martin,

1. The Flex CAN is working fine, i don't think the problem is with the crystal frequency.

2. MB14 CODE is set to 0x00 and the to 0x04.

3. The second side is via CANalyser, the problem is out of the 2 CAN ID's (i.e 18FEE621 and 18FEE626 ) on MB14 with ID as 18FEE621 and mask as 0x1FFFFFF8, only i am able to receive only frames with this CAN ID 18FEE621 and not this CAN ID 18FEE626.

4. Without masking the all frames with CAN ID mentioned above are received.

Regards,

Hareesha

0 Kudos
Reply