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)
{
}
}