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.

AM2634: adc soc software problem

Part Number: AM2634

Tool/software:

environment: CCS12.7 sdk9.0.02  demo: adc_soc_software_am263x-lp_r5fss0-0     hardware: 2634lp  red demo board

I modified the code in the example to facilitate observing the values of variables through debug mode at any time, thereby confirming whether my ADC configuration is correct.

-------------------------------------------------------------------------------------------------------------------------------------------------------------

int main(void)
{
     System_init();
     Board_init();

     adc_soc_software_main(NULL);
     while(1);

     // Board_deinit();
     // System_deinit();

     return 0;
}

----------------------------------------------------------------------------------------------------------------------------------------------------------------

my pwm configuration:

EPWM_setEmulationMode(CONFIG_EPWM4_BASE_ADDR, EPWM_EMULATION_FREE_RUN);
EPWM_setClockPrescaler(CONFIG_EPWM4_BASE_ADDR, EPWM_CLOCK_DIVIDER_8, EPWM_HSCLOCK_DIVIDER_1);
EPWM_setTimeBasePeriod(CONFIG_EPWM4_BASE_ADDR, 12500);
EPWM_setPeriodLoadMode(CONFIG_EPWM4_BASE_ADDR, EPWM_PERIOD_SHADOW_LOAD);
EPWM_setTimeBaseCounter(CONFIG_EPWM4_BASE_ADDR, 0);
EPWM_setTimeBaseCounterMode(CONFIG_EPWM4_BASE_ADDR, EPWM_COUNTER_MODE_UP);

EPWM_enableInterrupt(CONFIG_EPWM4_BASE_ADDR);
EPWM_setInterruptSource(CONFIG_EPWM4_BASE_ADDR, EPWM_INT_TBCTR_ZERO, 0);
EPWM_setInterruptEventCount(CONFIG_EPWM4_BASE_ADDR, 1);

EPWM_lockRegisters(CONFIG_EPWM4_BASE_ADDR, 0);

EPWM_disableInterrupt(CONFIG_EPWM4_BASE_ADDR);

SOC_xbarSelectInterruptXBarInputSource(CSL_CONTROLSS_INTXBAR_U_BASE, 0, ( INT_XBAR_EPWM4_INT ), 0, 0, 0, 0, 0, 0);

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

my adc configuration

ADC_setPrescaler(CONFIG_ADC0_BASE_ADDR, ADC_CLK_DIV_4_0);
ADC_setMode(CONFIG_ADC0_BASE_ADDR, ADC_RESOLUTION_12BIT, ADC_MODE_SINGLE_ENDED);
ADC_setSOCPriority(CONFIG_ADC0_BASE_ADDR, ADC_PRI_ALL_ROUND_ROBIN);

ADC_setupSOC(CONFIG_ADC0_BASE_ADDR, 0, ADC_TRIGGER_SW_ONLY, ADC_CH_ADCIN0, 16);

ADC_enableConverter(CONFIG_ADC0_BASE_ADDR);
ClockP_usleep(500);
ADC_setInterruptPulseMode(CONFIG_ADC0_BASE_ADDR, ADC_PULSE_END_OF_CONV);
ADC_disableBurstMode(CONFIG_ADC0_BASE_ADDR);

ADC_setPrescaler(CONFIG_ADC1_BASE_ADDR, ADC_CLK_DIV_4_0);
ADC_setMode(CONFIG_ADC1_BASE_ADDR, ADC_RESOLUTION_12BIT, ADC_MODE_SINGLE_ENDED);
ADC_setSOCPriority(CONFIG_ADC1_BASE_ADDR, ADC_PRI_ALL_ROUND_ROBIN);

ADC_setupSOC(CONFIG_ADC1_BASE_ADDR, 0, ADC_TRIGGER_SW_ONLY, ADC_CH_ADCIN0, 16);
ADC_setupSOC(CONFIG_ADC1_BASE_ADDR, 1, ADC_TRIGGER_SW_ONLY, ADC_CH_ADCIN2, 16);


ADC_enableConverter(CONFIG_ADC1_BASE_ADDR);
ClockP_usleep(500);
ADC_setInterruptPulseMode(CONFIG_ADC1_BASE_ADDR, ADC_PULSE_END_OF_CONV);

ADC_disableBurstMode(CONFIG_ADC1_BASE_ADDR);

----------------------------------------------------------------------------------------------------------------------------------------------------------------

