• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Microcontrollers » Stellaris® ARM® Microcontrollers » Stellaris® ARM® LM3S Microcontrollers Forum » ADC with Sequencer Interrupt
Share
Stellaris® ARM® Microcontrollers
  • Forum
Options
  • Subscribe via RSS
Helpful Stellaris® LM4F Series Links
  • LM4F Series
  • Stellaris PinMux Utility
  • Stellaris® LM4F120 LaunchPad
  • LM4F MCU Applications
  • LM4F MCU Video
  • ARM Cortex-M4F Whitepaper
  • Stellaris MCU Brochure
  • LM4F232 Eval Kit
  • ADC with Sequencer Interrupt

    ADC with Sequencer Interrupt

    This question is not answered
    Abhay Kothari
    Posted by Abhay Kothari
    on Apr 09 2012 23:45 PM
    Intellectual435 points

    Hello,

    Im using the stellaris 8962 eval kit . I want to use the adc with the sequencer 3 interrupts with the code as written below 

    #include "inc/lm3s8962.h"
    #include "inc/hw_memmap.h"
    #include "inc/hw_types.h"
    #include "inc/hw_ints.h"
    #include "driverlib/interrupt.h"
    #include "driverlib/debug.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/adc.h"
    #include "driverlib/gpio.h"

    unsigned long Value = 0;

    void ADC3IntHandler(void) //INTERRUPT HANDLER
    {
    //turn on led
    GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0, 0x01);
    //CLEAR INTERRUPT
    ADCIntClear(ADC0_BASE, 3);
    //READ DATA
    ADCSequenceDataGet(ADC0_BASE, 3, &Value);

    }




    int main (void)
    {

    SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ);

    //GPIO CONFIG
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_0);
    GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0, 0x00);



    /////////ADC CONFIGURATION
    SysCtlADCSpeedSet(SYSCTL_ADCSPEED_250KSPS);

    //Enable clock to the ADC
    SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);

    //DISABLE SEQUENCER
    ADCSequenceDisable(ADC0_BASE, 3);

    // Configure sample sequence 3: TIMER trigger, priority = 0
    ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0);

    //CONFIGURE STEP
    ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_TS| ADC_CTL_IE | ADC_CTL_END);

    //ENABLE INTERRUPTS
    ADCIntEnable(ADC0_BASE,3);

    //ENABLE THE SEQUENCER
    ADCSequenceEnable(ADC0_BASE, 3);

    IntMasterEnable();           //Processor Master Interrupt

    while(1)
    {
    ADCProcessorTrigger (ADC0_BASE,3);
    }

    }//End of Main
    
    
    ,i have modified startup_ccs as the following
    extern void ADC3IntHandler(void);
    and also changed the name of the interrupt  in the list below as
       ADC3IntHandler,                      // ADC Sequence 3
    
    
    But the code doesn't work . . .Should i use ADCInt Register function ,if so do give me an example and illustrate how or tell me what steps am i missing 
    
    
    Regards
    Abhay
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    All Replies
    • Stellaris Mitch
      Posted by Stellaris Mitch
      on Apr 10 2012 11:48 AM
      Intellectual2170 points

      Hello Abhay,

      It looks like you just need to add a IntEnable(INT_ADC0SS3); after your ADCIntEnable() call.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Alan Nilsson
      Posted by Alan Nilsson
      on Apr 10 2012 15:02 PM
      Prodigy190 points

      Abhay Kothari
      unsigned long Value = 0;

      void ADC3IntHandler(void) //INTERRUPT HANDLER
      {
      //turn on led
      GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0, 0x01);
      //CLEAR INTERRUPT
      ADCIntClear(ADC0_BASE, 3);
      //READ DATA
      ADCSequenceDataGet(ADC0_BASE, 3, &Value);

      }

      Be careful here, you'll want to take precautions not to let the compiler optimize 'Value'.  Typically that would be declaring any value used between main code and an interrupt as volatile.  In this case you'll get a compiler warning (gcc anyway) because ADCSequenceDataGet(...) is not prototyped as taking a pointer to a volatile unsigned int.  AFAIK, volatile-ness cannot be cast so you cannot get rid of the warning.  Whether or not the compiler would then feel free to optimize 'Value' inside of ADCSequenceDataGet(...), I am not sure, but I would be wary of it.

      You may consider:

      volatile unsigned long Value;

      void ADC3IntHandler(void)

      {

      ADCIntClear(ADC0_BASE, 3);

      unsigned long temp = 0;

      ADCSequenceDataGet(ADC0_BASE, 3, &temp);

      Value = temp;

      }

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • cb1_mobile
      Posted by cb1_mobile
      on Apr 10 2012 17:11 PM
      Guru21680 points

      Bit of a pile-up this frequency (post) - do agree with TI Mitch about necessity for ADCIntEnable().

      Beyond that: your code (below) seems not to meet normal/customary Stellaris MCU spec (framed in yellow) for ADC Operation:

      SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ);

      With an 8MHz xtal and PLL bypassed - appears that you are in spec violation.  (never a good idea)

      Note that you seek example & illustrations (for action) - yet provide neither for we attempting to assist!   (True poetic justice - n'est pas?)  

      Your, "Code doesn't work" - doesn't work for we remote diagnosticians either...



       

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Abhay Kothari
      Posted by Abhay Kothari
      on Apr 10 2012 23:37 PM
      Intellectual435 points

      Thanks for pointing that out ,but i dont know how to use the PLL,do tell me how to use it . . .when i mean code doesn't work i mean the ADC code 

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Abhay Kothari
      Posted by Abhay Kothari
      on Apr 11 2012 00:11 AM
      Intellectual435 points

      Thanks Mitch,

      That helped :)

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • cb1_mobile
      Posted by cb1_mobile
      on Apr 11 2012 07:29 AM
      Guru21680 points

      Abhay Kothari
      dont know how to use the PLL

      Almost every example w/in StellarisWare illustrates - also you should focus upon SW-DRL-UG8555 (or newer) which provides just the detail you need.

          ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_25MHZ |
                             SYSCTL_OSC_MAIN);

      Note 2nd pararmeter: SYSCTL_USE_PLL - this enables the PLL.  This function divides the 200MHz PLL by 4 - yielding a 50MHz MCU System Clock.  You require a system clock of 16MHz or greater to comply with TI's ADC spec.

      Final note: "ADC doesn't work" while marginally improving, "doesn't work" - may itself not win many awards for clarity or detail.  Is it off by 2-3 Lsb when converting, occasionally "slip" a conversion, or never converts at all?   (your readers have no clue!)   Can easily list 10 other "doesn't work" - but continue to "argue strongly against" use of such "information-free" phrase.  (quick, uninspired fault descriptions usually will yield poor response...we know that you can do better...)

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    TI E2E™ Community
    • Support Forums
    • Blogs
    • Videos
    • Groups
    • Site Support & Feedback
    • Settings
    TI E2E™ Community Groups
    • TI University Program
    • Make the Switch
    • Microcontroller Projects
    • Motor Drive & Control
    Other Communities
    • Deyisupport
    • Designsomething.org
    • beagleboard.org
    • TI on Element 14
    • TI on TechXchangeSM
    Other Technical & Support Resources
    • WEBENCH® Design Center
    • Product Information Centers
    • Technical Documents
    • TI Design Network
    • TI Technical Articles
    • TI Training

    All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

    Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

    Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
    TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

    TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
    embedded processors, along with software, tools and the industry’s largest sales/support staff.

    © Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
    Trademarks | Privacy Policy | Terms of Use