• 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 » ek-lm3s811 interrupt problem
Share
Stellaris® ARM® Microcontrollers
  • Forum
Options
  • Subscribe via RSS

Forums

ek-lm3s811 interrupt problem

This question is answered
Mehmet Akif MEYDANCI
Posted by Mehmet Akif MEYDANCI
on Aug 15 2012 09:50 AM
Prodigy30 points
ints.rar

Hi,

I have started to use ek-lm3s811 recently. I use Keil v4.54.

All sample projects run correctly.But my codes didn't run on board properly. I didn't get any error or warning message. I checked Flash Tool Configurations many times.

I used sample code to be sure that my prob. is not about codes.

I copied interrupts.c file from StellarisWare\boards\ek-lm3s811\interrupts.c.

Then i created a new uvision project. I am sure ,i added the correct lib file to project and chose correct configuration from Flash Tool Configuration tab.I didn't get any error or warning message.

I downloaded this code to flash memory.My display is just  ;

////////////////////////

Equal Priority

Act:      Pend:

////////////////////////

When i download sample code to flash memory everything is ok.program is running.But my codes are waste. It seems like there is so simple solution but i cant see it. Thanks for your help.

p.s.=i added my project files.i am pleased ,if you can view my project files.

 

Report Abuse
  • Reply
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
All Replies
  • Stellaris Jordan
    Posted by Stellaris Jordan
    on Aug 16 2012 10:58 AM
    Intellectual830 points

    Hey Mehmet,

    Sorry to hear you're having trouble getting your code to load properly.  Have you taken a look at our Keil Quickstart guide?  It should have been on the CD that came with your evaluation kit, but you can also find it at http://www.ti.com/lit/ml/spmu055c/spmu055c.pdf

    I would especially recommend looking over Step 7 (which begins on page 8), which explains in great detail how to start a project from scratch, properly configure Keil to  build it for the part you want, and load the compiled code onto your chip.

    If you have already followed all of these steps, let me know and we can dig a bit deeper into your project to figure out what your issue is.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Dave Robinson
    Posted by Dave Robinson
    on Aug 16 2012 18:02 PM
    Verified Answer
    Verified by Mehmet Akif MEYDANCI
    Genius5490 points

    A glance at your code shows some of the problems... You don't have a clue how to use interrupts -- neither do I -- not really. It's not well explained...

    Look at the Startup_xx.X file -- Not sure what name you use... with Keil.

    Here are some excerpts one of my programs that works...

    Find this section in the startup file you use... NOTE the extern word -- all routines are void and void -- in effect Procedures as opposed to functions. You can add the word interupt as I did it just makes sure that the calling convention is correct in the 5.01 compiler as far as I know.

    This is my code -- not yours. The fix should be obvious though!

    //*****************************************************************************
    //
    // External declaration for the reset handler that is to be called when the
    // processor is started
    //
    //*****************************************************************************
    extern void _c_int00(void);
    extern interrupt void Timer0IntHandler(void); // see below where this can be hooked in for e.g.
    extern interrupt void ADCIntHandler(void);

    ... Then in the interrupt table...

    I put in this...

        IntDefaultHandler,                      // Quadrature Encoder 0
        ADCIntHandler,                          // ADC Sequence 0
        ADCIntHandler,                            // ADC Sequence 1
        ADCIntHandler,                          // ADC Sequence 2
        ADCIntHandler,                            // ADC Sequence 3
        IntDefaultHandler,                      // Watchdog timer
        Timer0IntHandler,                         // Timer 0 subtimer A Timer0IntHandler

    ... You have to find the right spot.

    The declarations in your code look right -- like mine -- see here... (Just the declarations -- not the code)

    interrupt void Timer0IntHandler(void);

    interrupt void ADCIntHandler(void);

    And my next one...

    What you need to do is put the proper declarations in this section:

        IntDefaultHandler,                      // The SysTick handler
        IntDefaultHandler,                      // GPIO Port A
        IntDefaultHandler,                      // GPIO Port B
        IntDefaultHandler,                      // GPIO Port C
        IntDefaultHandler,                      // GPIO Port D
        IntDefaultHandler,                      // GPIO Port E

    Point at the interrupt handler:

    Which you declared in your main program.

    Hope that helps.

    I will try to publish a full working example for the ADC On the EK-LM3S811 -- using interrupts -- in the next few days. It is not clear at all. I do have it working and there are several things you must "reverse engineer".

    Dave Robinson

    EK-LM3S811
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Mehmet Akif MEYDANCI
    Posted by Mehmet Akif MEYDANCI
    on Aug 16 2012 23:01 PM
    Prodigy30 points

         @Jordan,Thank you for your attention and quick answer. I read Keil Quickstart Guide to check all steps. Quickstart Guides(Keil,Code Composer etc.) are useful to open/view/run sample projects,but they are not useful to create a new projects because informations are for old versions (f.e. uvision 3),i think. 

          Dave has found what my issue is.It is "Startup.s" file.When i create a new project ,keil asks me for adding startup code and i say yes.But that startup code doesn't contain necessary interrupt codes. I actually don't know anything about startup code.I supposed that keil adds that file automatically and it's always same. Would you please explain me about startup code or give a link to learn?

          @Dave , Thank you very much for your help. As you said,the problem was "startup.s" file. i looked at existing projects which works on my board.They has specific startup files.I supposed they are general.I will search about startup codes. I am waiting for your new sample codes about this topic, too.Please let me know.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Stellaris Jordan
    Posted by Stellaris Jordan
    on Aug 16 2012 23:36 PM
    Verified Answer
    Verified by Mehmet Akif MEYDANCI
    Intellectual830 points

    Mehmet,

    My apologies; I normally use Code Composer Studio for all my projects, so I hadn't noticed that the Quickstart Guide I linked to you was out of date.  It should still be useful in determining what compiler options and preprocessor definitions are necessary to get Keil to build for the part you want.

    As for the Startup.s file, I understand your confusion, as this is something of a complicated topic (especially if you don't have much experience working with microcontrollers and are coming from a pure C, object oriented background).  The top few lines of code in a typical startup_rvmdk.S file are not too pertinent for what you're doing.  They are used to set up memory alignments and sizes... honestly, I only tend to have to muddle with that if I'm doing something like setting up a chip to contain two partitions of memory for separate projects (ex: when using the bottom page of flash to store a bootloader, and the remaining upper pages to store a large application).

    The first big pertinent chunk of code will be following a comment along the lines of

    ;******************************************************************************
    ;
    ; The vector table.
    ;
    ;******************************************************************************
    EXPORT __Vectors
    __Vectors

    This notes that the startup file is beginning to define the vector table.  This vector table is used to tell the processor where to go to execute code.  For example, the second line tells the CPU that when a reset condition occurs, the code should jump to the memory location defined by the label Reset_Handler.  If you scroll down a bit to where Reset_Handler is defined, you can see that it causes the CPU to jump into the main entry point of the program that has been stored in flash (basically.  The full explanation for this is more complicated than I can muster at this time of night).  This is what causes the CPU to jump back to line 1 of your main function when you press the reset button on an evaluation kit while code is already running.

    You normally don't need to muck with the first 15 or so entries in the vector table, as these define things like the reset handler, the fault handler, and the non-maskable interrupt handler; all of these are interesting, but are rarely changed in a typical microcontroller application.  The interesting stuff is when you start seeing things like

    DCD IntDefaultHandler ; The SysTick handler
    DCD IntDefaultHandler ; GPIO Port A
    DCD IntDefaultHandler ; GPIO Port B
    DCD IntDefaultHandler ; GPIO Port C
    DCD IntDefaultHandler ; GPIO Port D
    DCD IntDefaultHandler ; GPIO Port E

    These are defining vectors for various peripheral interrupts.  For example, the above states that when the hardware on your microcontroller hits an interrupt for GPIO Port A that has not been masked away, it will refer to this vector table, look at the entry corresponding to GPIO Port A, and jump to whatever memory location is stored in the vector table at that location.  By default, that memory location is the default interrupt handler, which we call IntDefaultHandler.  If you instead wanted to jump to a function named InterrupFoo, you would change the second line I pasted to instead read

    DCD InterruptFoo; GPIO Port A

    Now, when the processor signals that it needs to service the GPIO Port A interrupt, it will jump to whatever function corresponds to the label InterruptFoo.  But how does it figure out the value for that label?  The easiest way to do this, as Dave showed, is to have externally defined functions declared in your startup code.  This means that before the vector table is declared, you would want to have a line of code stating

    EXTERN  InterruptFoo

    The extern keyword here will inform our compiler that there exists a label named InterruptFoo somewhere in our name space, and that that label will be available by the time our entire project is compiled and linked.  To make this true, we would need to add a function definition for the InterruptFoo function somewhere in our code, which would be all the code necessary to handle that interrupt.

    Hopefully all of this will help you to understand exactly how interrupts work on Stellaris Microcontrollers, and how to add interrupt handlers to your code.  If you look over the startup file included with the Interrupts example, you should be able to see where they have changed the interrupt vectors for gpioa, b, and c.  If you then look at interrupts.c, you'll be able to see where those interrupt handlers are defined.

    I hope this helps your  understanding!

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Mehmet Akif MEYDANCI
    Posted by Mehmet Akif MEYDANCI
    on Aug 17 2012 18:59 PM
    Prodigy30 points

    Thank you very much for your attention and help. This explanation will be very useful for me to create new projects.My first aim is able to use UART,I2C,SPI .So this explanation meets my requirements completely. 

    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