FlexCAN with DMA feature

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

FlexCAN with DMA feature

846 Views
engineer_attila
Contributor III

Hi folks,

I have MPC5775B based board.

I want to use Rx FIFO Transfer type to DMA mode instead of interrupt mode for FlexCAN module(or also if possible for MCAN).

I'm working over Matlab generated code.

Screenshot_1.png

I setuped simple MPC5775B project and try to use CAN Bus with EDMA feature(I set the FEATURE_CAN_HAS_DMA_ENABLE (1) on MPC5775B_features.h, and compile project without code regeneration)

ı got the compilation error.

>> !CAN_DMA.bat
 
C:\Users\xxxxxx\Desktop\NXP\CAN_DMA\CAN_DMA_mbd_rtw>set MATLAB=C:\Program Files\MATLAB\R2018b  
 
C:\Users\xxxxxx\Desktop\NXP\CAN_DMA\CAN_DMA_mbd_rtw>"C:\Program Files\MATLAB\R2018b\bin\win64\gmake" -f CAN_DMA.mk  GENERATE_ERT_S_FUNCTION=0 INCLUDE_MDL_TERMINATE_FCN=1 COMBINE_OUTPUT_UPDATE_FCNS=1 MULTI_INSTANCE_CODE=0 INTEGER_CODE=0 ISPROTECTINGMODEL=NOTPROTECTING  
Cleaning... 
RELATIVE_PATH_TO_ANCHOR is .. 
==== Removing object files from build directory ==== 
Copying necessary files to build directory... 
Compiler details : "C:\Users\xxxxxx\AppData\Roaming\MathWorks\Add_ons\Toolboxes\NXP_MBDToolbox_MPC57xx\tools/S32DS/build_tools/powerpc-eabivle-4_9/bin/powerpc-eabivle-gcc"  -DCPU_MPC5775B -mcpu=e200z7 -DSTART_FROM_FLASH --sysroot="C:\Users\xxxxxx\AppData\Roaming\MathWorks\Add_ons\Toolboxes\NXP_MBDToolbox_MPC57xx\tools/S32DS/build_tools/e200_ewl2" -g3 -mbig -mvle -O1 -mregnames -mlsp -specs=ewl_c9x.specs -mhard-float -Wall -c -std=c99 -fdata-sections -ffunction-sections -funsigned-char -fmessage-length=0 -nostdinc -fno-jump-tables  -DTURN_ON_CPU0 -I. -I.. -I../instrumented -I.. -I"C:\Program Files\MATLAB\R2018b\simulink\include" -I"C:\Program Files\MATLAB\R2018b\extern\include" -I"C:\Program Files\MATLAB\R2018b\rtw\c\src" -I"C:\Program Files\MATLAB\R2018b\rtw\c\libsrc" -I"C:\Program Files\MATLAB\R2018b\rtw\c\src\ext_mode\common" -I"C:\Program Files\MATLAB\R2018b\rtw\c\src\ext_mode\tcpip" -I"C:\Program Files\MATLAB\R2018b\rtw\c\src\ext_mode\serial" -I"C:\Program Files\MATLAB\R2018b\rtw\c\src\ext_mode\custom" -IC:\Users\xxxxxx\Desktop\NXP\CAN_DMA -IC:\Users\xxxxxx\Desktop\NXP\CAN_DMA\CAN_DMA_mbd_rtw -IC:\PROGRA~1\MATLAB\R2018b\extern\include -IC:\PROGRA~1\MATLAB\R2018b\simulink\include -IC:\PROGRA~1\MATLAB\R2018b\rtw\c\src -IC:\PROGRA~1\MATLAB\R2018b\rtw\c\src\ext_mode\common -IC:\PROGRA~1\MATLAB\R2018b\rtw\c\ert  -I"C:\Users\xxxxxx\AppData\Roaming\MathWorks\Add_ons\Toolboxes\NXP_MBDToolbox_MPC57xx\tools/S32DS/build_tools/e200_ewl2/EWL_C/include" -I"C:\Users\xxxxxx\AppData\Roaming\MathWorks\Add_ons\Toolboxes\NXP_MBDToolbox_MPC57xx\tools/S32DS/build_tools/e200_ewl2/EWL_C/include/pa"    -I"./common" -I"./inc" -I"./src/clock/MPC57xx" -I"./src/clock/MPC5777C" -I"./src/sim/MPC5775B" -I"./src/power/MPC57xx" -I"./src/pins/siul2" -I"./src/pins/siu" -I"./MPC5775B/include" -I"../common" -I"../inc" -I"../src/clock/MPC57xx" -I"../src/clock/MPC5777C" -I"../src/sim/MPC5775B" -I"../src/power/MPC57xx" -I"../src/pins/siul2" -I"../src/pins/siu" -I"../MPC5775B/include" -I"../instrumented/common" -I"../instrumented/inc" -I"../instrumented/src/clock/MPC57xx" -I"../instrumented/src/sim/MPC5775B" -I"../instrumented/src/power/MPC57xx" -I"../instrumented/src/pins/siul2" -I"../instrumented/MPC5775B/include"     
Assembler details : "C:\Users\xxxxxx\AppData\Roaming\MathWorks\Add_ons\Toolboxes\NXP_MBDToolbox_MPC57xx\tools/S32DS/build_tools/powerpc-eabivle-4_9/bin/powerpc-eabivle-gcc" -c  -g3 -mbig -mvle -mregnames  -DTURN_ON_CPU0  
Product: CAN_DMA.mot 
Build product type: executable 
Building file core0_intc_sw_handlers.o... 
"C:\Users\xxxxxx\AppData\Roaming\MathWorks\Add_ons\Toolboxes\NXP_MBDToolbox_MPC57xx\tools/S32DS/build_tools/powerpc-eabivle-4_9/bin/powerpc-eabivle-gcc" -c  -g3 -mbig -mvle -mregnames  -DTURN_ON_CPU0 -I..  -o core0_intc_sw_handlers.o core0_intc_sw_handlers.S 
Building file interrupt_vectors.o... 
"C:\Users\xxxxxx\AppData\Roaming\MathWorks\Add_ons\Toolboxes\NXP_MBDToolbox_MPC57xx\tools/S32DS/build_tools/powerpc-eabivle-4_9/bin/powerpc-eabivle-gcc" -c  -g3 -mbig -mvle -mregnames  -DTURN_ON_CPU0 -I..  -o interrupt_vectors.o interrupt_vectors.S 
Building file startup_MPC5775B.o... 
"C:\Users\xxxxxx\AppData\Roaming\MathWorks\Add_ons\Toolboxes\NXP_MBDToolbox_MPC57xx\tools/S32DS/build_tools/powerpc-eabivle-4_9/bin/powerpc-eabivle-gcc" -c  -g3 -mbig -mvle -mregnames  -DTURN_ON_CPU0 -I..  -o startup_MPC5775B.o startup_MPC5775B.S 
Building file CAN_DMA.o... 
"C:\Users\xxxxxx\AppData\Roaming\MathWorks\Add_ons\Toolboxes\NXP_MBDToolbox_MPC57xx\tools/S32DS/build_tools/powerpc-eabivle-4_9/bin/powerpc-eabivle-gcc"  -DCPU_MPC5775B -mcpu=e200z7 -DSTART_FROM_FLASH --sysroot="C:\Users\xxxxxx\AppData\Roaming\MathWorks\Add_ons\Toolboxes\NXP_MBDToolbox_MPC57xx\tools/S32DS/build_tools/e200_ewl2" -g3 -mbig -mvle -O1 -mregnames -mlsp -specs=ewl_c9x.specs -mhard-float -Wall -c -std=c99 -fdata-sections -ffunction-sections -funsigned-char -fmessage-length=0 -nostdinc -fno-jump-tables  -DTURN_ON_CPU0 -I. -I.. -I../instrumented -I.. -I"C:\Program Files\MATLAB\R2018b\simulink\include" -I"C:\Program Files\MATLAB\R2018b\extern\include" -I"C:\Program Files\MATLAB\R2018b\rtw\c\src" -I"C:\Program Files\MATLAB\R2018b\rtw\c\libsrc" -I"C:\Program Files\MATLAB\R2018b\rtw\c\src\ext_mode\common" -I"C:\Program Files\MATLAB\R2018b\rtw\c\src\ext_mode\tcpip" -I"C:\Program Files\MATLAB\R2018b\rtw\c\src\ext_mode\serial" -I"C:\Program Files\MATLAB\R2018b\rtw\c\src\ext_mode\custom" -IC:\Users\xxxxxx\Desktop\NXP\CAN_DMA -IC:\Users\xxxxxx\Desktop\NXP\CAN_DMA\CAN_DMA_mbd_rtw -IC:\PROGRA~1\MATLAB\R2018b\extern\include -IC:\PROGRA~1\MATLAB\R2018b\simulink\include -IC:\PROGRA~1\MATLAB\R2018b\rtw\c\src -IC:\PROGRA~1\MATLAB\R2018b\rtw\c\src\ext_mode\common -IC:\PROGRA~1\MATLAB\R2018b\rtw\c\ert  -I"C:\Users\xxxxxx\AppData\Roaming\MathWorks\Add_ons\Toolboxes\NXP_MBDToolbox_MPC57xx\tools/S32DS/build_tools/e200_ewl2/EWL_C/include" -I"C:\Users\xxxxxx\AppData\Roaming\MathWorks\Add_ons\Toolboxes\NXP_MBDToolbox_MPC57xx\tools/S32DS/build_tools/e200_ewl2/EWL_C/include/pa"    -I"./common" -I"./inc" -I"./src/clock/MPC57xx" -I"./src/clock/MPC5777C" -I"./src/sim/MPC5775B" -I"./src/power/MPC57xx" -I"./src/pins/siul2" -I"./src/pins/siu" -I"./MPC5775B/include" -I"../common" -I"../inc" -I"../src/clock/MPC57xx" -I"../src/clock/MPC5777C" -I"../src/sim/MPC5775B" -I"../src/power/MPC57xx" -I"../src/pins/siul2" -I"../src/pins/siu" -I"../MPC5775B/include" -I"../instrumented/common" -I"../instrumented/inc" -I"../instrumented/src/clock/MPC57xx" -I"../instrumented/src/sim/MPC5775B" -I"../instrumented/src/power/MPC57xx" -I"../instrumented/src/pins/siul2" -I"../instrumented/MPC5775B/include"     -o CAN_DMA.o CAN_DMA.c 
In file included from devassert.h:22:0, 
                 from device_registers.h:411, 
                 from CAN_DMA.h:24, 
                 from CAN_DMA.c:17: 
