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.

TMS320F28035: I inherited asm code for the CLA1 to read the ADC in the background

Part Number: TMS320F28035
Other Parts Discussed in Thread: C2000WARE

For some reason I'm just getting values for ADCRESULT0 and ADCRESULT1.

I want to read 14 ADCRESULT values.

Thanks for any insights to help me understand what's happening.

Mechi

// TI File $Revision: /main/2 $
// Checkin $Date: February 20, 2009   15:37:05 $
//###########################################################################
//
// FILE:	DSP2803x_Adc.c
//
// TITLE:	DSP2803x ADC Initialization & Support Functions.
//
//###########################################################################
// $TI Release: DSP2803x C/C++ Header Files V1.10 $
// $Release Date: July 27, 2009 $
//###########################################################################

#include "DSP2803x_Device.h"     // DSP2803x Headerfile Include File
#include "DSP2803x_Examples.h"   // DSP2803x Examples Include File

#define ADC_usDELAY  1000L

//---------------------------------------------------------------------------
// InitAdc:
//---------------------------------------------------------------------------
// This function initializes ADC to a known state.
//
// NOTE: ADC INIT IS DIFFERENT ON 2803x DEVICES COMPARED TO OTHER 28X DEVICES
//
void InitAdc(void)
{


    // *IMPORTANT*
	// The Device_cal function, which copies the ADC calibration values from TI reserved
	// OTP into the ADCREFSEL and ADCOFFTRIM registers, occurs automatically in the
	// Boot ROM. If the boot ROM code is bypassed during the debug process, the
	// following function MUST be called for the ADC to function according
	// to specification. The clocks to the ADC MUST be enabled before calling this
	// function.
	// See the device data manual and/or the ADC Reference
	// Manual for more information.

	    EALLOW;
		SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 1;
		(*Device_cal)();
		EDIS;

    // To powerup the ADC the ADCENCLK bit should be set first to enable
    // clocks, followed by powering up the bandgap, reference circuitry, and ADC core.
    // Before the first conversion is performed a 5ms delay must be observed
	// after power up to give all analog circuits time to power up and settle

    // Please note that for the delay function below to operate correctly the
	// CPU_RATE define statement in the DSP2803x_Examples.h file must
	// contain the correct CPU clock period in nanoseconds.
	EALLOW;
	AdcRegs.ADCCTL1.bit.ADCBGPWD  = 1;		// Power ADC BG
	AdcRegs.ADCCTL1.bit.ADCREFPWD = 1;		// Power reference
	AdcRegs.ADCCTL1.bit.ADCPWDN   = 1;		// Power ADC
	AdcRegs.ADCCTL1.bit.ADCENABLE = 1;		// Enable ADC
	AdcRegs.ADCCTL1.bit.ADCREFSEL = 0;		// Select internal BG
	EDIS;

    DELAY_US(ADC_usDELAY);         // Delay before converting ADC channels
}

void InitAdcAio()
{

   EALLOW;

/* Configure ADC pins using AIO regs*/
// This specifies which of the possible AIO pins will be Analog input pins.
// NOTE: AIO1,3,5,7-9,11,13,15 are analog inputs in all AIOMUX1 configurations.
// Comment out other unwanted lines.

    GpioCtrlRegs.AIOMUX1.bit.AIO2 = 2;    // Configure AIO2 for A2 (analog input) operation
    GpioCtrlRegs.AIOMUX1.bit.AIO4 = 2;    // Configure AIO4 for A4 (analog input) operation
    GpioCtrlRegs.AIOMUX1.bit.AIO6 = 2;    // Configure AIO6 for A6 (analog input) operation
    GpioCtrlRegs.AIOMUX1.bit.AIO10 = 2;   // Configure AIO10 for B2 (analog input) operation
    GpioCtrlRegs.AIOMUX1.bit.AIO12 = 2;   // Configure AIO12 for B4 (analog input) operation
    GpioCtrlRegs.AIOMUX1.bit.AIO14 = 2;   // Configure AIO14 for B6 (analog input) operation
    EDIS;
}

