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.

Multiple ADC on Tiva C

How can i read multiple ADC value on EK-TM4C123G????

Here is my single ADC code :

#include "../tm4c123gh6pm.h"

volatile long adcResult=0;

void GPIO_InIt(void)
{	
	GPIO_PORTF_DEN_R = 0xFF;				// PORTF Digital Enable
	GPIO_PORTF_AFSEL_R = 0x00;				// Disable Alternate Fun. of PORTF
	GPIO_PORTF_DIR_R = 0xFF;	 		        // Make PORTF output
		
	GPIO_PORTE_DIR_R &= ~(1<<1);				// Make PE1 input
	GPIO_PORTE_AFSEL_R = (1<<1);				// Set PE1 as alternate fun.
	GPIO_PORTE_DEN_R &= ~(1<<1);				// Disable Digital Enable on PE1
	GPIO_PORTE_AMSEL_R = (1<<1);				// Enable Analog functionality on PE1
}

void ADC1_InIt(void)
{	
	ADC1_ACTSS_R &= ~(1<<3);				// Disable Sample Sequencer
	ADC1_EMUX_R = (0xF<<12);			        // Configure Trigger event : continuous mode
	ADC1_SSMUX3_R = 2; 			                // For PE1 -> AIN2 ; SSMUX3=2
	ADC1_SSCTL3_R = (1<<1) | (1<<2);			// Set END bit & Enable Interrupt	
	ADC1_IM_R = (1<<3);					// Set MASK bit ; For SS3 -> MASK3
	ADC1_ACTSS_R |= (1<<3);					// Enable Sample Sequencer
	
	ADC1_ISC_R = (1<<3);					// Clear flag status
	
	NVIC_EN1_R |= (1<<19);					// Enable NVIS interrupt bit for ADC
}

void ADC1Seq3_Handler(void)
{
	adcResult = ADC1_SSFIFO3_R;			
	ADC1_ISC_R = (1<<3);
}

int main(void)
{
	SYSCTL_RCGCGPIO_R = (1<<4) | (1<<5);			// Enable RCC Clock for PORTE & PORTF
	SYSCTL_RCGCADC_R = (1<<1);			        // Enable RCC Clock for ADC1
	
	GPIO_InIt();
	ADC1_InIt();
	
	
	while(1)
	{
		
	}
}

  • Hello Deep,

    Critical data alludes the post. How many channels, rate at which the channels need to be sampled, etc. Please specify

    Regards
    Amit
  • I want to use total 8 channels ; 5 for sensors and 3 for accelerometer.
    SS0 - Sequencer ; 8 number of samples
  • Indeed - critical (always necessary) data eludes his post.  Strange that - is it not?

    KISS tossed far out the window/under the bus - poster's over-arching goal - I'd say.

    Would not mastery of 2 or 3 ADC channel conversions - illustrated w/great detail - prove a better learning framework?  Too many "balls in the air" (predictably) will confuse, derail learning.  (just ask any aspiring circus juggler - few start w/8 "flaming daggers" airborne...at least those who (still) have hands...)

    May I predict that harvesting all 8 channels of multiple source - ADC channel data correctly - is unlikely to happen?  (anytime soon)

    Instead - would not poster's creation of, "pot-driven" ADC test board - monitored by a DVM - better enable his understanding & mastery of (at least) the ADC side - this complex project?   (Ans: mais certainement)

    KISS, baby steps - incremental approach to a complex goal - or "kitchen-sink" (I saw that done on youtube) "all at once" approach!  (rarely does one "start" flying by attempting a carrier landing while in a fighter jet...)  Rules, regulations - "guidance" prevents such - long (too long) absent here...

  • Hello Deep,

    Again what is the rate of sampling, is it a fixed rate or can change?

    Regards
    Amit
  • @ Amit,
    May I quote one of our young (female) programming interns? (after she scanned this thread)
    Adding an updated schedule - to the Titanic's orchestra/dance hall - is unlikely to help it avoid the rapidly approaching iceberg! (visible on the horizon)
  • @CB1, Amit, appropriate rate of dancing clock scanning approaching rate of danger but not the solution to avoid collision... No more appropriate prophetic to next answer... After some still unknown fixed rate clock tick.... Again C2E cannot work and Iceberg kill all us on boat.

  • @Roberto,

    Rather clear that "PC" far trumps "reality" - requests by beginner's for design of Hydrogen Fuel Cell - or Perpetual Motion - appear (also) "Fair Game."

    Predictable result - rather than making the time/effort for a more detailed - comprehensively explained - "real" ADC App Note - we have (instead) a succession of wildly wandering, undisciplined posts - without any (effective) commonality and well thought presentation.  The result, "I wanna, Urgent, & Does not Work!"

    Horror is that with LESS Time & Effort - a vastly improved set of Peripheral App Notes could be created - which would benefit the entire community.  In contrast - we have this disorganized "rumble" as 5-6 back-forth exchanges are required - just to "tease out" poster's intent.  

    This registers so clearly - rings very much of, "Ten thousand band-aids" - when the elimination of the "sharp, protruding nail" - provides a far better solution. 

    Simple fact that SO MANY - near identical posts land - (most inadequately described by posters) verifies the "lack of effectively detailed App Notes" - which forces posters to (endlessly/exhaustingly) steer their requests here...  Pity...

  • Hello Deep,

    If that is the case then
    1. Configure a timer to trigger the ADC at the "fixed" rate.
    2. Configure ADC SS0 which has 8 channels for each of the channel
    3. Enable the ADC SS0 interrupt and in the interrupt handler read the data. Do map the interrupt handler in the startup_ccs.c file
    4. Enable the timer

    Now if you are expecting a code, then I would suggest looking at the examples for timer and adc in TivaWare/examples/peripherals, doing some code building....

    Regards
    Amit