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.

TDA4VM-Q1: SDL VTM API Usage Problem

Part Number: TDA4VM-Q1

Hi Dear TI Experts,

I am trying to re-configure the VTM GT1/GT2/LT0 thresholds for our new requirements with SDK8.05. However, following the SDL VTM example, when I use the API SDL_VTM_tsConvTempToAdc(),

it returns failed status.

Here is my code:

    SDL_VTM_configTs cfgTs;
    SDL_VTM_intrCtrl ctrl;
    SDL_VTM_configVd cfgVd;
    SDL_VTM_InstTs insTs = SDL_VTM_INSTANCE_TS_0;
    int32_t retVal;
    int32_t lt_thr0_temp_value = LT_THR0_RECOVER_TEMP;
    int32_t gt_thr1_temp_value = GT_THR1_HIGH_TEMP;
    int32_t gt_thr2_temp_value = GT_THR2_OVER_TEMP;
    SDL_VTM_adc_code adc_code_lt_thr0 = 0x0;
    SDL_VTM_adc_code adc_code_gt_thr1 = 0x0;
    SDL_VTM_adc_code adc_code_gt_thr2 = 0x0; 
    
    /* Convert the LT0, GT1, GT2, max alert THRO/THR temperature values to be adc values*/

    retVal = SDL_VTM_tsConvTempToAdc(lt_thr0_temp_value, insTs, &adc_code_lt_thr0);
    if(retVal != SDL_PASS)
    {
        while(1)
        {

        }
    }

    retVal = SDL_VTM_tsConvTempToAdc(gt_thr1_temp_value, insTs, &adc_code_gt_thr1);
        if(retVal != SDL_PASS)
    {
        while(1)
        {
            
        }
    }    
    retVal = SDL_VTM_tsConvTempToAdc(gt_thr2_temp_value, insTs, &adc_code_gt_thr2);
        if(retVal != SDL_PASS)
    {
        while(1)
        {
            
        }
    }

#define LT_THR0_RECOVER_TEMP                              (105000)
#define GT_THR1_HIGH_TEMP                                 (115000)
#define GT_THR2_OVER_TEMP                                 (123000)
Then sure I cannnot get the correct ADC values for the new thresholds.
I cannot debug any further inside SDL_VTM_tsConvTempToAdc. As you can see, I tried to set the new thresholds as 105, 115, 123 degrees.
Is there anything wrong?Any idea why SDL_VTM_tsConvTempToAdc() failed?
Thanks for your time.
  • Hi,

    Do the examples included in the SDL delivery work on the setup under test?

    Which core is the test being run on?

    Thanks,

    kb

  • Hi KB,

    I thought I found the reason.

    SDL_VTM_tsConvTempToAdc() returns SDL_EBADARGS, mostly in 

        /* Check the temperature sensor ID out of range values */
        if ((int32_t)instance > gNumTempSensors)
        {
            retVal = SDL_EBADARGS;
        }
    while gNumTempSensor is uninitialized(-1), which is causing the API failed.
    It means I will have to invoke SDL_VTM_getSensorVDCount() to initialize gNumTempSensor before using SDL_VTM_tsConvTempToAdc() solely.
     SDL_VTM_tsConvADCToTemp contains SDL_VTM_getSensorVDCount(), while SDL_VTM_tsConvTempToAdc does not.
    In SDL example, SDL_VTM_tsConvADCToTemp is executed first, so that gNumTempSensor is initialized. Then SDL_VTM_tsConvTempToAdc is working perfectly.
     
    In my test case, I use SDL_VTM_tsConvADCToTemp() only, hence it cannot work properly.
    Can you confirm the above conclusion? Thanks.
  • Hi,

    As you mentioned, TempToAdc doesn’t initialize the gNumTempSensors parameter. One of the following calls will do that:
    SDL_VTM_initTs()
    SDL_VTM_initVd()
    SDL_VTM_tsConvADCToTemp()
     
    You can first call one of the other APIs, or you can directly call SDL_VTM_getSensorVDCount first to ensure it is initialized. Something like:
     {
        const SDL_VTM_cfg1Regs *p_cfg1 = (SDL_VTM_cfg1Regs *) SDL_VTM_CFG1_BASE;
        SDL_VTM_getSensorVDCount(p_cfg1);
    }
     
    We are also looking into this internally, so that SDL_VTM_tsConvTempToAdc can also be modified to initialize this. 

    Thanks,

    Josiitaa

  • Yes, I think this SDL_VTM_tsConvTempToAdc() may also be used solely in development, which is more reasonable.

    Thanks, then my problem solved.