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.

Stellaris Launchpad 2 channel ADC working code needed

hi,

     This is rajesh, recently i am purchase ARM stellaris launchpad kit. I want 2 channel working ADC code. Pls everyone help me.. 

Thanks in advance

Regards

Rajesh

  • RAJESH SHANMUGAM said:
    I want 2 channel working ADC code. Pls everyone help me.. 

    So - will today's homework assignment yield extra credit - with everyone doing the work for you?

    Even the most minimal - most basic investigation (by you) - would yield the required knowledge base...

    Your sub 15 USD "launchpad investment" should not deprive you of the normal/customary learning exercise we all experience - when trying to master a new challenge.  Your specific quest for "working code" strongly signals that you have less than optimal "learning/mastery" as your goal...

  • I appreciate the sources you gave.  I have been working to read a pair of sensors, concurrently or not, and am trying to use different ADCs for each sensor.  However, right now, the first sensor read through ADC0 is reading correctly, as far as I can tell, but the second, read through ADC1, is effected by the output of the first sensor.

    How does GPIOPinTypeADC() work?  How do I choose which ADC I want to connect the pin to, particularly if I want to use both ADCs at once?  Right now I use different sequencers, ADCs, and channels, but they signal from the first still appears to be in the second's ADC.  I've used an oscilloscope to verify that the sensor's outputs are not actually connected, so it appears to be a problem with how they connect to the ADCs in the microcontroller.

    I'm confused about how I choose which ADC gets which AIN pin.  Any advice?

  • It might be a little late to comment now but i will anyway. Below is a sample code to read data from 4 ADC channels (PE3, PE2, PE1 & PE0) and the internal temperature sensor of the Launchpad. The data obtained can be checked using a Hyperterminal or putty as i have also written a code for creating a UART interface. The code is commented well and i don't think there should be any problem for you to understand it. 

    ______________________________________________________

    #include "inc/hw_memmap.h" 
    #include "inc/hw_types.h" 
    #include "driverlib/debug.h" 
    #include "driverlib/sysctl.h" 
    #include "driverlib/adc.h" 
    #include "driverlib/uart.h"
    #include "driverlib/gpio.h" 

    #ifdef DEBUG //Error Checking on APIs
    void__error__(char *pcFilename, unsigned long ulLine)
    {
    }
    #endif

    int main(void)
    {
    unsigned long ulADC0Value[8];
    //We will use Sequencer 0 (having a FIFO Depth of 8). So, 8 Samples are generated.

    volatile unsigned long ulTempAvg;

    SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);
    //Configure System Clock to Run with 16Mhz crystal in Main Oscillator. Use PLL (400MHz). Divide by 5 (There is also, a default Divide by 2)
    //Hence, Divide by 10. So, Clock Frequency = 400/10 = 40MHz.

    SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); //Enable ADC0 Peripheral

    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); //Enable UART Peripheral

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); //Enable Port A Peripheral

    UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
    //Configure UART; Baud Rate Set to 115200, WLEN (Word length/No. of Data Bits) set to 8, One Stop Bits, Parity None

    GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); //PA0 - U0RX, PA1 = U0TX

    UARTFIFOEnable(UART0_BASE); // UART FIFO Buffer Enable

    UARTEnable(UART0_BASE); //Enable UART

    SysCtlADCSpeedSet(SYSCTL_ADCSPEED_250KSPS); //ADC Sample Rate set to 250 Kilo Samples Per Second

    ADCHardwareOversampleConfigure(ADC0_BASE, 64); // Hardware averaging. ( 2, 4, 8 , 16, 32, 64 )
    //64 Samples are averaged here i.e, each sample will be a result of 64 averaged samples. Therefore, every result is a result of 64 x 4 = 256 samples.

    ADCSequenceDisable(ADC0_BASE, 1); //Before Configuring ADC Sequencer 1, it should be OFF

    ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_PROCESSOR, 0);
    //ADC Configured so that Processor Triggers the sequence and we want to use highest priority. ADC Sequencer 0 is Used.

    ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ADC_CTL_CH0); //Sequencer Step 0: Samples Channel PE3
    ADCSequenceStepConfigure(ADC0_BASE, 0, 1, ADC_CTL_CH1); //Sequencer Step 1: Samples Channel PE2
    ADCSequenceStepConfigure(ADC0_BASE, 0, 2, ADC_CTL_CH2); //Sequencer Step 2: Samples Channel PE1
    ADCSequenceStepConfigure(ADC0_BASE, 0, 3, ADC_CTL_CH3); //Sequencer Step 3: Samples Channel PE0

    ADCSequenceStepConfigure(ADC0_BASE, 0, 4, ADC_CTL_TS); //Sequencer Step 4: Samples Temperature Sensor
    ADCSequenceStepConfigure(ADC0_BASE, 0, 5, ADC_CTL_TS); //Sequencer Step 5: Samples Temperature Sensor
    ADCSequenceStepConfigure(ADC0_BASE, 0, 6, ADC_CTL_TS); //Sequencer Step 6: Samples Temperature Sensor
    ADCSequenceStepConfigure(ADC0_BASE, 0, 7, ADC_CTL_TS | ADC_CTL_IE | ADC_CTL_END);
    //Final Sequencer Step also Samples and enables Interrupt and we are telling the sequencer that this is the last step

    //Configuring all eight steps in the ADC Sequence

    ADCSequenceEnable(ADC0_BASE, 0); //Enable ADC Sequence


    while(1)
    {
    ADCIntClear(ADC0_BASE, 0); // Clear ADC Interrupt
    ADCProcessorTrigger(ADC0_BASE, 0); // Trigger ADC Interrupt

    while(!ADCIntStatus(ADC0_BASE, 0, false)) //Wait for interrupt Status flag to go off
    {
    }

    //Conversion Complete

    ADCSequenceDataGet(ADC0_BASE, 0, ulADC0Value); //Grab the Entire FIFO

    ulTempAvg = (ulADC0Value[4] + ulADC0Value[5] + ulADC0Value[6] + ulADC0Value[7] + 2)/4;

    char x[4], y[4], z[4], w[4], a[4]; //Character arrays for storing ADC Data for TX

    a[3] = ulTempAvg%10 + 48;
    ulTempAvg = ulTempAvg/10 ;
    a[2] = ulTempAvg%10 + 48;
    ulTempAvg = ulTempAvg/10 ;
    a[1] = ulTempAvg%10 + 48;
    a[0] = ulTempAvg/10 + 48;

    x[3] = ulADC0Value[0]%10 + 48;
    ulADC0Value[0] = ulADC0Value[0]/10 ;
    x[2] = ulADC0Value[0]%10 + 48;
    ulADC0Value[0] = ulADC0Value[0]/10 ;
    x[1] = ulADC0Value[0]%10 + 48;
    x[0] = ulADC0Value[0]/10 + 48;

    y[3] = ulADC0Value[1]%10 + 48;
    ulADC0Value[1] = ulADC0Value[1]/10 ;
    y[2] = ulADC0Value[1]%10 + 48;
    ulADC0Value[1] = ulADC0Value[1]/10 ;
    y[1] = ulADC0Value[1]%10 + 48;
    y[0] = ulADC0Value[1]/10 + 48;

    z[3] = ulADC0Value[2]%10 + 48;
    ulADC0Value[2] = ulADC0Value[2]/10 ;
    z[2] = ulADC0Value[2]%10 + 48;
    ulADC0Value[2] = ulADC0Value[2]/10 ;
    z[1] = ulADC0Value[2]%10 + 48;
    z[0] = ulADC0Value[2]/10 + 48;

    w[3] = ulADC0Value[3]%10 + 48;
    ulADC0Value[3] = ulADC0Value[3]/10 ;
    w[2] = ulADC0Value[3]%10 + 48;
    ulADC0Value[3] = ulADC0Value[3]/10 ;
    w[1] = ulADC0Value[3]%10 + 48;
    w[0] = ulADC0Value[3]/10 + 48;

    UARTCharPutNonBlocking(UART0_BASE, x[0]); // Put Character in UART Transmit Buffer
    UARTCharPutNonBlocking(UART0_BASE, x[1]);
    UARTCharPutNonBlocking(UART0_BASE, x[2]);
    UARTCharPutNonBlocking(UART0_BASE, x[3]);

    UARTCharPutNonBlocking(UART0_BASE, ' ');

    SysCtlDelay(10000);

    UARTCharPutNonBlocking(UART0_BASE, y[0]);
    UARTCharPutNonBlocking(UART0_BASE, y[1]);
    UARTCharPutNonBlocking(UART0_BASE, y[2]);
    UARTCharPutNonBlocking(UART0_BASE, y[3]);

    UARTCharPutNonBlocking(UART0_BASE, ' ');

    SysCtlDelay(10000);

    UARTCharPutNonBlocking(UART0_BASE, z[0]);
    UARTCharPutNonBlocking(UART0_BASE, z[1]);
    UARTCharPutNonBlocking(UART0_BASE, z[2]);
    UARTCharPutNonBlocking(UART0_BASE, z[3]);

    UARTCharPutNonBlocking(UART0_BASE, ' ');

    SysCtlDelay(10000);

    UARTCharPutNonBlocking(UART0_BASE, w[0]);
    UARTCharPutNonBlocking(UART0_BASE, w[1]);
    UARTCharPutNonBlocking(UART0_BASE, w[2]);
    UARTCharPutNonBlocking(UART0_BASE, w[3]);

    UARTCharPutNonBlocking(UART0_BASE, ' ');

    SysCtlDelay(10000);

    UARTCharPutNonBlocking(UART0_BASE, a[0]);
    UARTCharPutNonBlocking(UART0_BASE, a[1]);
    UARTCharPutNonBlocking(UART0_BASE, a[2]);
    UARTCharPutNonBlocking(UART0_BASE, a[3]);

    UARTCharPutNonBlocking(UART0_BASE, ' ');

    UARTCharPutNonBlocking(UART0_BASE, '\n');

    SysCtlDelay(2000000);
    }
    }

  • Jaspreet Singh said:
    read data from 4 ADC channels (PE3, PE2, PE1 & PE0)

    This is a nice job - but for the missing, "SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);" //   don't you think?

    Older M3 Stellaris may have had dedicated ADC pins - but homework seeker and your post refer to M4 - and ADC usually is not default...

         SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); //Enable ADC0 Peripheral

         SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); //Enable UART Peripheral

         SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); //Enable Port A Peripheral

    Unless PE0-PE3 "default" to ADC - clock to that port is required... ARM MCUs (all makers) are especially notorious for demanding that all clocks - be present/accounted for...

     

  • I don't think there's any need for adding that line you mentioned "SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE)" to enable Port E Peripheral!

    Check here http://www.ti.com/lit/ug/spmu289a/spmu289a.pdf (Stellaris Launchpad Manual, Page 10)

    The pins i mentioned default to ADC0 Peripheral.

     

  • Jaspreet Singh said:
    I don't think there's any need

    You'll note my qualifier - "if said pins do not default into ADC mode."

    That said - might not your code be even more sound - and of higher value - by being able to extend to many other Ports and Pins?

    Should the code - as you've listed - be modified (quite likely in reality) to any other port - and such ADC default behavior is not fully replicated - what then?

    And that is why far beyond, "any need" - instead there exists maximal need for the ADC Port's proper initialization!

    Relying upon usually rare and surely inconsistent "default" behavior is not, "Best Practice."  Q.E.D.

    And - will surely "bite" you/others the moment you "copy/paste" such code into another Port - or another MCU...

  • I completely agree with you sir ! 

    Frankly speaking, i am newbie to this Stellaris MCU development environment. I haven't worked on any other controller from this series except the LM120H5QR that's there in the Stellaris launchpad and this question was specifically asked for Stellaris Launchpad. So, i provided a code accordingly. That being said, i agree to what you have said in this post. I will keep that in mind if incase i reply to any other post asking for code in this forum. 

  • Hi,

    The sequences for initializing ADC are given beautifully in this program. I have a doubt though. In the program you have posted, you are using only ADC0 for sampling all 7 samples. But I need to use both the ADCs 0 and 1 for sampling. These are the connections I need to sample:

    1. ADC0 samples PE1 and PE3

    2. ADC1 samples PE2 and PE4.

    How to configure the ADCs to sample in the above configuration ? Moreover, in one cycle I need to sample once from PE3 and PE4 and 128 times from PE1 and PE2. How can I accomplish this ?

  • there is one thing that seems to be incorrect. we are using sequencer 0 but in this program we are disabling sequencer 1 in the line:

    ADCSequenceDisable(ADC0_BASE, 1); //Before Configuring ADC Sequencer 1, it should be OFF

    and i have one doubt, apart from turning on the peripheral clock don't we need to assign ports to the 8 ADC values. if 4 are the default ones on PE0 to PE3 . what about the other 4 . and why last 4 steps sample only the temperature sensor. does that mean i am only left with 4 analog values?

    it would be of much help if someone could help...

     

  • Hello Awais,

    Looking at the code, the disable of the ADCSequencer seems to be a typo. In the example the user wants to sample 4 analog channels followed by 4 readings of the internal temperature sensor. However you can change it to samples other analog channels after configuring them as Analog Pads

    Regards

    Amit

  • i had implemented the example in a bit different way . my code is working but  when i tested the pins, sourcing the pins  PE0,PE1,PE2,PE3 didn't make any difference in the reading which i am receiving on a uart terminal.the data i get is almost always 

    2025,0380,0265,0257,0258,0,0,0,0,0#

    or


    0380,0268,0256,0260,0258,0,0,0,0,0#

    where PE0 sometimes changes to 2025 . and the last 4 digit value is the temperature sensor which dosnt change much .

    part of my code for configuring and calling the function is as follows 

    //*****************************************************************************
    //
    // ADC0 Configuration
    //
    //*****************************************************************************
    
    void ADC0Config (void)
    {
    	SysCtlADCSpeedSet(SYSCTL_ADCSPEED_250KSPS); //ADC Sample Rate set to 250 Kilo Samples Per Second
    
    
    	ADCHardwareOversampleConfigure(ADC0_BASE, 64); // Hardware averaging. ( 2, 4, 8 , 16, 32, 64 )
    	//64 Samples are averaged here i.e, each sample will be a result of 64 averaged samples. Therefore, every result is a result of 64 x 4 = 256 samples.
    
    	ADCSequenceDisable(ADC0_BASE, 0); //Before Configuring ADC Sequencer 0, it should be OFF
    
    	ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_PROCESSOR, 0);
    	//ADC Configured so that Processor Triggers the sequence and we want to use highest priority. ADC Sequencer 0 is Used.
    
    	ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ADC_CTL_CH0); //Sequencer Step 0: Samples Channel PE3
    	ADCSequenceStepConfigure(ADC0_BASE, 0, 1, ADC_CTL_CH1); //Sequencer Step 1: Samples Channel PE2
    	ADCSequenceStepConfigure(ADC0_BASE, 0, 2, ADC_CTL_CH2); //Sequencer Step 2: Samples Channel PE1
    	ADCSequenceStepConfigure(ADC0_BASE, 0, 3, ADC_CTL_CH3); //Sequencer Step 3: Samples Channel PE0
    
    	ADCSequenceStepConfigure(ADC0_BASE, 0, 4, ADC_CTL_TS); //Sequencer Step 4: Samples Temperature Sensor
    	ADCSequenceStepConfigure(ADC0_BASE, 0, 5, ADC_CTL_TS); //Sequencer Step 5: Samples Temperature Sensor
    	ADCSequenceStepConfigure(ADC0_BASE, 0, 6, ADC_CTL_TS); //Sequencer Step 6: Samples Temperature Sensor
    	ADCSequenceStepConfigure(ADC0_BASE, 0, 7, ADC_CTL_TS | ADC_CTL_IE | ADC_CTL_END);
    	//Final Sequencer Step also Samples and enables Interrupt and we are telling the sequencer that this is the last step
    
    	//Configuring all eight steps in the ADC Sequence
    
    	ADCSequenceEnable(ADC0_BASE, 0); //Enable ADC Sequence
    }
    
    //*****************************************************************************
    //
    // ADC Data Retrieval
    //
    //*****************************************************************************
    
    void ADC0DataGet(void)
    {
    	ADCIntClear(ADC0_BASE, 0); // Clear ADC Interrupt
    	ADCProcessorTrigger(ADC0_BASE, 0); // Trigger ADC Interrupt
    
    	while(!ADCIntStatus(ADC0_BASE, 0, false)) //Wait for interrupt Status flag to go off
    	{
    	}
    
    	//Conversion Complete
    
    	ADCSequenceDataGet(ADC0_BASE, 0, ulADC0Value); //Grab the Entire FIFO
    
    
    }
    
    //*****************************************************************************
    //
    // ADC Data storing
    //
    //*****************************************************************************
    
    void ADC0DataStore(void)
    {
    
    
    	ulTempAvg = (ulADC0Value[4] + ulADC0Value[5] + ulADC0Value[6] + ulADC0Value[7] + 2)/4;
    
    	x[3] = ulADC0Value[0]%10 + 48;
    	ulADC0Value[0] = ulADC0Value[0]/10 ;
    	x[2] = ulADC0Value[0]%10 + 48;
    	ulADC0Value[0] = ulADC0Value[0]/10 ;
    	x[1] = ulADC0Value[0]%10 + 48;
    	x[0] = ulADC0Value[0]/10 + 48;
    
    	y[3] = ulADC0Value[1]%10 + 48;
    	ulADC0Value[1] = ulADC0Value[1]/10 ;
    	y[2] = ulADC0Value[1]%10 + 48;
    	ulADC0Value[1] = ulADC0Value[1]/10 ;
    	y[1] = ulADC0Value[1]%10 + 48;
    	y[0] = ulADC0Value[1]/10 + 48;
    
    	z[3] = ulADC0Value[2]%10 + 48;
    	ulADC0Value[2] = ulADC0Value[2]/10 ;
    	z[2] = ulADC0Value[2]%10 + 48;
    	ulADC0Value[2] = ulADC0Value[2]/10 ;
    	z[1] = ulADC0Value[2]%10 + 48;
    	z[0] = ulADC0Value[2]/10 + 48;
    
    	w[3] = ulADC0Value[3]%10 + 48;
    	ulADC0Value[3] = ulADC0Value[3]/10 ;
    	w[2] = ulADC0Value[3]%10 + 48;
    	ulADC0Value[3] = ulADC0Value[3]/10 ;
    	w[1] = ulADC0Value[3]%10 + 48;
    	w[0] = ulADC0Value[3]/10 + 48;
    
    	//temperature sensor avg data
    	a[3] = ulTempAvg%10 + 48;
    	ulTempAvg = ulTempAvg/10 ;
    	a[2] = ulTempAvg%10 + 48;
    	ulTempAvg = ulTempAvg/10 ;
    	a[1] = ulTempAvg%10 + 48;
    	a[0] = ulTempAvg/10 + 48;
    
    	
    }
    //*****************************************************************************
    //
    // Sending Data on UART1 using the protocol $A0,A1...A4,D0,D1...D4#
    //
    //*****************************************************************************
    
    void Uart1DataSend(void)
    {
    	SysCtlDelay(SysCtlClockGet() / (1000 * 2)); //2 cycle delay
    
    	UARTCharPutNonBlocking(UART1_BASE, '$');
    	UARTCharPutNonBlocking(UART1_BASE, x[0]); // Put Character in UART Transmit Buffer
    	UARTCharPutNonBlocking(UART1_BASE, x[1]);
    	UARTCharPutNonBlocking(UART1_BASE, x[2]);
    	UARTCharPutNonBlocking(UART1_BASE, x[3]);
    
    	UARTCharPutNonBlocking(UART1_BASE, ',');
    
    	SysCtlDelay(SysCtlClockGet() / (1000 * 2));
    
    	UARTCharPutNonBlocking(UART1_BASE, y[0]);
    	UARTCharPutNonBlocking(UART1_BASE, y[1]);
    	UARTCharPutNonBlocking(UART1_BASE, y[2]);
    	UARTCharPutNonBlocking(UART1_BASE, y[3]);
    
    	UARTCharPutNonBlocking(UART1_BASE, ',');
    
    	SysCtlDelay(SysCtlClockGet() / (1000 * 2));
    
    	UARTCharPutNonBlocking(UART1_BASE, z[0]);
    	UARTCharPutNonBlocking(UART1_BASE, z[1]);
    	UARTCharPutNonBlocking(UART1_BASE, z[2]);
    	UARTCharPutNonBlocking(UART1_BASE, z[3]);
    
    	UARTCharPutNonBlocking(UART1_BASE, ',');
    
    	SysCtlDelay(SysCtlClockGet() / (1000 * 2));
    
    	UARTCharPutNonBlocking(UART1_BASE, w[0]);
    	UARTCharPutNonBlocking(UART1_BASE, w[1]);
    	UARTCharPutNonBlocking(UART1_BASE, w[2]);
    	UARTCharPutNonBlocking(UART1_BASE, w[3]);
    
    	UARTCharPutNonBlocking(UART1_BASE, ',');
    
    	SysCtlDelay(SysCtlClockGet() / (1000 * 2));
    
    	UARTCharPutNonBlocking(UART1_BASE, a[0]);
    	UARTCharPutNonBlocking(UART1_BASE, a[1]);
    	UARTCharPutNonBlocking(UART1_BASE, a[2]);
    	UARTCharPutNonBlocking(UART1_BASE, a[3]);
    
    	UARTCharPutNonBlocking(UART1_BASE, ',');
    
    	
    	SysCtlDelay(SysCtlClockGet() / (1000 * 2));
    
    	//Digtal values
    		//DIGI0
    		UARTCharPutNonBlocking(UART1_BASE, CDig0);
    		SysCtlDelay(SysCtlClockGet() / (1000 * 2)); //2 cycle delay
    		UARTCharPutNonBlocking(UART1_BASE, ',');
    		SysCtlDelay(SysCtlClockGet() / (1000 * 2)); //2 cycle delay
    		//DIGI1
    		UARTCharPutNonBlocking(UART1_BASE, CDig1);
    		SysCtlDelay(SysCtlClockGet() / (1000 * 2)); //2 cycle delay
    		UARTCharPutNonBlocking(UART1_BASE, ',');
    		SysCtlDelay(SysCtlClockGet() / (1000 * 2)); //2 cycle delay
    		//DIGI2
    		UARTCharPutNonBlocking(UART1_BASE,CDig2);
    		SysCtlDelay(SysCtlClockGet() / (1000 * 2)); //2 cycle delay
    		UARTCharPutNonBlocking(UART1_BASE, ',');
    		SysCtlDelay(SysCtlClockGet() / (1000 * 2)); //2 cycle delay
    		//DIGI3
    		UARTCharPutNonBlocking(UART1_BASE,CDig3);
    		SysCtlDelay(SysCtlClockGet() / (1000 * 2)); //2 cycle delay
    		UARTCharPutNonBlocking(UART1_BASE, ',');
    		SysCtlDelay(SysCtlClockGet() / (1000 * 2)); //2 cycle delay
    		//DIGI4
    		UARTCharPutNonBlocking(UART1_BASE,CDig4);
    		SysCtlDelay(SysCtlClockGet() / (1000 * 2)); //2 cycle delay
    		UARTCharPutNonBlocking(UART1_BASE, '#');
    		UARTCharPutNonBlocking(UART1_BASE, '\r');
    		UARTCharPutNonBlocking(UART1_BASE, '\n');
    		//End sequence
    }
    

    and part in the main

    void main(void) {
    
    	// configure system clock to run at 50 MHz
    	// use external crystal (16 MHz) and PLL
    	SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
    
    	//for UART0 and UART1 starting sequence
    	char StrUART0[20]="UART0 Terminal\n\r";
    	char StrUART1[20]="UART1 XbeeTerminal\n\r";
    	char Str1UART1[4]="~\n\r";
    
    
    
    	//Initializing peripherals
    	PortFunctionInit();
    
    
    	// Enable lazy stacking for interrupt handlers. This allows floating-point
    	// instructions to be used within interrupt handlers, but at the expense of
    	// extra stack usage.
    	//
    	FPUEnable();
    	FPULazyStackingEnable();
    
    	//Uart0 and Uart1 configuration function
    	UartsConfig ();
    
    	ADC0Config();// ADC0 configuration function call
    
    	IntMasterEnable();
    
    
    	SysCtlDelay(SysCtlClockGet() / (1000 * 2)); //2 cycle delay
    
    	if(!UARTBusy(UART1_BASE))
    	{
    
    		UARTSend1(Str1UART1, 21);
    		SysCtlDelay(SysCtlClockGet() / (1000 * 2)); //2 cycle delay
    		UARTSend1(StrUART1, 21);
    		SysCtlDelay(SysCtlClockGet() / (1000 * 2)); //2 cycle delay
    	}
    	if(!UARTBusy(UART0_BASE))
    	{
    
    
    
    		UARTSend0(StrUART0,20);
    
    		//turn light off
    		GPIOPinWrite(GPIO_PORTF_BASE, LED_RED|LED_BLUE|LED_GREEN, light);
    
    
    	}
    
    
    
    	while (1)
    	{
    		ADC0DataGet(); //Getting the data from the sequencer
    
    
    
    		ADC0DataStore();//storing each char in Char array of 4digits
    
    
    //Digital pin input status PE 0,4,3,2 and PF button2
    		DigiPins();
    
    		Uart1DataSend();
    
    		Togglebutton();
    
    
    
    
    
    
    		//			SysCtlDelay(SysCtlClockGet() / 12);
    
    	}
    
    
    
    
    
    
    }

    is there any visible error in the configuration

  • Hi,

    Yes, there are several problems with your code:

    a) Please follow the examples provided by TI and do not change the configuration order - enabling FPULazyStacking should be done before clock configuration, not after, or even worse, inside an interrupt (seen recently on this forum). 

    b) On first page of this forum there are some sticky threads with/for special problems - seems you (and other posters in this thread) have ignored that - see specially this: http://e2e.ti.com/support/microcontrollers/tiva_arm/f/908/t/293858.aspx

    c) for temperature conversion see the user manual - it is normal to have "0" for that? I think not, the user manual has a formula to convert to degree.

    d) when we have many characters to send to UART, it is better to use a repetitive loop to send them, not sending one by one.

    e) I did not checked your conversion from binary to the ASCII equivalent - could be some errors there. 

    Petrei

  • ok thank you very much .. i would try those changes. quite valuable suggestions .

  • after fixing few things my code is working fine and giving the ADC values and the digital values. but there is one small problem now which i cant figure out. at the UART terminal where i am monitoring the ADC values . the ADC values occasionally shift from one pin to the next one. e.g if i am using PE0.PE1..... the values i have noticed went from PE0 to PE1 occasionally. do i need to put some ARef in the hardware or am i missing something else in the hardware. P.s the digital values work fine.

  • Hi,

    How big are differences in PE0 and PE1? if relatively near each other, then the noise/cabling problems could be the cause. If doing your own board, of coarse you need to use a voltage reference.

    Try also to change the order of conversion - move two of the temperature conversions on position actually occupied by PE0 and PE1 and see if the problem moved to other channels.

    Petrei