void adc_soc_software_main(void *args)
{
HwiP_Params hwiPrms;
interruptFlg = 1;
interruptTrigTimes = 0;

adc_open();
pwm_open();


HwiP_Params_init(&hwiPrms);
/* Integrate with Syscfg */
hwiPrms.intNum = CSLR_R5FSS0_CORE0_CONTROLSS_INTRXBAR0_OUT_0;
hwiPrms.isPulse = TRUE;
hwiPrms.callback = &App_epwmIntrISR;
HwiP_construct(&gEpwmHwiObject, &hwiPrms);

EPWM_clearEventTriggerInterruptFlag(CONFIG_EPWM4_BASE_ADDR);
EPWM_enableInterrupt(CONFIG_EPWM4_BASE_ADDR);
}

----------------------------------------------------------------------------------------------------------------------------------------------------------------

my interrupt ISR:

static void App_epwmIntrISR(void *handle)
{
EPWM_clearEventTriggerInterruptFlag(CONFIG_EPWM4_BASE_ADDR);
interruptTrigTimes = interruptTrigTimes + 1;
if (interruptFlg == 1)
{
interruptFlg = 2;
ADC_forceSOC(CONFIG_ADC0_BASE_ADDR, ADC_SOC_NUMBER0);
ADC_forceSOC(CONFIG_ADC1_BASE_ADDR, ADC_SOC_NUMBER0);
ADC_forceSOC(CONFIG_ADC1_BASE_ADDR, ADC_SOC_NUMBER2);
}
else if (interruptFlg == 2)
{
interruptFlg = 1;
adcval1 = ADC_readResult(CONFIG_ADC0_RESULT_BASE_ADDR, ADC_SOC_NUMBER0);
adcval2 = ADC_readResult(CONFIG_ADC1_RESULT_BASE_ADDR, ADC_SOC_NUMBER0);
adcval3 = ADC_readResult(CONFIG_ADC1_RESULT_BASE_ADDR, ADC_SOC_NUMBER2);
}
}

------------------------------------------------------------------------------------------------------------------------

I use EPWM4 interrupt to software force trig ADC0IN0 & ADC1IN0 & ADC1IN2

Then I use an external power supply to supply 2.27V power to J3->23 & J3->24 &  J7->67

then I get adcval1 = adcval2 = adcval3 ≈2907, which is correct.

------------------------------------------------------------------------------------------------------------------------

I change ADC0IN0 to ADC0IN2, Only three code modifications were made below

ADC_setupSOC(CONFIG_ADC0_BASE_ADDR, 0, ADC_TRIGGER_SW_ONLY, ADC_CH_ADCIN2, 16);

ADC_forceSOC(CONFIG_ADC0_BASE_ADDR, ADC_SOC_NUMBER2);

adcval1 = ADC_readResult(CONFIG_ADC0_RESULT_BASE_ADDR, ADC_SOC_NUMBER2);

Of course, I change connect J3->23 to J7->66

expect:  adcval1 = adcval2 = adcval3 ≈2907

actual:   adcval2 = adcval3 ≈2907   adcval1 = 0xff

--------------------------------------------------------------------------------------------------------------------------

I change ADC0IN2 to ADC0IN3 again, Only three code modifications were made below

ADC_setupSOC(CONFIG_ADC0_BASE_ADDR, 0, ADC_TRIGGER_SW_ONLY, ADC_CH_ADCIN3, 16);

ADC_forceSOC(CONFIG_ADC0_BASE_ADDR, ADC_SOC_NUMBER3);

adcval1 = ADC_readResult(CONFIG_ADC0_RESULT_BASE_ADDR, ADC_SOC_NUMBER3);

I change connect J7->66 to J1->2

expect:  adcval1 = adcval2 = adcval3 ≈2907

actual:   adcval2 = adcval3 ≈2907   adcval1 = 0xff

------------------------------------------------------------------------------------------------------------------------------------------------------------ 

Why? My configuration error or anything about ADC priority?

  • Hello Zhou,

    Apologies for the delayed response as there was a US holiday yesterday. As mentioned on the other thread, can you please try this with the latest version of the SDK? Can you also share your .syscfg file used?

    One point I noticed in the following lines when changing from ADCAIN0 to ADCAIN2. 

    ADC_setupSOC(CONFIG_ADC0_BASE_ADDR, 0, ADC_TRIGGER_SW_ONLY, ADC_CH_ADCIN2, 16);

    ADC_forceSOC(CONFIG_ADC0_BASE_ADDR, ADC_SOC_NUMBER2);

    You are configuring ADC_SOC_NUMBER0, but forcing ADC_SOC_NUMBER2.

    You either need to change the setupSOC function to configure SOC2, or change the forceSOC function to trigger SOC0.

    Best Regards,

    Zackary Fleenor

  • Hello Fleenor,

           Thank you for your answer, my negligence caused this small problem, and now I have got correct answer.

    Best regards,

    Nanyi Zhou