Attached are the relevant files.

  • Mechi,

    Can you point us to the instruction where you are trying to read the other result registers other than RESULT0/1?

    Regards,
    Praveen

  • I really have no idea.

    From what I understand, there are 2 reads at a time (0 & 1, 2 & 3, etc.) and then there's a loop to read until it reaches NUM_DATA_POINTS.

    What I see actually happening is that only ADCRESULT0 and ADCRESULT1 are being populated...

    Here's InitCLA() code:

    //==============================================
    //      Initialize the CLA registers        
    //==============================================
    void InitCLA(void)
    {
    
       MemCopy(&Cla1funcsLoadStart, &Cla1funcsLoadEnd, &Cla1funcsRunStart); 
    
       EALLOW;
       Cla1Regs.MVECT1 = (Uint16)(&Cla1Task1-&Cla1Prog_Start)*sizeof(Uint32);
       Cla1Regs.MVECT2 = (Uint16)(&Cla1Task2-&Cla1Prog_Start)*sizeof(Uint32);
       Cla1Regs.MVECT3 = (Uint16)(&Cla1Task3-&Cla1Prog_Start)*sizeof(Uint32);
       Cla1Regs.MVECT8 = (Uint16)(&Cla1Task8-&Cla1Prog_Start)*sizeof(Uint32);
       Cla1Regs.MPISRCSEL1.bit.PERINT1SEL = CLA_INT1_ADCINT1; // ADCINT2 starts Task 1
       Cla1Regs.MPISRCSEL1.bit.PERINT2SEL = CLA_INT2_ADCINT2;
       Cla1Regs.MPISRCSEL1.bit.PERINT3SEL = CLA_INT3_ADCINT3;
       //MemCopy(&Cla1funcsLoadStart, &Cla1funcsLoadEnd, &Cla1funcsRunStart); 
       Cla1Regs.MMEMCFG.bit.PROGE = 1;  // Map CLA program memory to the CLA
    
       // SQA software doc. - for SIL software test number 1 (Wrong CLA initialization - no sampling of pulses)
       // Cla1Regs.MCTL.bit.IACKE = 0;    // Disable IACK to start tasks via software
    
       Cla1Regs.MCTL.bit.IACKE = 1;       // Enable IACK to start tasks via software
    
       Cla1Regs.MIER.all = (M_INT8|M_INT1|M_INT2|M_INT3);   // Enable Task 8 and Task 1
       EDIS;
    
       // Calibration_Value = 0;
       task_state = CALIBRATION;
    
       // GainPhase = UNKNOW;
    }

    Here's the definition of the structure to store the RF values read:

    union  ADC_DATA{
       Uint32  	StartData[NUM_DATA_POINTS];
       Uint16	NormalData[NUM_DATA_POINTS*2];
    };
    
    union  ADC_DATA ADC_A; // ADC_A[NUM_DATA_POINTS];
    union  ADC_DATA ADC_B; //Uint32 ADC_B[NUM_DATA_POINTS];
    Uint32 ADC_A_COUNTER1;
    Uint32 ADC_A_COUNTER2;
    Uint32 ADC_B_COUNTER1;
    Uint32 ADC_B_COUNTER2;
    
    float32 normal_fun_counter;
    float32 normal_ref_counter;
    

    There's code to erase all of the ADC Data points...

  • I had to erase the ASM code...

    _
  • Hi Menchi,

    While we look at these codes, I had a question for you. Have you used any existing c2000ware examples to develop these codes or developed from scratch? Have you looked into any examples as a reference to achieve what you are trying to accomplish?

    Regards,
    Praveen

  • This is code that someone from TI helped us with.

    That's what I meant that it was "inherited".

    I have to work one-on-one - I can't put the code in the forum...Can you help me with this? 

    Thanks,

    Mechi

  • The discussion will happen offline over mail. Closing this thread.