FreeMASTER CAN Example S32K144 for S32DS 3.4

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

FreeMASTER CAN Example S32K144 for S32DS 3.4

Jump to solution
2,158 Views
CY9
Contributor III


Hi,

I don't have MCUXpresso , I am using S32DS 3.4. Build 201217(Update3)

I tried to implement FreeMaster using S32DS on S32K144 with CAN.

The example of the SDK is communication with UART.

I saw there are CAN examples on S32K3xx uC and I tried porting to S32K144 but it resulted in too many errors.

There don't seem to be enough examples to explain how to communicate with CAN on the 144.

My product might work from several kilometers away, so cannot use UART communication.

Can you provide some sample code for CAN communication using S32K1xx on S32DS.

Thanks.

Tags (3)
0 Kudos
Reply
1 Solution
2,128 Views
iulian_stan
NXP Employee
NXP Employee

Hi @CY9

Please find attached the S32 Design Studio project.

Note: This project was build with S32DS 3.5 and S32SDK 4.0.1.

View solution in original post

0 Kudos
Reply
5 Replies
2,129 Views
iulian_stan
NXP Employee
NXP Employee

Hi @CY9

Please find attached the S32 Design Studio project.

Note: This project was build with S32DS 3.5 and S32SDK 4.0.1.

0 Kudos
Reply
1,891 Views
CY9
Contributor III

Dear iulian_stan,

There seems exist too much define in the project, cause sometimes definition mix up?

Ref: 

CY9_0-1728024003079.png

I did NOT config and define any USRT in project, but it try to call FMSTR_InitSerial()‵ which is included in definition :

#if FMSTR_USE_SERIAL
    /* initialize communication and start listening for commands */
    if (!FMSTR_InitSerial())
        return FMSTR_FALSE;
#endif 

And the `FMSTR_USE_SERIAL` is =0 now. 

#define FMSTR_DISABLE          0    /* ... */
#define FMSTR_USE_LPUART       0    /* !!!!! */
#define FMSTR_USE_FLEXCAN      1    
#define FMSTR_USE_PDBDM        0    
//...
#if (FMSTR_USE_SCI) || (FMSTR_USE_ESCI) || (FMSTR_USE_LPUART) || (FMSTR_USE_JTAG) || (FMSTR_USE_USB_CDC) || (FMSTR_USE_MQX_IO) || (FMSTR_USE_MBED)
  #ifndef FMSTR_USE_SERIAL
    #define FMSTR_USE_SERIAL 1
  #else
    #if FMSTR_USE_SERIAL == 0
      #error "FMSTR_USE_SERIAL macro cannot be configured by user, FreeMASTER serial driver functionality is not garanted."
    #endif
    #endif
#else
    #ifndef FMSTR_USE_SERIAL
        #define FMSTR_USE_SERIAL 0
    #endif
#endif

 

0 Kudos
Reply
1,874 Views
iulian_stan
NXP Employee
NXP Employee

Hi @CY9,

FreeMASTER Driver has guards against multiple definitions. This includes communication interface definitions (see freemaster_private.h: 298)

 

/* only one communication link may be selected */
#if (!(FMSTR_DISABLE)) && FMSTR_COUNT_INTERFACES > 1
#error More than one communication interface selected for FreeMASTER driver.
#endif

 

The compiler would through an error should there be incompatible definitions. 
Also, there should be no FMSTR_InitSerial symbol generated in your project if FMSTR_USE_FLEXCAN is defined.

You can check this by inspecting the .map file content or the .elf file symbols.
This output is generated in case of CAN:

 

C:\NXP\S32DS.3.5\S32DS\build_tools\gcc_v6.3\gcc-6.3-arm32-eabi\arm-none-eabi\bin>readelf.exe C:\fmstr_rtd_fcan_s32k144\Debug_FLASH\fmstr_rtd_fcan_s32k144.elf -s | find "FMSTR_InitCan"
   610: 00000e39    56 FUNC    GLOBAL DEFAULT    3 FMSTR_InitCan

C:\NXP\S32DS.3.5\S32DS\build_tools\gcc_v6.3\gcc-6.3-arm32-eabi\arm-none-eabi\bin>readelf.exe C:\fmstr_rtd_fcan_s32k144\Debug_FLASH\fmstr_rtd_fcan_s32k144.elf -s | find "FMSTR_InitSerial"

 

