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.
已解决! 转到解答。
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.
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?
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.
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.