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.

TMS320F28377D: ADC settings

Part Number: TMS320F28377D
Other Parts Discussed in Thread: SYSCONFIG, C2000WARE

  Hi,

I have the following simple code which is not simple for me.  Could you please help me understand and make it better?

1. For acqps setting, can I use one if statement which can include all ADCA to ADCD (I actually have the setting from ADCA to ADCD) ?

2. For one ADCA or other ADCX,  is the following one interrupt setting enough? or do I need to add the three ? mark setting after ADCA SOC0 setting?

       AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 1;      //EOC_X will set INT1 flag

       AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1;        //enable INT1 flag

       AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;      //make sure INT1 flag is cleared

3. Do I need to set this ( is this the default setting)?  AdcaRegs.ADCSOCPRICTL.bit.SOCPRIORITY = 15;  // SOC0 is high priority.

4. The trigger source is ePWM1, what if ePWM3 is not setting or is on off state? what does the ADC value look like, zero or not allowed?  In my settings, some are triggered by ePWM1, some are triggered by ePWM7. When ePWM1 is on, ePWM7 is off or vice versa, can I do the setting together or I have to set it separately?

5. ADCa_soc0, ADCb_soc0, ADCc_soc0 and ADCd_soc0 are processed simultaneously, then all ADCx_soc1, ---15? If so, can I just set one interrupt for all by choosing the largest socx as the trigger source? 

6. Is any of  SEL1N2 or SEL3N4 fine to choose?

Thanks for your help,

Hongmei

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

if(ADC_RESOLUTION_12BIT == AdcaRegs.ADCCTL2.bit.RESOLUTION){

            acqps = 14;

        }

        else {

            acqps = 63;

        }       

 

       EALLOW;

       {

           AdcaRegs.ADCSOC0CTL.bit.CHSEL = 0;         

           AdcaRegs.ADCSOC0CTL.bit.ACQPS = acqps

           AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 5;       

           AdcaRegs.ADCSOCPRICTL.bit.SOCPRIORITY = 15;  // SOC0 is high priority

       }

      ?  AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 0;      //EOC_X will set INT1 flag

      ?  AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1;        //enable INT1 flag

      ? AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;      //make sure INT1 flag is cleared

       {

           AdcaRegs.ADCSOC1CTL.bit.CHSEL = 1;      

           AdcaRegs.ADCSOC1CTL.bit.ACQPS = acqps;

           AdcaRegs.ADCSOC1CTL.bit.TRIGSEL = 5 ;

       }

       AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 1;      //EOC_X will set INT1 flag

       AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1;        //enable INT1 flag

       AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;      //make sure INT1 flag is cleared

       EDIS;

 

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

if(ADC_RESOLUTION_12BIT == AdcbRegs.ADCCTL2.bit.RESOLUTION){

           acqps = 14;

       }

       else {

           acqps = 63;

       }

       EALLOW;

      // if (1 <= ADC_B_SAMPLING_NUMBER_ISR1)

       {

           AdcbRegs.ADCSOC0CTL.bit.CHSEL = ADC_B_SAMPLING_CH1_ISR1;

           AdcbRegs.ADCSOC0CTL.bit.ACQPS = acqps;     

           AdcbRegs.ADCSOC0CTL.bit.TRIGSEL = 5;

       }

       AdcbRegs.ADCINTSEL1N2.bit.INT1SEL = 1;      //end of SOC0 will set INT1 flag

       AdcbRegs.ADCINTSEL1N2.bit.INT1E = 1;        //enable INT1 flag

       AdcbRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;      //make sure INT1 flag is cleared

       EDIS;

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

  • Hi Hongmei,

    I recommend using our sysconfig tool to setup the ADC, its a graphical tool that will generate code for you depending on your desired settings. If you download the latest C2000Ware package and look at the F2837xD ADC examples within the 'driverlib' folder you'll find a project which utilizes sysconfig. 

    If after using the tool you still have the same questions please let me know.

    Best Regards,

    Marlyn

  • Hi Marlyn,

    I have a stupid question: How can I get all  the related files for my project to use?

    For example, I modify the following setting in my project. The functions like ADC_forceMultipleSOC(ADCA_BASE, (ADC_FORCE_SOC0 | ADC_FORCE_SOC1)), parameters like ADCA_BASE, are in hw_memmap.h and adc.h files. I can copy these two to my project, however adc.h has other header files, where can I find it?

    Can I just include some files or get an include path for my project or some other simple way to use it?

    Thanks,

    -Hongmei

  • Hi Hongmei,

    I recommend you start working from the empty project found within C2000Ware. This way all of the paths will be resolved and you wont have to manually include files within your project.

    C:\ti\c2000\C2000Ware_version\driverlib\f2837xd\examples\cpu1\empty_projects

    Best Regards,

    Marlyn