fsl_mcan.c not able to clear bits in XIDFC and GFC registers?

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

fsl_mcan.c not able to clear bits in XIDFC and GFC registers?

1,161 Views
Ken_V
Contributor I

I am using the LPC54608 microcontroller and the SDK for Keil tools IDE.

In my application I need to change the acceptance registers from what was originally set up.

The "MCAN_SetFilterConfig" function to set the registers, but it only ORs the value, so bits already set can't be cleared...

base->GFC |= CAN_GFC_RRFE(config->remFrame) | CAN_GFC_ANFE(config->nmFrame);
base->XIDFC |= CAN_XIDFC_FLESA(config->address >> CAN_XIDFC_FLESA_SHIFT) | CAN_XIDFC_LSE(config->listSize);

Is this a bug, or is there something I'm missing?

0 Kudos
Reply
3 Replies

1,073 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Ken,

If you want to change the acceptance registers, yes, you really need your second code (FIXED CODE), because your original code keep original setting.

BR

Alice

BR

Alice

0 Kudos
Reply

1,151 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Ken,

About set CAN ID filter, you can have a look at this thread:

 

https://community.nxp.com/t5/LPC-Microcontrollers/CAN-with-Extended-ID-filtering-how-to-set-multiple...

 

 

BR

Alice

0 Kudos
Reply

1,091 Views
Ken_V
Contributor I

I have no problem setting up multiple filter configurations...

I need to change the configuration later at some point in time and the current driver code does not allow doing that unless I preclear the registers or fix the driver code as shown below to set it equal to the config settings instead of ORing them...

ORIGINAL CODE

// base->GFC |= CAN_GFC_RRFE(config->remFrame) | CAN_GFC_ANFE(config->nmFrame);
// base->XIDFC |= CAN_XIDFC_FLESA(config->address >> CAN_XIDFC_FLESA_SHIFT) | CAN_XIDFC_LSE(config->listSize);

FIXED CODE
base->GFC = CAN_GFC_RRFE(config->remFrame) | CAN_GFC_ANFE(config->nmFrame);
base->XIDFC = CAN_XIDFC_FLESA(config->address >> CAN_XIDFC_FLESA_SHIFT) | CAN_XIDFC_LSE(config->listSize);

 

Is there something I'm missing that makes this work correctly with supplied drivers?

Tags (1)
0 Kudos
Reply