Multiple CAN channel usage issue in MPC5748G GW board using Free RTOS FlexCAN

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Multiple CAN channel usage issue in MPC5748G GW board using Free RTOS FlexCAN

ソリューションへジャンプ
2,042件の閲覧回数
hims8111
Contributor II

Hi,

I am facing issue regarding memory allocation during task creation while using multiple FlexCAN channels in MPC5748G-GW board. I have used example shared on below Knowledge base link  https://community.nxp.com/t5/MPC5xxx-Knowledge-Base/Example-MPC5748G-FlexCAN-TX-RX-FreeRTOS-S32DS2-1...

CAN Tx and Rx task works fine with canCom1:FlexCAN (CAN1) as given in example. However, as per my application requirement, I have added one more CAN channel component with same settings is  canCom2:FlexCAN. (Please find attached image). After adding same initialization for CAN2 in hardware setup function, errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY error encountered during scheduler call.

At First, I was skeptical about freeRtos heap memory allocation (by default it was 16384). I checked by doubling it (32768). After that it has created tasks successfully but during execution it got in to DevAssert block in devassert.h. (So probably, my hardware doesn't have enough RAM to allocate dynamically during SendCANdata function call. please correct me if my understanding is wrong)

Could you please help me to understand is it possible to use multiple CAN channel for Transmission and Reception using Free RTOS? If yes, then what should I do to resolve this issue? Any help will be appreciated.

Thanks in advance.FreeRTOSexample-memoryAllocation-issue.PNG

 

 

 

 

 

0 件の賞賛
返信
1 解決策
1,912件の閲覧回数
PetrS
NXP TechSupport
NXP TechSupport

Hi,

as far as I know this is due to driver over freertos "eats" a lot of Heap Memory for the semaphores for each MBs.

BR, Petr

元の投稿で解決策を見る

0 件の賞賛
返信
6 返答(返信)
1,966件の閲覧回数
hims8111
Contributor II

Hi, 

Thanks for trying, I have modified your original example for target board MPC5748G-GW-RDB (Gateway board). So after initializing canCOM2 I was facing memory issue during scheduler call. However, I could figure out temporary workaround by increasing the FreeRTOS heap size more than 65000. But I still don't understand the significant memory requirement change after including 2 CAN channels. If you find the reason, please let me know.

Thanks.

0 件の賞賛
返信
2,013件の閲覧回数
PetrS
NXP TechSupport
NXP TechSupport

Hi,

from which function you got devassert, can you identify the line?
What if beside increasing heap you also increase stack size, when creating task.

BR, Petr

0 件の賞賛
返信
2,004件の閲覧回数
hims8111
Contributor II

Hi, 

Thanks. I just checked by increasing stack depth to 1000 and checked but still the same. It goes to DevAssert section from xPortStartScheduler(). Please find attached image. I want to understand, how adding one more CAN channel impact the memory significantly?

hims8111_0-1630324543582.png

hims8111_1-1630324718016.png

 

 

My Current Configuration:

FreeRTOS Total heap size : Changed from 16384 to 32768

Tx and Rx task stack depth : 1000 (I guess its more than enough for two CAN channels, as one channel communication works with 200<Minimal_stack_size>)

I have also attached modified example with #define ENABLE_FLEXCAN2 in rtos.c file to check the difference in behavior by commenting/uncommenting it. 

Please let me know incase more details required form my side.

Thanks.

 

 

0 件の賞賛
返信
1,973件の閲覧回数
PetrS
NXP TechSupport
NXP TechSupport

Hi,

I tried the example on DEVKIT, but without connecting to bus, and it does not stop on any devassert.
What is your board and connection, in fact?

BR, Petr

0 件の賞賛
返信
1,946件の閲覧回数
hims8111
Contributor II

Hi, Thanks for trying, I have modified your original example for target board MPC5748G-GW-RDB (Gateway board). So after initializing canCOM2 I was facing memory issue during scheduler call. However, I could figure out temporary workaround by increasing the FreeRTOS heap size more than 65000. But I still don't understand the significant memory requirement change after including 2 CAN channels. If you find the reason, please let me know. Thanks.

0 件の賞賛
返信
1,913件の閲覧回数
PetrS
NXP TechSupport
NXP TechSupport

Hi,

as far as I know this is due to driver over freertos "eats" a lot of Heap Memory for the semaphores for each MBs.

BR, Petr

0 件の賞賛
返信