Freemaster 2.0 and S32 FLEXCAN

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

Freemaster 2.0 and S32 FLEXCAN

Jump to solution
2,192 Views
gearhead1107
Contributor IV

I'm trying to use Freemaster 2.0 over CAN, however the configuration method isn't exactly clear.

I got Freemaster to work over UART (and it's excellent), but when I instead go to freemaster_cfg.h and make the following changes:
#define FMSTR_USE_FLEXCAN      1 

/* Select RX and TX FlexCAN Message buffers */
#define FMSTR_FLEXCAN_TXMB 4
#define FMSTR_FLEXCAN_RXMB 5 //MB0-3 are used by application

There doesn't appear to be any activity from Freemaster. What's not clear is:

-How do I set the actual TX and RX ID's for Freemaster to use? I see private functions, however it's not clear how I'm "supposed" to manipulate those commands

-Do I need to put FMSTR_ISR(); in the existing CAN interrupt handler?

Is there a setup guide to help with the CAN configuration? It was relatively straightforward with UART, however I haven't seen much for using CAN.

Thank you,

Andrew

1 Solution
1,534 Views
gearhead1107
Contributor IV

Came back with some fresh eyes and got this figured out. I'll go over the "obvious" stuff, especially if you have used Freemaster over UART, and then get into the non-obvious.

Obvious configuration things - as found in examples, documentation, etc.:

Even if you have Freemaster included in your S32DS project, you still need:

  • A freemaster_cfg.h file with your settings
    • FMSTR_USE_FLEXCAN set to 1
    • FMSTR_FLEXCAN_TXMB and RXMB set to used message buffers that aren't used in your application
  • FMSTR_Init(); in your init sequence
  • FMSTR_Poll(); in your loop

What's *not* obvious:

  • Freemaster uses FLEXCAN instance Zero (with address of 0x40024000UL) set in "freemaster_cfg.h". If you want to change the instance, look in S32K144.h for the corresponding address, such as CAN0_BASE.
    • In order for Freemaster to run, you need to put  FMSTR_Isr(); in the interrupt handler for that instance. If using PE, you want to put that line at the top of the code for FLEXCAN_DRV_IRQHandler(uint8_t instance), and make sure it runs on instance 0
  • The addresses Freemaster will use on CAN are in "freemaster_defcfg.h", which are by default 0x7AA for transmit and receive, you can change by looking for FMSTR_CAN_CMDID.
    • If you don't define a message buffer, it will use buffers 0 and 1 by default
  • If using Intrepid CAN tools, you cannot run their software and run Freemaster 2.0 at the same time

View solution in original post

3 Replies
1,535 Views
gearhead1107
Contributor IV

Came back with some fresh eyes and got this figured out. I'll go over the "obvious" stuff, especially if you have used Freemaster over UART, and then get into the non-obvious.

Obvious configuration things - as found in examples, documentation, etc.:

Even if you have Freemaster included in your S32DS project, you still need:

  • A freemaster_cfg.h file with your settings
    • FMSTR_USE_FLEXCAN set to 1
    • FMSTR_FLEXCAN_TXMB and RXMB set to used message buffers that aren't used in your application
  • FMSTR_Init(); in your init sequence
  • FMSTR_Poll(); in your loop

What's *not* obvious:

  • Freemaster uses FLEXCAN instance Zero (with address of 0x40024000UL) set in "freemaster_cfg.h". If you want to change the instance, look in S32K144.h for the corresponding address, such as CAN0_BASE.
    • In order for Freemaster to run, you need to put  FMSTR_Isr(); in the interrupt handler for that instance. If using PE, you want to put that line at the top of the code for FLEXCAN_DRV_IRQHandler(uint8_t instance), and make sure it runs on instance 0
  • The addresses Freemaster will use on CAN are in "freemaster_defcfg.h", which are by default 0x7AA for transmit and receive, you can change by looking for FMSTR_CAN_CMDID.
    • If you don't define a message buffer, it will use buffers 0 and 1 by default
  • If using Intrepid CAN tools, you cannot run their software and run Freemaster 2.0 at the same time
1,534 Views
jiri_kral
NXP Employee
NXP Employee

Hi Andrew, 

you only need to enable FlexCAN communication by 

 #define FMSTR_USE_FLEXCAN      1        

and disable UART. 

In FreeMaster communication driver you can find examples for multiple MCUs. Anyway - which MCU are you using? S32K144? 

Jiri

0 Kudos
1,534 Views
gearhead1107
Contributor IV

Thanks Jiri,

Yes, I'm using the S32K144 FRDM board

I understand that's how the documentation says it's "supposed" to work.. but that's exactly what I've done in freemaster_cfg.h, and it doesn't work. 

My application communicates on FlexCAN MB 0,1,2, and 3 just fine, however when I use the Freemaster CAN communication wizard, communication times out because the FMSTR code won't respond on 0x7AA.Freemaster CAN.jpg

I looked at the example for the S32 in the driver package, however it wasn't useful since the example is for SCI, not CAN. I may be looking in the wrong example, of course - if you could be more specific on which one works with CAN it would be very helpful.

Again - 0x7AA TX/ RX is the default communication setting in the PC application - but where am I supposed to set this in the S32's configuration? If I instead want to set the ID to 0x7FF it's not clear on how I need to do that - the only thing that I can tell is setting "1" for "FMSTR_USE_FLEXCAN" which seems insufficient.

0 Kudos