C:\Users\xxxxxx\AppData\Roaming\MathWorks\Add_ons\Toolboxes\NXP_MBDToolbox_MPC57xx\tools/S32DS/build_tools/e200_ewl2/EWL_C/include/stdbool.h:45:0: warning: "true" redefined 
  #define true       1 
 ^ 
In file included from CAN_DMA.h:23:0, 
                 from CAN_DMA.c:17: 
rtwtypes.h:27:0: note: this is the location of the previous definition 
 #   define true                        (1U) 
 ^ 
In file included from devassert.h:22:0, 
                 from device_registers.h:411, 
                 from CAN_DMA.h:24, 
                 from CAN_DMA.c:17: 
C:\Users\xxxxxx\AppData\Roaming\MathWorks\Add_ons\Toolboxes\NXP_MBDToolbox_MPC57xx\tools/S32DS/build_tools/e200_ewl2/EWL_C/include/stdbool.h:46:0: warning: "false" redefined 
  #define false       0 
 ^ 
In file included from CAN_DMA.h:23:0, 
                 from CAN_DMA.c:17: 
rtwtypes.h:23:0: note: this is the location of the previous definition 
 #   define false                       (0U) 
 ^ 
In file included from CAN_DMA.h:27:0, 
                 from CAN_DMA.c:17: 
