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.

【F28377S】 How should I set up ADC sampling frequency?

Other Parts Discussed in Thread: CONTROLSUITE

Hi,

None of the existing examples or discussion help me understand how should I make the sampling frequency of ADC (12bit mode) to be 3.5MHz. I read a lot of datasheet and manual but none of them make sense to me.

void ConfigureADC(void)
{
	EALLOW;

	//write configurations
	AdcaRegs.ADCCTL2.bit.PRESCALE = 6; //set ADCCLK divider to /4
    AdcSetMode(ADC_ADCA, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);

	//Set pulse positions to late
	AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 1;

	//power up the ADC
	AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1;

	//delay for 1ms to allow ADC time to power up
	DELAY_US(1000);

	EDIS;
}

void ConfigureEPWM(void)
{
	EALLOW;
	// Assumes ePWM clock is already enabled
	EPwm1Regs.ETSEL.bit.SOCAEN	= 0;	        // Disable SOC on A group
	EPwm1Regs.ETSEL.bit.SOCASEL	= 4;	        // Select SOC on up-count
	EPwm1Regs.ETPS.bit.SOCAPRD = 1;		        // Generate pulse on 1st event
	EPwm1Regs.CMPA.bit.CMPA = 0x0800;          // Set compare A value to corresponding counts
	EPwm1Regs.TBPRD = 0x1000 ;       // Set period to 4096 counts
	EPwm1Regs.TBCTL.bit.CTRMODE = 3;            // freeze counter
	EDIS;
}

void SetupADCEpwm(Uint16 channel)
{
	Uint16 acqps;

	//determine minimum acquisition window (in SYSCLKS) based on resolution
	if(ADC_RESOLUTION_12BIT == AdcaRegs.ADCCTL2.bit.RESOLUTION){
		acqps = 14; //75ns
	}
	else { //resolution is 16-bit
		acqps = 63; //320ns
	}

	//Select the channels to convert and end of conversion flag
	EALLOW;
	AdcaRegs.ADCSOC0CTL.bit.CHSEL = channel;  //SOC0 will convert pin A0
	AdcaRegs.ADCSOC0CTL.bit.ACQPS = acqps;   //
	AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 5; //trigger on ePWM1 SOCA/C
	AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 0; //end of SOC0 will set INT1 flag
	AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1;   //enable INT1 flag
	AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //make sure INT1 flag is cleared
}

Above is the example configuration given by controlSUITE, there is no comment at all about what is the sampling frequency of this example. I tested it with multiple sinusoidal waves from 100Hz to 5kHz and I even see envelopes which don't make sense at all. None of the result I calculated has any connection with the number 0x1000 (TBPRD) 14(acqps)... and etc.

Could any one please just give a brief example to show how should I achieve setting sampling frequency at 3.5Mhz?

Couldn't appreciate more!

  • Hi YC,

    Simply import this example code from controlSuite: C:\ti\controlSUITE\device_support\F2837xS\v191\F2837xS_examples_Cpu1\adc_soc_epwm
    In ConfigureEPWM(void) function vary the TBPRD value to a very low value such as 100 and CMPA to 0. You'll also have to change the Pre-scaler in ConfigureADC which says divide by 4 to divide by 1. I'm not sure what sampling frequency  frequency you'll achieve but just guiding you to setup a high value.

    Regards,
    Gautam