Tool/software: Code Composer Studio
Hello Sir,
I have use PE-3 pin for analog pin with 3.3 V input on this port. The analog value should be come 4095 according to 12 bit ADC. But that is not comming in attached file.
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/tm4c123gh6pm.h"
#include "driverlib/sysctl.h"
#include "driverlib/adc.h"
#include "driverlib/gpio.h"
#include "driverlib/uart.h"
#include "driverlib/pin_map.h"
volatile long adcResult=0;
int a,b,c,d,e,f;
void GPIO_InIt(void)
{
GPIO_PORTE_DIR_R &= ~0x10; // Make PE1 input
GPIO_PORTE_AFSEL_R |=0x10; // Set PE as alternate fun.
GPIO_PORTE_DEN_R &=~0x10; // Disable Digital Enable on PE3
GPIO_PORTE_AMSEL_R |=0x10; // Enable Analog functionality on PE3
ADC0_ACTSS_R &=~0x0008; // Disable sample Sequencer 3(SS3)
ADC0_EMUX_R &=~0xF; // Software Trigger Conversion // Configure Trigger event : continuous mode
ADC0_SSMUX3_R |=0; // Get input from channel 0
ADC0_SSCTL3_R |=0x0006; // Take one sample at a time set flat at 1st sample
ADC0_ACTSS_R |=0x0008; // Enable SS3
}
void ADC0Seq3_Handler(void)
{
ADC0_PSSI_R|=0x0008; // Start Conversion at SS3
while((ADC0_RIS_R & 0x08)==0){} // Wait for conversion complete
adcResult = ADC0_SSFIFO3_R & 0xFFF;
ADC0_ISC_R = 0x0008;
}
int main(void)
{
SYSCTL_RCGCGPIO_R |=0x10; // Enable clock for Port E
SYSCTL_RCGCADC_R |=0x01; // Enable Clock for ADC Module 0
GPIO_InIt();
while(1)
{
ADC0Seq3_Handler();
}
}
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/tm4c123gh6pm.h"
#include "driverlib/sysctl.h"
#include "driverlib/adc.h"
#include "driverlib/gpio.h"
#include "driverlib/uart.h"
#include "driverlib/pin_map.h"
volatile long adcResult=0;
int a,b,c,d,e,f;
void GPIO_InIt(void)
{
GPIO_PORTE_DIR_R &= ~0x10; // Make PE1 input
GPIO_PORTE_AFSEL_R |=0x10; // Set PE as alternate fun.
GPIO_PORTE_DEN_R &=~0x10; // Disable Digital Enable on PE3
GPIO_PORTE_AMSEL_R |=0x10; // Enable Analog functionality on PE3
ADC0_ACTSS_R &=~0x0008; // Disable sample Sequencer 3(SS3)
ADC0_EMUX_R &=~0xF; // Software Trigger Conversion // Configure Trigger event : continuous mode
ADC0_SSMUX3_R |=0; // Get input from channel 0
ADC0_SSCTL3_R |=0x0006; // Take one sample at a time set flat at 1st sample
ADC0_ACTSS_R |=0x0008; // Enable SS3
}
void ADC0Seq3_Handler(void)
{
ADC0_PSSI_R|=0x0008; // Start Conversion at SS3
while((ADC0_RIS_R & 0x08)==0){} // Wait for conversion complete
adcResult = ADC0_SSFIFO3_R & 0xFFF;
ADC0_ISC_R = 0x0008;
}
int main(void)
{
SYSCTL_RCGCGPIO_R |=0x10; // Enable clock for Port E
SYSCTL_RCGCADC_R |=0x01; // Enable Clock for ADC Module 0
GPIO_InIt();
while(1)
{
ADC0Seq3_Handler();
}
}