FreeMaster Over CAN on interrupt fail to compile in polling mode

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

FreeMaster Over CAN on interrupt fail to compile in polling mode

190 Views
millerhughes
Contributor II

 

I try to change those 3 mico for enabling polling mode from code generated from  "FreeMaster over CAN" and "s32k3xx_fm_over_can_s32ct" 

FMSTR_SHORT_INTR, FMSTR_POLL_DRIVEN, and FMSTR_DEBUG_TX

but end with compiling failed, reason is that transfer feature freemaster over can from "s32k3xx_fm_over_can_s32ct"  reply on interrupt, but if motor control case using many irq like least 10khz fast task and bctu and hall , wagtch dog, freemaster received no response from controllewr k312, polling mode is necessary.

how to enable those 3 micros and open polling mode for "s32k3xx_fm_over_can_s32ct" 

0 Kudos
Reply
6 Replies

170 Views
iulian_stan
NXP Employee
NXP Employee

Hi @millerhughes,

To enable Polling mode you need to update the following macros:

#define FMSTR_LONG_INTR    0
#define FMSTR_SHORT_INTR   0
#define FMSTR_POLL_DRIVEN  1

only one out of those 3 should be set to 1, overwise the code won't compile.

Regarding FMSTR_DEBUG_TX - this is a debug macro that is meant to verify the TX line. Combined with previous definitions this one:

#define FMSTR_DEBUG_TX  1