The second command returns an empty result.

I suspect that the clean task may not delete the old elf file or debug configuration does not trigger a full rebuild. This causes the debug session to reuse an older version of the elf file.

0 Kudos
Reply
2,076 Views
CY9
Contributor III

Dear iulian_stan ,

I'd test it by CAN bus , it work ! 

Thanks 

 

 

There exist 2 question,

1.  

FMSTR_PipeDiscardBytes() {
    if(discard > 0) {
        rp = ...;
    }
    pbuff->nRP = rp;
}

So, if (discard<=0) , rp = ??

 

2. 

I had download S32DS 3.5 & update to latest.

After I clean your project, and try to rebuild it , error message :

Building target: fmstr_rtd_fcan_s32k144.elf
Invoking: Standard S32DS C Linker
arm-none-eabi-gcc -o "fmstr_rtd_fcan_s32k144.elf" "@fmstr_rtd_fcan_s32k144.args"
c:/nxp/s32ds.3.5/s32ds/build_tools/gcc_b1620/gcc-6.3-arm32-eabi/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/bin/real-ld.exe: ./SDK/platform/devices/S32K144/startup/system_S32K144.o: in function `SystemInit':
D:\Project\TYC\S32DS35\fmstr_rtd_fcan_s32k144\Debug_FLASH/../SDK/platform/devices/S32K144/startup/system_S32K144.c:69: multiple definition of `SystemInit'; ./SDK/S32K144_SDK_4.0.1/platform/devices/S32K144/startup/system_S32K144.o:D:\Project\TYC\S32DS35\fmstr_rtd_fcan_s32k144\Debug_FLASH/../SDK/S32K144_SDK_4.0.1/platform/devices/S32K144/startup/system_S32K144.c:69: first defined here
c:/nxp/s32ds.3.5/s32ds/build_tools/gcc_b1620/gcc-6.3-arm32-eabi/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/bin/real-ld.exe: ./SDK/platform/devices/S32K144/startup/system_S32K144.o: in function `SystemCoreClockUpdate':
D:\Project\TYC\S32DS35\fmstr_rtd_fcan_s32k144\Debug_FLASH/../SDK/platform/devices/S32K144/startup/system_S32K144.c:128: multiple definition of `SystemCoreClockUpdate'; ./SDK/S32K144_SDK_4.0.1/platform/devices/S32K144/startup/system_S32K144.o:D:\Project\TYC\S32DS35\fmstr_rtd_fcan_s32k144\Debug_FLASH/../SDK/S32K144_SDK_4.0.1/platform/devices/S32K144/startup/system_S32K144.c:128: first defined here
c:/nxp/s32ds.3.5/s32ds/build_tools/gcc_b1620/gcc-6.3-arm32-eabi/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/bin/real-ld.exe: ./SDK/platform/devices/S32K144/startup/system_S32K144.o: in function `SystemSoftwareReset':
D:\Project\TYC\S32DS35\fmstr_rtd_fcan_s32k144\Debug_FLASH/../SDK/platform/devices/S32K144/startup/system_S32K144.c:179: multiple definition of `SystemSoftwareReset'; ./SDK/S32K144_SDK_4.0.1/platform/devices/S32K144/startup/system_S32K144.o:D:\Project\TYC\S32DS35\fmstr_rtd_fcan_s32k144\Debug_FLASH/../SDK/S32K144_SDK_4.0.1/platform/devices/S32K144/startup/system_S32K144.c:179: first defined here

...... 

Build Failed. 57 errors, 5 warnings. (took 6s.272ms)

Have you any suggestion, thanks .

 

0 Kudos
Reply
2,059 Views
iulian_stan
NXP Employee
NXP Employee

Hi @CY9,

1. That one is a bug that was fixed in a later version of FreeMASTER Driver. That assignment should be inside the previous {} block:

if (discard > 0U)
{
...
  /* buffer is for sure not full */
  pbuff->flags.flg.bIsFull = 0;
  pbuff->nRP               = rp;
}

We do plan to update the library for S32K1 family, but have no ETA at the moment.

2. First I would clean the project (to be safe I would manually delete the Debug_FLASH folder) and rebuild it. If the issue persists, it means that during the migration to the new DS, you got duplicates for some files. Search for problematic functions (ex: SystemInit) duplicates definitions in the project files and remove the redundant source path.

0 Kudos
Reply