flexcan_hw_access.h: In function 'FLEXCAN_SetRxFifoDMA': 
flexcan_hw_access.h:1208:31: error: 'CAN_MCR_DMA_MASK' undeclared (first use in this function) 
     base->MCR = (base->MCR & ~CAN_MCR_DMA_MASK) | CAN_MCR_DMA(enable? 1UL : 0UL); 
                               ^ 
flexcan_hw_access.h:1208:31: note: each undeclared identifier is reported only once for each function it appears in 
flexcan_hw_access.h:1208:5: warning: implicit declaration of function 'CAN_MCR_DMA' [-Wimplicit-function-declaration] 
     base->MCR = (base->MCR & ~CAN_MCR_DMA_MASK) | CAN_MCR_DMA(enable? 1UL : 0UL); 
     ^ 
CAN_DMA.c: In function 'CAN_DMA_initialize': 
CAN_DMA.c:126:62: warning: passing argument 3 of 'FLEXCAN_DRV_ConfigRxFifo' from incompatible pointer type 
     FLEXCAN_DRV_ConfigRxFifo(0, FLEXCAN_RX_FIFO_ID_FORMAT_A, &id_filter_table); 
                                                              ^ 
In file included from CAN_DMA.h:26:0, 
                 from CAN_DMA.c:17: 
flexcan_driver.h:716:6: note: expected 'const struct flexcan_id_table_t *' but argument is of type 'struct flexcan_id_table_t (*)[8]' 
 void FLEXCAN_DRV_ConfigRxFifo( 
      ^ 
gmake: *** [CAN_DMA.o] Error 1 
>> 

I also try same configuration on s32 Power Studio i couldn't change the Configuration List "RX FIFO Transfer type" Using Interrupts to Using DMA.

when i insert the below code on the MPC5775B.h within CAN MCR macros 

#define CAN_MCR_DMA_MASK                         0x8000u
#define CAN_MCR_DMA_SHIFT                        15u
#define CAN_MCR_DMA_WIDTH                        1u
#define CAN_MCR_DMA(x)                           (((uint32_t)(((uint32_t)(x))<<CAN_MCR_DMA_SHIFT))&CAN_MCR_DMA_MASK)

The error is disappear, but i'm not sure this is proper way to use DMA with FlexCAN

How can i use DMA mode instead of interrupts mode for MBDT based MPC5775B projects?

Regards,
Attila.

0 Kudos
Reply
0 Replies