Jump to content

How to use interrupts in Energia?

Recommended Posts

I want to use ADC and Timer interrupts in Energia. For this i have to modify ISR Table.

Energia has ISR table in Startup_gcc.c file.


So how to modify this file to access interrupts of ADC and Timers.


Or is there any Library to access Interrupts directly. 


Board:- TIVA C (TM4C123G)


Link to post
Share on other sites

You will probably need to go below the level of Energia to use Timer Interrupts.

(Or find a timer library.  I was working on one, but haven't done much with it in a while.)


Look at the Tivaware/Stellarisware library documentation on timer interrupts (or ADC).


If you want an example that uses them in creating an Energia library, can look at this LED driver library I adapted to Tiva


  MAP_SysCtlPeripheralEnable( TIMER_SYSCTL );

  MAP_TimerConfigure( TIMER_BASE, TIMER_CFG );

  IntRegister( TIMER_INT, TmrHandler );

  MAP_IntEnable( TIMER_INT );

  MAP_TimerLoadSet( TIMER_BASE, TIMER_AB, rowtime );

  MAP_TimerEnable( TIMER_BASE, TIMER_AB );


void TmrHandler(void)

// MAP_ version of library call takes longer
//  HWREG(TIMER_BASE + TIMER_O_ICR) = TIMER_TIMEOUT;    // Inlining timer library code - just in ISR, where speed helpful


In my case timing was critical in the Timer ISR, so I wound up inlining the timer interrupt clear code (commented out above).

For most uses calling the TimerIntClear library would be better.


Using IntRegister means I do not have to modify Startup_gcc.c - which makes the library more portable/easier for others to use.

(It may also take a little more space, not sure on speed.)  

Since I was making a library for general use, the portability was much more important.  Of course your application may be different.


A neater way to handle this (best of both worlds) would be to use Weak default interrupt handlers in Startup_gcc.c

(as is done for the UARTIntHandlers in Energia's Startup_gcc.c)


Then you could substitute your own handler just by declaring it to have a certain name, and it would override the built in (weak) handler.

(If the built in Startup_gcc.c had such weak definitions, then further editing of Startup_gcc would not be necessary.)


If you want more examples of weak - I proposed a fix for some initialization issue in Energia using this feature over on 43oh.

Startup files for some other ARM processors libraries use weak (sorry I don't remember which ones, but I ran into them while working on the code for eLua.)

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...