Close

CC3200 12 bit ADC

A project log for Monitor Data and Rmote Control from a WebApp

Internet-Of-Things open project - connect to the web, monitor data and control onboard LED with CC3200 and a simple web application.

romanRoman 10/07/2017 at 16:560 Comments

ADC initialization (main.c):

//ADC ####ADC####ADC####ADC####ADC####ADC####ADC##############################################################
    //
    // Pinmux for the selected ADC input pin
    //
    MAP_PinTypeADC(PIN_60,PIN_MODE_255);
    uiChannel = ADC_CH_3;
    //
    // Configure ADC timer which is used to timestamp the ADC data samples
    //
    MAP_ADCTimerConfig(ADC_BASE,2^17);
    //
    // Enable ADC timer which is used to timestamp the ADC data samples
    //
    MAP_ADCTimerEnable(ADC_BASE);
    //
    // Enable ADC module
    //
    MAP_ADCEnable(ADC_BASE);
    //
    // Enable ADC channel
    //
    MAP_ADCChannelEnable(ADC_BASE, uiChannel);

Inside the man.c while{ } loop:

//ADC  ##########################################################################################################
    	while(uiIndex < NO_OF_SAMPLES + 4)
    	{
    		if(MAP_ADCFIFOLvlGet(ADC_BASE, uiChannel))//If a sample is ready
    		{
    			ulSample = MAP_ADCFIFORead(ADC_BASE, uiChannel);//Read the sample
    			pulAdcSamples[uiIndex++] = ulSample;//Load the sample into an array
    		}
    	}
    	//MAP_ADCChannelDisable(ADC_BASE, uiChannel);//
    	uiIndex = 0;
    	ADCsum = 0;
    	while(uiIndex < NO_OF_SAMPLES + 4)
    	{
    		//UART_PRINT("\n\rVoltage is %f\n\r",(((float)((pulAdcSamples[4+uiIndex] >> 2 ) & 0x0FFF))*1.4)/4096);
    		ADCsum = ADCsum + pulAdcSamples[uiIndex];
    		uiIndex++;
    	}
    	ADCsum = ADCsum / (NO_OF_SAMPLES + 4);
    	UART_PRINT("\n\rVoltage is %f\n\r",((ADCsum >> 2 ) & 0x0FFF)*1.4/4096);
    	//UART_PRINT("\n\rVoltage is %f\n\r",((pulAdcSamples[4] >> 2 ) & 0x0FFF)*1.4/4096);
    	UART_PRINT("\n\r");
//################################################################################################################

Discussions