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.

TM4C123GH6PM: Trying to get ADC working, please help.

Part Number: TM4C123GH6PM

I am trying to sample PE3 for a Sonar sensor, but my code never enters the ISR. I have updated my vector table with the "ADC_read_fxn" handler, but constantly just end up with "No source available for "0xfffffffe"  errors. Any help would be greatly appreciated. 

#include "sonar_init.h"

float distInch;
volatile unsigned int proflag=0;

void sonarInit(void)
{

    //SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
    SysCtlPeripheralReset(SYSCTL_PERIPH_ADC0);
    ADCSequenceDisable(ADC0_BASE,3);

    ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0);

    ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH0 | ADC_CTL_IE | ADC_CTL_END);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
    GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3);
    ADCIntRegister(ADC0_BASE,3, &ADC_read_fxn);
    ADCIntEnable(ADC0_BASE,3);\
    ADCIntClear(ADC0_BASE, 3);
    ADCSequenceEnable(ADC0_BASE,3);

    IntMasterEnable();

}

void main(void)
{
    sonarInit();

    while(1){
        if (proflag==0){
       ADCProcessorTrigger(ADC0_BASE,3);
       proflag=1;
        }
    }
}


void ADC_read_fxn(void)
{
  ADCIntClear(ADC0_BASE,3);
  while(!ADCIntStatus(ADC0_BASE, 3, false));
  uint32_t rawADC;
  ADCSequenceDataGet(ADC0_BASE, 3, &rawADC);
  distInch=rawADC*102.4;
  proflag=0;
}

  • Hi,

    I can see you commented the SysCtlClockSet function - try to enable it first and set a clock frequency equal to 16MHz, or bigger = the ADC needs precisely a clock of 16MHz to operate. (clock block, which includes the PLL, has special dividers to get the ADC to have the needed 16MHz.)

    Also, look at the Tiva examples, before enabling the clock you need to enable the floating point unit, if you need to use floats - I see you use it inside interrupt.

    Look also inside Project Properties (find yourself) - there is a setting that add a breakpoint at main function - so after loading the program into flash and run, it will stop at main. Be sure not to have an fault interrupt.

  • Tyler,
    Ain't you maybe missing the entry below? I'm not sure when it is needed or not, but my code here has it.

    IntEnable(INT_ADC0SS3);

    Regards
    Bruno
  • Thanks, Bruno, you are correct. The IntEnable(INT_ADCSS3) is needed to enable the corresponding interrupt channel at the Processor NVIC level.
  • Even with this enabled I am not able to get this to work...anything else I may be missing?
  • Do you have the DEBUG declared as predefined symbol, compiler options?

    Do you have a target file added to your project and correctly configured?

    Try to import an example project from Tiva, compile/link and verify everything works ok, then look to project properties and compare with yours. 

    What modifications did you do to original posted code? what is system clock frequency set now?

  • I appreciate all the replies here, I am still working on this issue, but another problem popped up and had to be given priority.