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.

ADC test in 28335

Other Parts Discussed in Thread: TMS320F28335, CONTROLSUITE, LM6132

how to test 28335, am trying adc code in tms320f28335 bord,but it showing ramdom  vaules, even am giving 1v dc also why.

  •  

    Hi,

    How are you making the SOC?

    Are you sure that your 1V isn't floating? (The power source that you are using to make 1V must have the GND common with the GND of DSP).

    Are you using the eZdsp320F28335? if YES you can use a signal from the board, for example 3.3V.

    How are you doing to see the result of your conversion?

     

    Best regards!

     

     

  • hi ,

    am using code is given below,

    my kit is TMS320F28335

    how to is see the result?

    where i want see the result?

    example : i want give 1V dc to adc , how to give and which pins numbers to give?

    please to replay with all steps.....

     

     

     

     

     

    /
    //   For 150 MHz devices (default)
    //   divides SYSCLKOUT by six to reach a 25.0Mhz HSPCLK
    //   (assuming a 30Mhz XCLKIN).
    //
    //   For 100 MHz devices:
    //   divides SYSCLKOUT by four to reach a 25.0Mhz HSPCLK
    //   (assuming a 20Mhz XCLKIN).
    //
    //   Interrupts are enabled and the ePWM1 is setup to generate a periodic
    //   ADC SOC on SEQ1. Two channels are converted, ADCINA3 and ADCINA2.
    //
    //   Watch Variables:
    //
    //         Voltage1[10]     Last 10 ADCRESULT0 values
    //         Voltage2[10]     Last 10 ADCRESULT1 values
    //         ConversionCount  Current result number 0-9
    //         LoopCount        Idle loop counter
    //
    //
    //###########################################################################
    //
    // Original Author: D.F.
    //
    // $TI Release: DSP2833x/DSP2823x Header Files V1.20 $
    // $Release Date: August 1, 2008 $
    //###########################################################################

    #include "DSP28x_Project.h"     // Device Headerfile and Examples Include File

    // Prototype statements for functions found within this file.
    interrupt void adc_isr(void);

    // Global variables used in this example:
    Uint16 LoopCount;
    Uint16 ConversionCount;
    Uint16 Voltage1[10];
    Uint16 Voltage2[10];


    main()
    {

    // Step 1. Initialize System Control:
    // PLL, WatchDog, enable Peripheral Clocks
    // This example function is found in the DSP2833x_SysCtrl.c file.
       InitSysCtrl();


       EALLOW;
       #if (CPU_FRQ_150MHZ)     // Default - 150 MHz SYSCLKOUT
         #define ADC_MODCLK 0x3 // HSPCLK = SYSCLKOUT/2*ADC_MODCLK2 = 150/(2*3)   = 25.0 MHz
       #endif
       #if (CPU_FRQ_100MHZ)
         #define ADC_MODCLK 0x2 // HSPCLK = SYSCLKOUT/2*ADC_MODCLK2 = 100/(2*2)   = 25.0 MHz
       #endif
       EDIS;

    // Step 2. Initialize GPIO:
    // This example function is found in the DSP2833x_Gpio.c file and
    // illustrates how to set the GPIO to it's default state.
    // InitGpio();  // Skipped for this example

    // Step 3. Clear all interrupts and initialize PIE vector table:
    // Disable CPU interrupts
       DINT;

    // Initialize the PIE control registers to their default state.
    // The default state is all PIE interrupts disabled and flags
    // are cleared.
    // This function is found in the DSP2833x_PieCtrl.c file.
       InitPieCtrl();

    // Disable CPU interrupts and clear all CPU interrupt flags:
       IER = 0x0000;
       IFR = 0x0000;

    // Initialize the PIE vector table with pointers to the shell Interrupt
    // Service Routines (ISR).
    // This will populate the entire table, even if the interrupt
    // is not used in this example.  This is useful for debug purposes.
    // The shell ISR routines are found in DSP2833x_DefaultIsr.c.
    // This function is found in DSP2833x_PieVect.c.
       InitPieVectTable();

    // Interrupts that are used in this example are re-mapped to
    // ISR functions found within this file.
       EALLOW;  // This is needed to write to EALLOW protected register
       PieVectTable.ADCINT = &adc_isr;
       EDIS;    // This is needed to disable write to EALLOW protected registers

    // Step 4. Initialize all the Device Peripherals:
    // This function is found in DSP2833x_InitPeripherals.c
    // InitPeripherals(); // Not required for this example
       InitAdc();  // For this example, init the ADC

    // Step 5. User specific code, enable interrupts:

    // Enable ADCINT in PIE
       PieCtrlRegs.PIEIER1.bit.INTx6 = 1;
       IER |= M_INT1; // Enable CPU Interrupt 1
       EINT;          // Enable Global interrupt INTM
       ERTM;          // Enable Global realtime interrupt DBGM

       LoopCount = 0;
       ConversionCount = 0;

    // Configure ADC
       AdcRegs.ADCMAXCONV.all = 0x0001;       // Setup 2 conv's on SEQ1
       AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x3; // Setup ADCINA3 as 1st SEQ1 conv.
       AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x2; // Setup ADCINA2 as 2nd SEQ1 conv.
       AdcRegs.ADCTRL2.bit.EPWM_SOCA_SEQ1 = 1;// Enable SOCA from ePWM to start SEQ1
       AdcRegs.ADCTRL2.bit.INT_ENA_SEQ1 = 1;  // Enable SEQ1 interrupt (every EOS)

    // Assumes ePWM1 clock is already enabled in InitSysCtrl();
       EPwm1Regs.ETSEL.bit.SOCAEN = 1;        // Enable SOC on A group
       EPwm1Regs.ETSEL.bit.SOCASEL = 4;       // Select SOC from from CPMA on upcount
       EPwm1Regs.ETPS.bit.SOCAPRD = 1;        // Generate pulse on 1st event
       EPwm1Regs.CMPA.half.CMPA = 0x0080;      // Set compare A value
       EPwm1Regs.TBPRD = 0xFFFF;              // Set period for ePWM1
       EPwm1Regs.TBCTL.bit.CTRMODE = 0;          // count up and start

    // Wait for ADC interrupt
       for(;;)
       {
          LoopCount++;
       }

    }


    interrupt void  adc_isr(void)
    {

      Voltage1[ConversionCount] = AdcRegs.ADCRESULT0 >>4;
      Voltage2[ConversionCount] = AdcRegs.ADCRESULT1 >>4;

      // If 40 conversions have been logged, start over
      if(ConversionCount == 9)
      {
         ConversionCount = 0;
      }
      else ConversionCount++;

      // Reinitialize for next ADC sequence
      AdcRegs.ADCTRL2.bit.RST_SEQ1 = 1;         // Reset SEQ1
      AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1;       // Clear INT SEQ1 bit
      PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;   // Acknowledge interrupt to PIE

      return;
    }


  • Hi Ananda,

    I propose you to use a GRAPH to see the result of your ADconversion.

    First of all:

    I'm using the Code Composer Studio 4 version Microcontroller, you can make download gratuit

    http://processors.wiki.ti.com/index.php/Code_Composer_Studio_v4


    Let's begin:

    1) New-Project and configure your  project to use the Delfino Microcontroller 32bits

    2) Go to: Project->Properties->C/C++ Build->Include Options and add the directories DSP2833x_headers\include

    and the DSP2833x_common\include.

    3) In the IDE CCS4 at left side you will find the C/C++ Projects, make a right click in your project ->New->file

    choose for name: HelpADC.c or something like that (or not :P).

    4)make a right click in your project -> link files to project, find and link the files:

    DSP2833x_DefaultIsr.c, DSP2833x_PieCtrl.c, DSP2833x_PieVect.c,  DSP2833x_GlobalVariableDefs.c, 

    28335_RAM_Ink.cmd, DSP2833x_Headers_nonBIOS.cmd, DSP2833x_SysCtrl.h

    5) Write on the HelpADC.c file:


    //#####################################################################

    // VMG - Engenharia

    // Vanderley Maia Gomes - Embedded Systems Engineer

    // Date: 16/10/2010

    // UFCG-CAMPINA GRANDE-PARAIBA-NORDESTE-BRAZIL

    //#####################################################################

    #include "DSP28x_Project.h"

    #define LED GpioDataRegs.GPBDAT.bit.GPIO32 //To make easy access

    extern void DelayUs(Uint16);//Function defined in another file

    extern void PWMSET(void);//Function defined in another file

    extern void GPIOSET(void);//Function defined in another file

    extern void ADSET(void);//Function defined in another file



    //--- Variáveis Globais

    Uint16 AdcBuf[48]; // Buffer que vai guardar os ultimos ADC_BUF_LEN valores resultantes das conversões A/D

    Uint16 ContadorLED = 0;

    Uint16 *PonteiroBUF = AdcBuf;

    main()

    {

    //CPU Initialization

    InitSysCtrl(); // Initialize the CPU

    GPIOSET(); // Configure GPIOs

    PWMSET(); // Configure PWM

    ADSET(); // Configure AD

    DINT;


    // Initialize the PIE control registers to their default state.

    // The default state is all PIE interrupts disabled and flags

    // are cleared.

    // This function is found in the DSP2833x_PieCtrl.c file.

    InitPieCtrl();


    // Disable CPU interrupts and clear all CPU interrupt flags:

       IER = 0x0000;

       IFR = 0x0000;


    // Initialize the PIE vector table with pointers to the shell Interrupt

    // Service Routines (ISR).

    // This will populate the entire table, even if the interrupt

    // is not used in this example.  This is useful for debug purposes.

    // The shell ISR routines are found in DSP2833x_DefaultIsr.c.

    // This function is found in DSP2833x_PieVect.c.

       InitPieVectTable();


    // Enable ADCINT in PIE

       PieCtrlRegs.PIEIER1.bit.INTx6 = 1;

       IER |= M_INT1; // Enable CPU Interrupt 1

       EINT;          // Enable Global interrupt INTM

       ERTM;          // Enable Global realtime interrupt DBGM

       


    while(1)//loop infinite

    {

    DelayUs(1);

    }

    }

     

    6) Create a file.c in your project named: ADSET.c, and write:

    //#####################################################################

    // VMG - Engenharia

    // Vanderley Maia Gomes - Embedded Systems Engineer

    // Date: 16/10/2010

    // UFCG-CAMPINA GRANDE-PARAIBA-NORDESTE-BRAZIL

    //#####################################################################

    #include "DSP28x_Project.h"

    extern void DelayUs(Uint16);

    //---------------------------------------------------------------------------

    // Macros

    //

    #define ADC_cal_func_ptr (void (*)(void))0x380080

    void ADSET(void)

    {

    // Reset the ADC

    AdcRegs.ADCTRL1.bit.RESET = 1;

     

    //To reset the ADC module we need to wait a bit of time

    //exactly 2 ADCCLK, assuming that the ADCCLK was configured to 10Mhz

    //We need 150/10 = 15 CPU clocks, than we will give him 30 clocks! to reset the ADC.

     

    asm(" RPT #30 || NOP"); // Must wait for ADC reset to take effect

     

    //--- Call the ADC_cal() function located in the Boot ROM.

    //    ADC_cal_func_ptr is a macro defined in the file example_nonBios.h or

    //    example_BIOS.h (as may be the case for the example being used).  This

    //    macro simply defines ADC_cal_func_ptr to be a function pointer to

    //    the correct address in the boot ROM.

    (*ADC_cal_func_ptr)();

     

    // 0=internal, 1=external

    AdcRegs.ADCREFSEL.bit.REF_SEL = 0;


    // Power-up reference and main ADC

    AdcRegs.ADCTRL3.bit.ADCBGRFDN = 0x3;//11b = Power on reference.

    AdcRegs.ADCTRL3.bit.ADCPWDN = 1; //1b = Power On ADC Module

    AdcRegs.ADCTRL3.bit.ADCCLKPS = 0x4; //Fclk = HSPCLK/(8(ADCTRL1[7]+1));

    AdcRegs.ADCTRL3.bit.SMODE_SEL = 0; //0=sequencial mode;

    DelayUs(5000);   // Wait 5ms before using the ADC

     

     

    //---Configure the other ADC register

    AdcRegs.ADCMAXCONV.all = 0x0000;        // no autoconvertions   

    AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0; // Selecting the ADCINA0 Channel


    //Configuring ADCCTRL1, here we can chose the Acquisition window size and set the pre-scalers

    AdcRegs.ADCTRL1.bit.SUSMOD = 0;//Emulation suspend is ignored

    AdcRegs.ADCTRL1.bit.ACQ_PS = 0x7; //The Acqusition windows size is 7+1 times ADCLK períod = 42,667uS = 23.437kHz, remind ADCCLK = 150Mhz/8

    AdcRegs.ADCTRL1.bit.CPS = 0;// To make the ADCCLK = 150Mhz/8.

    AdcRegs.ADCTRL1.bit.CONT_RUN = 0;//We dont wanna that the ADC runs continuously, we will use the SOC from the ePWM module.

    AdcRegs.ADCTRL1.bit.SEQ_OVRD = 0;

    AdcRegs.ADCTRL1.bit.SEQ_CASC =1;//We are using the modules in cascate mode, but this isn't important in this example because we use just one chanel.

     


    //Configuring ADCTRL2, here we can chose how the SOC will be made.

    AdcRegs.ADCTRL2.bit.EPWM_SOCB_SEQ = 0;

    AdcRegs.ADCTRL2.bit.RST_SEQ1 = 0;

    AdcRegs.ADCTRL2.bit.SOC_SEQ1 = 0;

    //bit 12 reserved

    AdcRegs.ADCTRL2.bit.INT_ENA_SEQ1 = 1;//Interrupt request by INT_SEQ1 is enabled

    AdcRegs.ADCTRL2.bit.INT_MOD_SEQ1 = 0;

    //bit 9 reserved

    AdcRegs.ADCTRL2.bit.EPWM_SOCA_SEQ1 = 1;//Allow SEQ1/SEQ to be started by ePWMx SOCA trigger. 

     

    AdcRegs.ADCTRL2.bit.EXT_SOC_SEQ1 = 0;

    AdcRegs.ADCTRL2.bit.RST_SEQ2 = 0;

    AdcRegs.ADCTRL2.bit.SOC_SEQ2 = 0;

    //bit4 reserved

    AdcRegs.ADCTRL2.bit.INT_ENA_SEQ2 = 0;

    AdcRegs.ADCTRL2.bit.INT_MOD_SEQ2 = 0;

    //bit1 reserved

    AdcRegs.ADCTRL2.bit.EPWM_SOCB_SEQ2 = 0;

    }

     

    7) create a file.c named: GPIOSET.c and write:

    #include "DSP28x_Project.h"

    void GPIOSET(void)

    {

    //Configure pin GPIO32: I/O pin and Output.

    EALLOW;

    GpioCtrlRegs.GPBMUX1.bit.GPIO32 = 0; //Configure I/O PIN

    GpioCtrlRegs.GPBDIR.bit.GPIO32  = 1; //Configure Output

    GpioCtrlRegs.GPAMUX1.bit.GPIO0  = 1; //Setting GPIO0 1=EPWM1A

    GpioCtrlRegs.GPBMUX1.bit.GPIO42 = 0; //to use the ADC we need to configure I/O

    EDIS;

    }

    8) create a c file: PWMSET.c and write:
    #include "DSP28x_Project.h"

    void PWMSET(void)
    {
    //Configure ePWM1.
    //Disable PWM clock "to have the 2 PWM signal sincronized"
    EALLOW;
    SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0;
    EDIS;

    //Disable Timer
    EPwm1Regs.TBCTL.bit.CTRMODE = 0x3;

    //We want a PWM 2kHz and duty-cicle 50%
    //The PWM frequency can be calculated by:

    //Pwmf = (SYCLKOUT*CLKDIV*HSPCLKDIV)/(TBPRD+1) 
    //We are using a SYCLKOUT = 150Mhz
    //We want a Pwmf = 2kHz
    //We going set the CLKDIV = 1/128 and the HSPCLKDIV = 1/1.
    //Than we will have:

    //TBPRD = 150M/(2k*128*1)-1 =~ 585
    // for 1k TBPRD =~ 1171
    // for 4.8k TBPRD = 243
    EPwm1Regs.TBCTL.bit.FREE_SOFT = 0x3;
    EPwm1Regs.TBCTL.bit.CLKDIV = 0x7; //CLKDIV=1/128
    EPwm1Regs.TBCTL.bit.HSPCLKDIV = 0;//HSPCLKDIV = 1/1
    EPwm1Regs.TBCTL.bit.PRDLD = 0;//reload PRD on counter=0
    EPwm1Regs.TBCTL.bit.PHSEN = 0;//phase control disable
    EPwm1Regs.TBCTL.bit.SYNCOSEL = 0x3;//Sync-out disable
    EPwm1Regs.TBCTL.bit.PHSDIR = 0;//using in up-dowm counter mode
    EPwm1Regs.TBCTL.bit.SWFSYNC = 0;//no software sync produced
    EPwm1Regs.TBCTL.bit.CTRMODE = 0x33;//timer stopped (disabled)
    EPwm1Regs.TBCTR = 0; //Clear timer counter
    EPwm1Regs.TBPRD = 243;//585;//Value calculated before
    EPwm1Regs.TBPHS.half.TBPHS = 0;//Set timer phase
    EPwm1Regs.CMPA.half.CMPA = 121;//292;//to have approximately 50% duty-cycle
    EPwm1Regs.CMPCTL.all = 0x0002;//LOADAMODE, 10 = load on zero or PRD match
    //We need to set the Action-Qualifier Control Register
    //This register will control the PWM behavior;
    //Disable all actions
    EPwm1Regs.AQCTLA.all  = 0;
    EPwm1Regs.AQSFRC.all  = 0;
    EPwm1Regs.AQCSFRC.all = 0;;
    //Action when the Counter equals zero
    EPwm1Regs.AQCTLA.bit.ZRO = 0x2;//PWM signal = 1
    //Action when the Counter equals CMPA
    EPwm1Regs.AQCTLA.bit.CAU = 0x1;//PWM signal = 0
    EPwm1Regs.DBCTL.bit.OUT_MODE = 0; // Deadband disabled
    EPwm1Regs.PCCTL.bit.CHPEN = 0; // PWM chopper unit disabled
    EPwm1Regs.TZCTL.bit.TZA = 0x3; // Trip action disabled for output A
    EPwm1Regs.TBCTL.bit.CTRMODE = 0x0; //Set COUNT UP mode.





    //Configuring ePWM2 that will be used to trigger the SOC

    //---------------------------------------------------------------------
    //--- Configure ePWM2 to trigger the ADC at 48 kHz rate
    //---------------------------------------------------------------------
    EPwm2Regs.TBCTL.bit.CTRMODE = 0x3; // Disable the timer
     
    EPwm2Regs.TBCTL.all = 0xC033; // Configure timer control register
    // bit 15-14     11:     FREE/SOFT, 11 = ignore emulation suspend
    // bit 13        0:      PHSDIR, 0 = count down after sync event
    // bit 12-10     000:    CLKDIV, 000 => TBCLK = HSPCLK/1
    // bit 9-7       000:    HSPCLKDIV, 000 => HSPCLK = SYSCLKOUT/1
    // bit 6         0:      SWFSYNC, 0 = no software sync produced
    // bit 5-4       11:     SYNCOSEL, 11 = sync-out disabled
    // bit 3         0:      PRDLD, 0 = reload PRD on counter=0
    // bit 2         0:      PHSEN, 0 = phase control disabled
    // bit 1-0       11:     CTRMODE, 11 = timer stopped (disabled)

    EPwm2Regs.TBCTR = 0x0000; // Clear timer counter
    EPwm2Regs.TBPRD = 3124; // Set timer period
    EPwm2Regs.TBPHS.half.TBPHS = 0x0000; // Set timer phase

    EPwm2Regs.ETPS.all = 0x0100; // Configure SOCA
    // bit 15-14     00:     EPWMxSOCB, read-only
    // bit 13-12     00:     SOCBPRD, don't care
    // bit 11-10     00:     EPWMxSOCA, read-only
    // bit 9-8       01:     SOCAPRD, 01 = generate SOCA on first event
    // bit 7-4       0000:   reserved
    // bit 3-2       00:     INTCNT, don't care
    // bit 1-0       00:     INTPRD, don't care

    EPwm2Regs.ETSEL.all = 0x0A00; // Enable SOCA to ADC
    // bit 15        0:      SOCBEN, 0 = disable SOCB
    // bit 14-12     000:    SOCBSEL, don't care
    // bit 11        1:      SOCAEN, 1 = enable SOCA
    // bit 10-8      010:    SOCASEL, 010 = SOCA on PRD event
    // bit 7-4       0000:   reserved
    // bit 3         0:      INTEN, 0 = disable interrupt
    // bit 2-0       000:    INTSEL, don't care

    EPwm2Regs.TBCTL.bit.CTRMODE = 0x0; // Enable the timer in count up mode


    //Enable the clocks to the ePWM module
    EALLOW;
    SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1; // HSPCLK to ePWM modules enabled
    EDIS;
    }
    9) Create a c file: SysCtrl.c and write:
    #include "DSP28x_Project.h"
    extern void DelayUs(Uint16);//Function defined in another file

    /**********************************************************************
    * Function: InitSysCtrl()
    *
    * Description: Initializes the F2833x CPU
    **********************************************************************/
    void InitSysCtrl(void)
    {
    volatile Uint16 i; // General purpose Uint16
    volatile int16 dummy; // General purpose volatile int16

    asm(" EALLOW"); // Enable EALLOW protected register access

    //--- Memory Protection Configuration
    DevEmuRegs.PROTSTART = 0x0100; // Write default value to protection start register
    DevEmuRegs.PROTRANGE = 0x00FF; // Write default value to protection range register

    //--- Configure the PLL

    // Note: The DSP/BIOS configuration tool can also be used to initialize the PLL
    // instead of doing the initialization here.

    // Make sure the PLL is not running in limp mode
    if (SysCtrlRegs.PLLSTS.bit.MCLKSTS != 1)
    { // PLL is not running in limp mode
    SysCtrlRegs.PLLSTS.bit.MCLKOFF = 1; // Turn off missing clock detect before changing PLLCR
    SysCtrlRegs.PLLSTS.bit.DIVSEL = 0; // DIVSEL must be 0 or 1  (/4 CLKIN mode) before changing PLLCR
    SysCtrlRegs.PLLCR.bit.DIV = 0x000A; // PLLx10/4 (because DIVSEL is /4)
       
    // Wait for PLL to lock.
    // During this time the CPU will run at OSCCLK/2 until the PLL is stable.
    // Once the PLL is stable the CPU will automatically switch to the new PLL value.
    // Code is not required to sit and wait for the PLL to lock.  However, 
    // if the code does anything that is timing critical (e.g. something that
    // relies on the CPU clock frequency to be at speed), then it is best to wait
    // until PLL lock is complete.  The watchdog should be disabled before this loop
    // (e.g., as was done above), or fed within the loop.
    while(SysCtrlRegs.PLLSTS.bit.PLLLOCKS != 1) // Wait for PLLLOCKS bit to set
    {
    SysCtrlRegs.WDKEY = 0x0055; // Service the watchdog while waiting
    SysCtrlRegs.WDKEY = 0x00AA; //   in case the user enabled it.
    }

    // After the PLL has locked, we are running in PLLx10/4 mode (since DIVSEL is /4).
    // We can now enable the missing clock detect circuitry, and also change DIVSEL
    // to /2.  In this example, we will wait a bit of time to let inrush currents settle,
    // and then change DIVSEL from /4 to /2.  This is only an example.  The amount of
    // time you need to wait depends on the power supply feeding the DSP (i.e., how much
    // voltage droop occurs due to the inrush currents, and how long it takes the
    // voltage regulators to recover).
    SysCtrlRegs.PLLSTS.bit.MCLKOFF = 0; // Enable missing clock detect circuitry
    DelayUs(20/2); // Wait 20 us (just an example).  Remember we're running
    // at half-speed here, so divide function argument by 2.
    SysCtrlRegs.PLLSTS.bit.DIVSEL = 0x2; // Change to /2 mode
    }
    else
    { // PLL is running in limp mode
    // User should replace the below with a call to an appropriate function,
    // for example shutdown the system (since something is very wrong!).
    asm(" ESTOP0");
    }

    //--- Configure the clocks
    SysCtrlRegs.HISPCP.all = 0x0000; // Hi-speed periph clock prescaler, HSPCLK=SYSCLKOUT/1
    SysCtrlRegs.LOSPCP.all = 0x0002; // Lo-speed periph clock prescaler, LOSPCLK=SYSCLKOUT/4

    SysCtrlRegs.PCLKCR3.bit.GPIOINENCLK = 1; // GPIO input module is clocked
    SysCtrlRegs.PCLKCR3.bit.XINTFENCLK = 1; // XINTF module is clocked
    SysCtrlRegs.PCLKCR3.bit.DMAENCLK = 1; // SYSCLKOUT to DMA enabled
    SysCtrlRegs.PCLKCR3.bit.CPUTIMER2ENCLK = 1; // SYSCLKOUT to CPU Timer2 enabled
    SysCtrlRegs.PCLKCR3.bit.CPUTIMER1ENCLK = 1; // SYSCLKOUT to CPU Timer1 enabled
    SysCtrlRegs.PCLKCR3.bit.CPUTIMER0ENCLK = 1; // SYSCLKOUT to CPU Timer0 enabled

    SysCtrlRegs.PCLKCR1.bit.EQEP2ENCLK = 1; // SYSCLKOUT to eQEP2 enabled
    SysCtrlRegs.PCLKCR1.bit.EQEP1ENCLK = 1; // SYSCLKOUT to eQEP1 enabled
    SysCtrlRegs.PCLKCR1.bit.ECAP6ENCLK = 1; // SYSCLKOUT to eCAP6 enabled
    SysCtrlRegs.PCLKCR1.bit.ECAP5ENCLK = 1; // SYSCLKOUT to eCAP5 enabled
    SysCtrlRegs.PCLKCR1.bit.ECAP4ENCLK = 1; // SYSCLKOUT to eCAP4 enabled
    SysCtrlRegs.PCLKCR1.bit.ECAP3ENCLK = 1; // SYSCLKOUT to eCAP3 enabled
    SysCtrlRegs.PCLKCR1.bit.ECAP2ENCLK = 1; // SYSCLKOUT to eCAP2 enabled
    SysCtrlRegs.PCLKCR1.bit.ECAP1ENCLK = 1; // SYSCLKOUT to eCAP1 enabled
    SysCtrlRegs.PCLKCR1.bit.EPWM6ENCLK = 1; // SYSCLKOUT to ePWM6 enabled
    SysCtrlRegs.PCLKCR1.bit.EPWM5ENCLK = 1; // SYSCLKOUT to ePWM5 enabled
    SysCtrlRegs.PCLKCR1.bit.EPWM4ENCLK = 1; // SYSCLKOUT to ePWM4 enabled
    SysCtrlRegs.PCLKCR1.bit.EPWM3ENCLK = 1; // SYSCLKOUT to ePWM3 enabled
    SysCtrlRegs.PCLKCR1.bit.EPWM2ENCLK = 1; // SYSCLKOUT to ePWM2 enabled
    SysCtrlRegs.PCLKCR1.bit.EPWM1ENCLK = 1; // SYSCLKOUT to ePWM1 enabled

    SysCtrlRegs.PCLKCR0.bit.ECANBENCLK = 1; // SYSCLKOUT/2 to eCAN-B enabled
    SysCtrlRegs.PCLKCR0.bit.ECANAENCLK = 1; // SYSCLKOUT/2 to eCAN-A enabled
    SysCtrlRegs.PCLKCR0.bit.MCBSPAENCLK = 1; // LSPCLK to McBSP-A enabled
    SysCtrlRegs.PCLKCR0.bit.MCBSPBENCLK = 1; // LSPCLK to McBSP-B enabled
    SysCtrlRegs.PCLKCR0.bit.SCIBENCLK = 1; // LSPCLK to SCI-B enabled
    SysCtrlRegs.PCLKCR0.bit.SCIAENCLK = 1; // LSPCLK to SCI-A enabled
    SysCtrlRegs.PCLKCR0.bit.SPIAENCLK = 1; // LSPCLK to SPI-A enabled
    SysCtrlRegs.PCLKCR0.bit.SCICENCLK = 1; // LSPCLK to SCI-C enabled
    SysCtrlRegs.PCLKCR0.bit.I2CAENCLK = 1; // LSPCLK to I2C-A enabled
    SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 1; // HSPCLK to ADC enabled

    // The PCLKCR0.TBCLKSYNC bit is handled in the InitEPwm() function since
    // it affects synchronization of the ePWM counters.

    //--- Configure the low-power modes
    SysCtrlRegs.LPMCR0.all = 0x00FC; // LPMCR0 set to default value

    //--- Finish up
    asm(" EDIS"); // Disable EALLOW protected register access

    } // end InitSysCtrl()


    //--- end of file -----------------------------------------------------

    10) Well, you create a complete project that uses two PWM, ePWM1 to give a PWM signal with 4.8kHz rate and 50% duty-cycle and ePWM2 to trigger the SOC of your ADC and is configurable to 48kHz rate. Your ePWM1 signal is avaiable in GPIO0 and your ADC signal must to be inserted in the GPIO42, ATTENTION AVOID MORE THAN 3V!

     

    11) Conect your GPIO0 to your GPIO42 ATTENTION, TURN OFF YOUR eZdsp KIT before conect GPIOs

     

    12) Build your project and Debug Launch

    13)  After Debug Launch Create a GRAPH to see your conversion: 

    13.1) Tools -> Graph -> Single Time

    13.2) Acquisiton Buffer Size = 48, Dsp Data Type = 16 Bits Unsigned Integer, Sampling Rate = 48000Hz, Display Data Size = 48, Time Display Unit = uS.

     

    14) Click in Enable Silicon Real Time Mode, and choose YES if the IDE ask you something.

     

    15) In your graph search and click in ENABLE CONTINUOUS REFRESH

     

    16) GO to VIEW->Memory and Write AdcBuf, find and click in ENABLE CONTINUOUS REFRESH.

     

    17) Now click in RUN!!! That is all, if everythin is gonna be alright you will see the PWM signal in your graph.

     

    Best regards!

  • Dear Vanderley Maia,
    thank you for solution.
    i will try and replay you

  • You are welcome,

    Another thing, after Debug Launc and Run, if all gonna be alright the LED will be blinking

    bye!

     

  • -Vanderley

    Actually i have the similar problem on 28335, 28035 or 2812. for 28035 or 2812, it can collect some data and convert result but it has big offset when the voltage is close to 3V.  I use standard power supply as calibration signal source. for 28335. The example code that I ran is from controlSUITE. It is supposed to be used in very straightforward way. I don't think it needs some VEROFL pin connected, something like that. But what is the problem? Any suggestion?

    I think customer won't like to do complicated calibration over on-chip ADC every time.

    thanks

    -Yu Cai

  • Dear Vanderley Maia,

    we made your program but it is not building why please give reply, i given cc4 figure also.

    Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4

    One more help ,

    How to work on DMA with ADC,

    AAK

     

     

     

     

     

     

  • Hi Ananda,

     

    Well I didn't get why isn't building?

    You made your Target Configuration?

    Here My Project:

     

    Take my project in: http://www.4shared.com/file/96uMTYEL/HelpADC.html

    About DMA with ADC, I have no experience but I will read about and if I understand

    I will reply you.

     

    Best regards!

  • Hi Yu Cai,

    First of all, sorry for the delay, I have not seen your question before.

     

    Well I'm using in my circuit a LM6132 Operational Amplifier for make a OFFSET signal.

    But I don't know if you have the same needs than I.

     

    I need to use a offset circuit because I have a sensor that gives me negative signals, than I have to ensure that the

    A/D port signal (ADCINA0 pin) will be greater than 0V.

     

    I set my OFFSET 1.5V and I dont have problems when my A/D port signal is close to 3V.

     

    I'm using the 3.3V pin from eZdsp board for power supplying the LM6132.

     

    Best regards