This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM2432: MCAN with DMA

Part Number: AM2432

Tool/software:

Hi,

When the customer tried the example project of “mcan_loopback_dma_am243x-evm_r5fss0-0_freertos_ti-arm-clang” without any change on the EVM, the following errors occurred.

MAIN_Cortex_R5_0_0: [MCAN] Loopback DMA mode, application started ...

MAIN_Cortex_R5_0_0: ERROR: App_mcanCompareMsg:663: Data mismatch !!!

MAIN_Cortex_R5_0_0: ASSERT: 0.11967s: ../mcan_loopback_dma.c:App_mcanCompareMsg:664: FALSE failed !!!

 

Are there any problem in their try ?

Has this example been tested ?

Or DMA cannot be used with CAN ?

 

Thanks and regards,

Hideaki

  • Hi Hideaki-San,

    Let me test this on my EVM and let you know if I can reproduce the issue, please expect a response in 1-2 days. Can you let me know which MCU+SDK version you are using, so that I can test on the same version.

    Best regards,

    Meet.

  • Hi Hideaki-San,

    I tested this same example at my end and it is working for me, I have tried the example from the SDK version 11.0 and tested it on am243-lp, please find the logs below:

    [MAIN_Cortex_R5_0_0] [MCAN] Loopback DMA mode, application started ...
    All tests have passed!!

    Let me know the version customer is using as well as on which EVM they are using.

    Best Regards,

    Meet.

  • Hi Meet,

    Thank you for testing the example on your end as well.

    They are using SDK 9.2.0.11 on AM243x EVM, not LaunchPad.

    Could you check this example with the above combination of 9.2.0.11 and EVM ?

    Thanks and regards,

    Hideaki 

  • Hi Hideaki-San.

    This is a known issue in the older SDK versions, this was fixed in SDK version 10.01: https://sir.ext.ti.com/jira/browse/EXT_SITMPUSW-11

    Best regards,

    Meet.

  • Hi Meet,

    I cannot see the jira fix contents because I do not have access to jira unfortunately.

    Could you tell me what the issue and fix was? Is this an application side change they can apply quickly or a source/driver change? Can we give them a patch to apply to SDK9.2.11?

    Best regards,

    Mari Tsunoda

  • Hi Meet,

    Do you have any update on this?

    If they cannot port the SDK10.1 contents to SDK9.2.0.11, then can they not use MCAN loopback DMA?

    Best regards,

    Mari Tsunoda

  • Hi Mari,

    They would need to backport the changes from 10.1 to 9.2 if they want to continue using 9.2. I am trying to find the commit where this was changed so they can refer to the same and backport the required changes.

    Best Regards,

    Meet.

  • Hi Meet,

    Thank you for your response.

     

    They tried to backport “mcan_loopback_dma” from SDK11.00 to 9.2.

    They renamed “mcan_loopback_v1.c” of 11.00 to “mcan_loopback_dma.c” and copied it to the same folder in 9.2.

    But the following error occurred when they tried to build it.

    fatal error: 'drivers/mcan/v0/dma/edma/canfd_dma_edma.c' file not found

     

    They found that the folder of “drivers/mcan/v0/dma/edma/ didn’t exist in SDK 9.2.

    How can they backport “mcan_loopback_dma” project ?

     

    Here are errors when they built.

    [0]**** Build of configuration Debug for project mcan_loopback_dma_am243x-evm_r5fss0-0_freertos_ti-arm-clang ****

    [1]"C:\\ti\\ccstheia150\\ccs\\utils\\bin\\gmake" -k -j 16 all -O

    [2]Building file: "../mcan_loopback_dma.c"

    [3]Invoking: Arm Compiler

    [4]"C:/ti/ti_cgt_tiarmclang_3.2.2.LTS/bin/tiarmclang.exe" -c -mcpu=cortex-r5 -mfloat-abi=hard -mfpu=vfpv3-d16 -mlittle-endian -mthumb -I"C:/ti/ti_cgt_tiarmclang_3.2.2.LTS/include/c" -I"C:/ti/motor_control_sdk_am243x_09_02_00_11/mcu_plus_sdk/source" -I"C:/ti/motor_control_sdk_am243x_09_02_00_11/mcu_plus_sdk/source/kernel/freertos/FreeRTOS-Kernel/include" -I"C:/ti/motor_control_sdk_am243x_09_02_00_11/mcu_plus_sdk/source/kernel/freertos/portable/TI_ARM_CLANG/ARM_CR5F" -I"C:/ti/motor_control_sdk_am243x_09_02_00_11/mcu_plus_sdk/source/kernel/freertos/config/am243x/r5f" -DSOC_AM243X -D_DEBUG_=1 -g -Wall -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-function -MMD -MP -MF"mcan_loopback_dma.d_raw" -MT"mcan_loopback_dma.o" -I"C:/sample/mcan_loopback_dma_am243x-evm_r5fss0-0_freertos_ti-arm-clang/Debug/syscfg"   -o"mcan_loopback_dma.o" "../mcan_loopback_dma.c"

    [5]subdir_rules.mk:47: recipe for target 'mcan_loopback_dma.o' failed

    [6]../mcan_loopback_dma.c:56:10: fatal error: 'drivers/mcan/v0/dma/edma/canfd_dma_edma.c' file not found

    [7]#include <drivers/mcan/v0/dma/edma/canfd_dma_edma.c>

    [8]         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    [9]1 error generated.

    [10]gmake: *** [mcan_loopback_dma.o] Error 1

    [11]gmake: Target 'all' not remade because of errors.

    [12]**** Build Finished ****

     

    Thanks and regards,

    Hideaki

  • Hi Hideaki,

    Could you ask customer to apply the following patch and check if this resolves the issue:

    diff --git a/source/drivers/mcan/v0/mcan.c b/source/drivers/mcan/v0/mcan.c
    index 05b3006..570e9dc 100644
    --- a/source/drivers/mcan/v0/mcan.c
    +++ b/source/drivers/mcan/v0/mcan.c
    @@ -2489,7 +2489,7 @@ int32_t MCAN_writeDmaHeader( const void* data, const MCAN_TxBufElement *elem)
                     ((uint32_t) ((elem->xtd << MCANSS_TX_BUFFER_ELEM_XTD_SHIFT) & MCANSS_TX_BUFFER_ELEM_XTD_MASK)) |
                     ((uint32_t) ((elem->esi << MCANSS_TX_BUFFER_ELEM_ESI_SHIFT) & MCANSS_TX_BUFFER_ELEM_ESI_MASK)));
     
    -        *((uint32_t*)(((uint32_t*)data)+4))= (((uint32_t)((elem->dlc << MCANSS_TX_BUFFER_ELEM_DLC_SHIFT) & MCANSS_TX_BUFFER_ELEM_DLC_MASK)) |
    +        *((uint32_t*)(((uint32_t*)data)+1))= (((uint32_t)((elem->dlc << MCANSS_TX_BUFFER_ELEM_DLC_SHIFT) & MCANSS_TX_BUFFER_ELEM_DLC_MASK)) |^M
                     ((uint32_t) ((elem->brs << MCANSS_TX_BUFFER_ELEM_BRS_SHIFT) & MCANSS_TX_BUFFER_ELEM_BRS_MASK)) |
                     ((uint32_t) ((elem->fdf << MCANSS_TX_BUFFER_ELEM_FDF_SHIFT) & MCANSS_TX_BUFFER_ELEM_FDF_MASK)) |
                     ((uint32_t) ((elem->efc << MCANSS_TX_BUFFER_ELEM_EFC_SHIFT) & MCANSS_TX_BUFFER_ELEM_EFC_MASK)) |

    Best regards,
    Meet.

  • Hi Meet,

    So as I understand it, are they only supposed to change the source files and NOT the example files - is this correct?

    We have asked them to try porting the example-side files from SDK11.0 to SDK9.2 previously, so if they need to revert these changes we will need to let them know.

    Also - do you have details of the original Jira issue details? It seems to me that the only change here is to increase the buffer size allocated for data. Was the original issue due to lack of buffer size?

    Best regards,

    Mari Tsunoda

  • Hi Mari,

    So as I understand it, are they only supposed to change the source files and NOT the example files - is this correct?

    That is correct. But after they add this change, they need to rebuild the library as well as the example.

    We have asked them to try porting the example-side files from SDK11.0 to SDK9.2 previously, so if they need to revert these changes we will need to let them know.

    This patch needs to be applied on default 9.2 SDK, so they need to revert these changes.

    Also - do you have details of the original Jira issue details? It seems to me that the only change here is to increase the buffer size allocated for data. Was the original issue due to lack of buffer size?

    There was no issue with the buffer size, the DMA header data needed in DMA mode was being written to a wrong address in the buffer (because of *((uint32_t*)(((uint32_t*)data)+4))) this was fixed by adding +1 instead of +4.

    Best Regards,

    Meet.