#include <stdint.h> #include "tm4c1294ncpdt.h" #define ADC0_SSMUX_AIN 0x0067CDEF // AIN6,7,12,13,14,15 /* * main.c */ int main(void) { int dummy; // ADC init SYSCTL_RCGCADC_R |= SYSCTL_RCGCADC_R0; // clock for adc0 dummy = SYSCTL_RCGCGPIO_R3; SYSCTL_RCGCGPIO_R |= SYSCTL_RCGCGPIO_R3; // clock for portD dummy = SYSCTL_RCGCGPIO_R3; GPIO_PORTD_DIR_R &= 0x0; // making it input GPIO_PORTD_AFSEL_R |= 0x3F; // Alternate function enabled for PD_0123456 GPIO_PORTD_DEN_R &= 0x00; // Analog pins GPIO_PORTD_AMSEL_R |= 0x3F; // Analog isolation disabled // SS config ADC0_ACTSS_R &= ~(ADC_ACTSS_ASEN0); // DISABLE SS0 ADC0_EMUX_R |= ADC_EMUX_EM0_ALWAYS; // always trigger ADC0_SSMUX0_R |= ADC0_SSMUX_AIN; // input analog pins ADC0_IM_R &= 0X0; // dont send to interrupt controller ADC0_SSCTL0_R |= (ADC_SSCTL0_END5 | ADC_SSCTL0_IE5);// end bit set for sample 6 and interrupt enabled ADC0_ACTSS_R &= ADC_ACTSS_ASEN0; // ENABLE SS0 // reading the value int adcValues[6]; while(1) { ADC0_PSSI_R = ADC_PSSI_SS0; // initiate sampling while( (ADC0_RIS_R&0x01) == 0) {}; // Wait for conversion done ( When done RIS = 1 ) adcValues[0] = ADC0_SSFIFO0_R&0xFFF; // read result adcValues[1] = ADC0_SSFIFO0_R&0xFFF; adcValues[2] = ADC0_SSFIFO0_R&0xFFF; adcValues[3] = ADC0_SSFIFO0_R&0xFFF; adcValues[4] = ADC0_SSFIFO0_R&0xFFF; adcValues[5] = ADC0_SSFIFO0_R&0xFFF; ADC0_ISC_R = 0x1; // Acknowledge (Clear RIS) } // return 0; }
I'm using TM4C1294 and was trying to configure 6 ADC channels, my code was working the first time I ran it but wasn't reading the values, so I just unmasked the ADCIM bit and after that it has totally stopped working even after reverting back to the previous code. I've tried everything but still no success, can please someone help me find the problem? I've attached the screen shot along with my code.
Thanks for the help and time.
P.S. I just changed this line before it stopped working
ADC0_IM_R &= 0X0;
to
ADC0_IM_R = 0X01;