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.

Compiler/TDA4VMXEVM: why AD Initialization fail when startup with linux?

Part Number: TDA4VMXEVM

Tool/software: TI C/C++ Compiler

Hello:

        Now I'm trying to run mcu r5f core and main r5f core. I use vision_apps demo and boot from SD card. I put mcu r5f binary at path "/rootfs/lib/firware" and rename as "j7-mcu-r5f0_0-fw".When I startup the system,I find that AD initialization fail and the mcu stops run when my code wants to read register ADC_CONTROL(0x40200040).

        But why when I boot from CCS, it doesn't have this problem and the mcu can work normal?

The code below is from "mcusw/mcal_drv/mcal/Adc/src/Adc_Pirv.c", SDK version : 6.2

    Adc_utilsInitLinkList(&hwUintObj->groupList);
    /*
     * Init the HW instance
     */
    baseAddr = hwUintObj->baseAddr;
    Adc_hwSetDefReg(baseAddr);

    /*
     * Power up Analog Front End
     */
    HW_WR_FIELD32(
        baseAddr + ADC_CTRL, ADC_CTRL_POWER_DOWN,
        ADC_CTRL_POWER_DOWN_AFEPOWERUP);             // The mcu will stop run when the code want to read the register!!!

    /* Wait 4us at-least */
    Adc_delayExecution(delayCount);

  • Hi,

    So you are using the MCUSW adc_app and then copying the *.xer5f to rootfs/lib/firmware and it is not working? (please confirm)

    Can you also please look at https://e2e.ti.com/support/processors/f/791/t/931992 to get more information on why this could have gone wrong alongside linux.

    Regards,

    Karan

  • Hi Karan:

        Yes, I'm copying *.xer5f to rootfs/lib/firmware. I will use AppUtils_Printf() to see log, At start it can printf log normal, But when the code runs to Adc_Init(), the log will not show any more. So I jump into the code, I find that if you want to read the ADC's register(such as ADC_CONTROL, address 0x40200040), mcu will stop run!!! But write to ADC's register has no problem.

    Thanks!

  • Hi,

    We can do one quick experiment

    Can you halt at u-boot and try to access the memory there.

    run the following:

    md 0x40200040  --> most likely this will crash the as I'm thinking that at this u-boot and SPL would not enable clocks for ADC

    Regards,

    Karan

  • Hi,

    So that is an abort as you can see. That means that ADC clocks and power is not set by u-boot or SPL and is neither done by the adc_app.

    The reason why it works with SBL and CCS (from where it is validated) is because CCS (via GELs) and SBL will enable power by default for ADC.

    Is there any specific reason for running this alongside Linux? Can you use SBL to run from SD card?

    Regards,

    Karan

  • Hi Karan:

          In our project, we need mcu ADC to sample the battery's voltage and transfer the data to vision_apps, so we need mcu runing alongside Linux.

    Thanks.

  • Hi,

    Can you try to enable module clocks in the application itself using the following:

    +/* Local API for enabling clocks.
    +   Copied from board library.
    + */
    +int32_t local_moduleClockEnable(uint32_t moduleId)
    +{
    +    int32_t retVal = 0;
    +    int32_t status = -1;
    +    uint32_t moduleState = 0U;
    +    uint32_t resetState = 0U;
    +    uint32_t contextLossState = 0U;
    +
    +    /* Get the module state.
    +       No need to change the module state if it
    +       is already ON
    +     */
    +    status = Sciclient_pmGetModuleState(moduleId,
    +                                        &moduleState,
    +                                        &resetState,
    +                                        &contextLossState,
    +                                        SCICLIENT_SERVICE_WAIT_FOREVER);
    +    if(moduleState == TISCI_MSG_VALUE_DEVICE_HW_STATE_OFF)
    +    {
    +        status = Sciclient_pmSetModuleState(moduleId,
    +                                            TISCI_MSG_VALUE_DEVICE_SW_STATE_ON,
    +                                            (TISCI_MSG_FLAG_AOP |
    +                                             TISCI_MSG_FLAG_DEVICE_RESET_ISO),
    +                                             SCICLIENT_SERVICE_WAIT_FOREVER);
    +        if (status == 0)
    +        {
    +            status = Sciclient_pmSetModuleRst (moduleId,
    +                                               0x0U,
    +                                               SCICLIENT_SERVICE_WAIT_FOREVER);
    +            if (status != 0)
    +            {
    +                retVal = -1;
    +            }
    +        }
    +        else
    +        {
    +            retVal = -1;
    +        }
    +    }
    +
    +    return retVal;
    +}

    You will need the header file for this:

    +#include <ti/drv/sciclient/sciclient.h>

    In the main() add the following:

    +    local_moduleClockEnable(TISCI_DEV_MCU_ADC0);
    +    local_moduleClockEnable(TISCI_DEV_MCU_ADC1);

    This will enable ADC module and won't depend on bootloader for that.

    After this build the same adc_app again and try to load using u-boot. After loading try to access the same address space using the md command, that should be accessible now.

    Regards,

    Karan

  • Hi Karan:

        Ok, resolved! Thanks!

  • I've updated the FAQ - https://e2e.ti.com/support/processors/f/791/t/931992 with this information.

    Regards,

    Karan