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.

TM4C123 Launchpad - ADC enable issue

Hi,

Hopefully a really quick one for the gurus.  I am attempting to read the internal temp of my tiva in a much larger project. 

However when I do this:

SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC1);

ADCSequenceConfigure(ADC1_BASE, 0, ADC_TRIGGER_PROCESSOR, 0);

I get an immediate FAULT_ISR.  It doesn't seem to matter which ADC peripheral I use that's what I get.

In fact it faults when I get to this section in ADC.C

HWREG(ui32Base + ADC_O_EMUX) = ((HWREG(ui32Base + ADC_O_EMUX) &
~(0xf << ui32SequenceNum)) |
((ui32Trigger & 0xf) << ui32SequenceNum));

I have tried using the while(!(SysCtlPeripheralReady(SYSCTL_PERIPH_ADC1))); in between the 2 lines of code above but the while loop never exits.

Any thoughts from the much smarter masses??

Thanks

Warwick

  • Hi,

    What sequencer did you enabled to work with your ADC?

    Normally, when configuring ADC, first disable all sequencers, make configurations and then enable the sequencer and the ADC.

  • Hi,

    Not exactly sure what you mean by that statement but here is my full section of ADC code.

    SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC1);
    while(!(SysCtlPeripheralReady(SYSCTL_PERIPH_ADC1)));
    ADCSequenceConfigure(ADC1_BASE, 0, ADC_TRIGGER_PROCESSOR, 0);
    ADCSequenceStepConfigure(ADC1_BASE, 0, 0, ADC_CTL_TS | ADC_CTL_IE | ADC_CTL_END);
    ADCSequenceEnable(ADC1_BASE, 0);
    ADCIntClear(ADC1_BASE, 0);

    However if I leave while(!(SysCtlPeripheralReady(SYSCTL_PERIPH_ADC1))); in the code never drops to the next line.  But if I leave it out I get a Bus Fault on the ADCSequenceConfigure step.  That order of code comes directly out of the Examples in the workshops.  I have no other ADC code in the entire module except where I was attempting to read it which execution never gets to.  I have however got timer modules and ssi modules in use.  Any chance of these conflicting?

    Thanks

    Warwick

  • Hi,

       You are lacking these code lines below. Search this forum for ADC initialization codes.

       SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOX);

       GPIOPinTypeADC(GPIO_PORTX_BASE, GPIO_PIN_X );

    - kel

  • Hi,

    I couldn't find anywhere that it lists the pin and peripheral for the internal temperature. I presumed that the workshops for the Tiva C would have been correct..
  • I will try to help you more after I get home.

    - kel
  • Hi Warwick,

    Why did you use ADC1 when at Lab 5 Workshop uses ADC0? Have you tried the Lab 5 Workshop as is?

    software-dl.ti.com/.../TM4C123G_LaunchPad_Workshop_Workbook.pdf

    - kel
  • Hi Markel,

    I have tried it both ways. That was probably one of my many attempts to get it working in any way that I can. I have however now just added it to the entire lab 5 into a standalone project and it works fine. So it must be something else that I'm already using. I wonder if the Temperature Sensor peripheral shares something else or if there is a particular clock setting that I need. I will do a little more experimentation.
  • Hi Markel,

    So I changed things and ended up putting all of this at the start of my main function.

    I still get a fault between the start of this block and the end:

    InitConsole();
    ArtisanInterface Interface;
    SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL| SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
    //Set ADC up for internal temp.
    SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
    //while(!(SysCtlPeripheralReady(SYSCTL_PERIPH_ADC0)));
    ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_PROCESSOR, 0);
    ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ADC_CTL_TS | ADC_CTL_IE |
    ADC_CTL_END);
    ADCSequenceEnable(ADC0_BASE, 1);
    ADCIntClear(ADC0_BASE, 1);

    Below this comes my while loop for measuring it all.
  • Hold that thought but I think it was the order of some of my setup. Particularly the class on line 2.

    Thanks for your help anyway Markel.
  • Mark this post as "Answered", if you already made your ADC code to work.

    - kel