S32K344 FlexCAN Change Highest-priority message buffer first to Lowest-number message buffer first

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

S32K344 FlexCAN Change Highest-priority message buffer first to Lowest-number message buffer first

245 Views
bruceyun
Contributor II

Hi all, 

I am working on a project to route CAN messages. I found out that CAN write block by default has arbitration process, which choose highest-priority CAN message buffer to send first. I want to change it to lowest-number message buffer to send first. 

After I read document, there are some lines: 

73.3.3.1
Lowest-number message buffer first
"If CTRL1[LBUF] is 1, the first (lowest number) active transmission message buffer found is the arbitration winner. MCR[LPRIOEN] has no effect when CTRL1[LBUF] is 1."

So I am trying to write CTRL1[LBUF] to 1. I believe that I need to change to Freeze Mode. 

"MCR[FRZ] must be 1 and the module must not be in a low-power mode"

"After requesting Freeze mode, you must wait for MCR[FRZACK] to become 1 before executing any other action, otherwise FlexCAN may operate unpredictably. In Freeze mode, all memory-mapped registers are accessible."

 

I tried to write MCR[FRZ] to 1 but I failed to change to Freeze mode. Can anyone here have the knowledge about this? I appreciate it. 

 

##S32K34 #FlexCAN #CAN #Route #AUTOSAR #NXP

0 Kudos
Reply
1 Reply

227 Views
SorinIBancila
NXP Employee
NXP Employee

Hello,

 

To put the FLEXCAN module into FreezeMode, we can use the S32K3 RTD functions:

  • FlexCAN_Ip_EnterFreezeMode_Privileged(uint8 instance)
  • FlexCAN_Ip_ExitFreezeMode_Privileged(uint8 instance)
 
To test this I've added the following blocks to an already existing model that sends messages over CAN. Basically, I have a variable CAN_0_enterfreeze which I modify from the FreeMASTER to have one of the following values:
  • 0: Do nothing
  • 1: read MCR register for CAN 0 instance and store the result in CAN_0_MCR
  • 2: Enter FreezeMode
  • 3: Exit FreezeMode
SorinIBancila_0-1754053072043.png

 

Inside case 2 and case 3, you have to add a MATLAB function block. The custom code to enter/exit freezemode can be found below:

SorinIBancila_1-1754053486901.png

 

To validate this I've done the following:

  • Reset the development board and read the content of MCR register for CAN 0 instance. 
SorinIBancila_2-1754053730649.png

 

  • Set CAN_0_enterfreeze to 2 and read the content of the MCR register. Note! The FlexCAN is not working in FreezeMode.SorinIBancila_3-1754053812864.png
 SorinIBancila_5-1754053865424.png

 

  •  Set CAN_0_enterfreeze to and read the content of the MCR register. The CAN is working again. I just send a message (ID = 101) from CAN analyzer tool and the board replies with a message ID=0.
SorinIBancila_6-1754053942109.pngSorinIBancila_7-1754053978440.png

 

The S32K3 RTD sources can be found inside the toolbox, where you can check the implementation for a specific module in case you need it. To open the root of the S32K3 folder, you can type the following command in MATLAB command window : cd(mbd_find_s32k3_root)

SorinIBancila_0-1754059684536.png

 

 

 

Do not hesitate to reply in case you have any other questions.

 

Best regards,

Sorin Bancila

0 Kudos
Reply