will instruct FreeMASTER Driver to continuously send a debug frame (note: this helps you inspecting the TX line and you won't be able to connect to the board using FreeMASTER tool while this functionality is enabled).

Could you share your compilation error logs ?

As far as I know, s32k3xx_fm_over_can_s32ct example is implemented by Model-Based Design Toolbox (MBDT) team. If you develop your application using Simulink, it may require updating block configuration instead of manual code changes. In this case, MBDT developers can provide better assistance for your use case through the dedicated MBDT community.

0 Kudos
Reply

163 Views
millerhughes
Contributor II

I did try before using same setting as you:

for example,  I changed FMSTR_POLL_DRIVEN as 1 (was 0.as interrupt mode)

// Select interrupt or poll-driven serial communication

#define FMSTR_LONG_INTR 1 // Complete message processing in interrupt

#define FMSTR_SHORT_INTR 0 // Queuing done in interrupt

#define FMSTR_POLL_DRIVEN 1/*0 */

 

7 error: mainly because of

#if (FMSTR_LONG_INTR && (FMSTR_SHORT_INTR || FMSTR_POLL_DRIVEN)) || \

(FMSTR_SHORT_INTR && (FMSTR_LONG_INTR || FMSTR_POLL_DRIVEN)) || \

(FMSTR_POLL_DRIVEN && (FMSTR_LONG_INTR || FMSTR_SHORT_INTR)) || \

!(FMSTR_POLL_DRIVEN || FMSTR_LONG_INTR || FMSTR_SHORT_INTR)

/* mismatch in interrupt modes, only one can be selected */

#error You have to enable exctly one of FMSTR_LONG_INTR or FMSTR_SHORT_INTR or FMSTR_POLL_DRIVEN

#endif

 3 error happen above for compile

 

../FMsrc/freemaster_private.h:326:2: error: #error You have to enable exctly one of FMSTR_LONG_INTR or FMSTR_SHORT_INTR or FMSTR_POLL_DRIVEN

326 | #error You have to enable exctly one of FMSTR_LONG_INTR or FMSTR_SHORT_INTR or FMSTR_POLL_DRIVEN

| ^~~~~

../FMsrc/freemaster_private.h:326:2: error: #error You have to enable exctly one of FMSTR_LONG_INTR or FMSTR_SHORT_INTR or FMSTR_POLL_DRIVEN

326 | #error You have to enable exctly one of FMSTR_LONG_INTR or FMSTR_SHORT_INTR or FMSTR_POLL_DRIVEN

| ^~~~~

 

../FMsrc/freemaster_private.h:326:2: error: #error You have to enable exctly one of FMSTR_LONG_INTR or FMSTR_SHORT_INTR or FMSTR_POLL_DRIVEN

326 | #error You have to enable exctly one of FMSTR_LONG_INTR or FMSTR_SHORT_INTR or FMSTR_POLL_DRIVEN

| ^~~~~

 

 

one is not enough, but two even all also failed.

0 Kudos
Reply

159 Views
iulian_stan
NXP Employee
NXP Employee

Communication modes are mutually exclusive options. That's exactly what the error message means.
FreeMASTER Driver routine may require a significative processing time and those 3 settings try to help developers to balance the execution depending on use case as follows:

  • FMSTR_POLL_DRIVEN - FreeMASTER routine is executed entirely in the FMSTR_Poll function - developers decides when it is called but has to make sure that it is invoked at such frequency that allows FreeMASTER to keep up with the communication speed
  • FMSTR_LONG_INTR - FreeMASTER routine is executed entirely in the FMSTR_CanIIsr function - deveopers forces the system to executed it by assigning a higher priority (I assume this one was used as it fits best in case of big number of interrupts)
  • FMSTR_SHORT_INTR - is a mix of the previous two: the communication is happening in the interrupt handler (FMSTR_CanIsr), but the processing - in (FMSTR_Poll)

I think what you want to try is the last one (combination of polling + interrupt). Still, while the interrupt may guarantee that the CAN frames will be read, the board may not reply on time if FMSTR_Poll is not invoked frequently enough (due to interrupts with higher priority). As a result - FreeMASTER desktop tool will show timeout errors.

The developer has to make sure that the system can allocate sufficient time for FreeMASTER Driver routines in compute intensive applications.

Hope it clarifies FreeMASTER's communication modes.

0 Kudos
Reply

107 Views
millerhughes
Contributor II

thanks for clarification, yes, combination of polling + interrupt is my target.

restate issue: target k312 fail to send response after freeamster running a while.

now feedback is following:

interrupt mode: freemaster working, issue shown above, FMSTR_LONG_INTR only

polling mode: compile,, freemaster not working ,  FMSTR_POLL_DRIVEN even if remove error message on freemaster_private.h:326:2:

mixed: freemaster working, can compile  but traffic issue remain , all three of FMSTR_LONG_INTR or FMSTR_SHORT_INTR or FMSTR_POLL_DRIVEN set as 1 and removing error message on freemaster_private.h:326:2:

now I justify :Could be my CAN driver issue.

which information do you need if your can provide further support?

0 Kudos
Reply

87 Views
iulian_stan
NXP Employee
NXP Employee

Hi @millerhughes,

I would try to troubleshoot the FMSTR_LONG_INTR mode, considering it is the only mode that works, even if only for a short time. The things I would look into are:

  1. Can you inspect the CAN bus with a logic analyzer and check whether the CAN messages are no longer being sent from the board, or if they are being sent but become corrupted?
  2. How many variables are you reading on the PC side? The number of variables is directly proportional to the amount of data exchanged between the PC tool and the board. If possible, I would start with a few variables and gradually increase the number to see when it breaks.
  3. Is the CAN instance used by any routines other than the FreeMASTER Driver?

Did you start with a MATLAB/Simulink model or an S32 Design Studio example application? Depending on the original source, the FreeMASTER CAN driver implementation may differ.

If possible, please attach the source files (they should be named freemaster_s32_flexcan.h and freemaster_s32_flexcan.c).

0 Kudos
Reply

60 Views
millerhughes
Contributor II

1, I used peakcan view to monitor message flow,

yes, CAN messages are no longer being sent from the board

when freeamster smoothly working, message flashing very fast; when freeamaster freeze, CAN message sent from S32k312minEVB stopped apparently  but message read from freemaster still visible and slow;

2, totally less 20 variables, but amount is much smaller than demon fm project s32k312_mc_pmsm_2sh_s32ct.pmpx "s32k344_mc_pmsm_2sh_s32ct"

3.CAN instance solely used by freemaster;

you are right,  our BSW use RTD ,to implement FM over CAN,  flexcan_43 and flexcan_ipw  layer from DEMON s32k3xx_fm_over_can_s32ct MCAL driver are integrated. but still working with issue above.

by the way, due to CAN IP layer limit, our can driver can accept standard msg ID, so freeamster configue setting : send standard, receeive extension.

 

please find atatched 4 files I have, which are close to you.

do you need all CAN IP configure files? actually all 43/ipw configure same as demon s32k3xx_fm_over_can_s32ct.

You can also directly email me.

 

0 Kudos
Reply