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.

Analog read is not working

Part Number: TM4C1294NCPDT

Tool/software: Code Composer Studio

I'm new to CCS and have tried to follow the Initialization and Configuration steps in the data sheet but I am not getting the expected results, I eventually want to use an interrupt but thought this would be easier.  

Or if anyone can point me to examples online using the TM4C1294 that would be great but most are either not using this IC or CCS.

Any assistance/direction is greatly appreciated!

Bill




/******************** ADC Test 1 ********************/ #include "tm4c1294ncpdt.h" void Initialize_BASIC(void){ SYSCTL_RCGCGPIO_R = 0x1030U; //Enable ports GPIO-E, GPIO-F and GPIO-N } void Initialize_DIGITAL(void){ /****** Set up Port F - DIGITAL OUTPUT *******************/ // Step 1 - Enable ports F GPIO_PORTF_DIR_R = 0x0FU; // Step 2 - Sets up Port F with pin 0, 1, 2 & 3 as outputs GPIO_PORTF_AFSEL_R = 0x00U; // Step 3 - Are alternate pins used? - Not now GPIO_PORTF_PC_R = 0x00U; // Step 4 - Extended Drive Mode - current drive of Digital I/O GPIO_PORTF_DR2R_R = 0x0EU; // Steps 5-7 - The output pin will be driven with 2mA GPIO_PORTF_CR_R = 0xFFU; // Step 8 - GPIOPUR, GPIOPDR and GPIOODR registers can be written to if 0xFF //GPIO_PORTF_PUR_R = // Step 8 - GPIO Pull up resistor //GPIO_PORTF_PDR_R = // Step 8 - GPIO Pull down resistor //GPIO_PORTF_ODR_R = // Step 8 - GPIO Open Drain GPIO_PORTF_DEN_R = 0xFFU; // Step 9 - Enables the digital functions on Port F //GPIO_PORTF_IEV_R = // Step 10 - GPIO Interrupt Event //GPIO_PORTF_IBE_R = // Step 10 - GPIO Interrupt Both Edges //GPIO_PORTF_IEV_R = // Step 10 - GPIO Interrupt Event rising or falling edge event //GPIO_PORTF_IM_R = // Step 10 - GPIO Interrupt Mask register /****** Set up Port N - DIGITAL OUTPUT *******************/ GPIO_PORTN_DIR_R = 0x03U; // Step 2 - Sets up Port N as an output GPIO_PORTN_AFSEL_R = 0x00U; // Step 3 - Are alternate pins used? - Not now GPIO_PORTN_PC_R = 0x00U; // Step 4 - Extended Drive Mode - current drive of Digital I/O GPIO_PORTN_DR2R_R = 0x04U; // Steps 5-7 - The output pin will be driven with 2mA GPIO_PORTN_CR_R = 0xFFU; // Step 8 - GPIOPUR, GPIOPDR and GPIOODR registers can be written to if 0xFF GPIO_PORTN_DEN_R = 0x03U; // Step 9 - Enables the digital functions on Port N } /*************** ADC Mode*************/ void Initialize_ADC1(void){ /********************* Set up ADC - Module Initialization *******************/ SYSCTL_RCGCADC_R = 0x02; // Step 1 - Enable ADC 1 SYSCTL_RCGCGPIO_R = 0x1030U; // Step 2 - Enable appropriate GPIO modules GPIO_PORTE_DIR_R = 0x00U; GPIO_PORTE_AFSEL_R = 0x02; // Step 3 - Use port E pin 1 for the ADC input GPIO_PORTE_DEN_R = (0x00); // Step 4 - Clears the digital enable bit for analog use on port E all pins GPIO_PORTE_AMSEL_R = (0x0F); // Step 5 - Disable analog isolation for the ADC input pins // Step 6 - Set priorities if required, not needed /********************* Set up ADC - Sequencer Configuration *******************/ ADC1_ACTSS_R &= ~(1<<3); // Step 1 - Disable ADC1 Sample Sequencer3 for programming ADC1_EMUX_R = 0x0F; // Step 2 - Trigger event is set to always for ADC1 Sample Sequencer3 // Step 3 - Set if PWM is used as trigger device ADC1_SSEMUX3_R = 0x00; // Step 4 - Use AIN[15:0] ADC1_SSMUX3_R = 0x02; // Step 4 - Sets MUX3 to be used with PE1 ADC1_SSCTL3_R = 0x02; // Step 5 - // Step 6 - no interrupts are used ADC1_ACTSS_R = (1<<3); // Step 7 - Enable Sample Sequencer 3 } int ADC_Number = 0; int main() { Initialize_BASIC(); Initialize_DIGITAL(); // Function that sets up the Digital Operations Initialize_ADC1(); GPIO_PORTN_DATA_R = 0x03U; while(1){ ADC_Number = ADC1_SSFIFO3_R; if (ADC_Number > 2000) GPIO_PORTN_DATA_R = 0x03U; else GPIO_PORTN_DATA_R = 0x00U; } return 0; }