Pages: [1]   Go Down
Author Topic: Implement C "inline" is a must - please enhance  (Read 461 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Inline mechanism is a must for programming microcontrollers and it has been for that particular reason of slower CPUs. While in todays computers it is insignificant performance improver it can make day and night difference in terms of 16MHz microcontroller.

I am trying to keep interrupt short wired with programming with tone output (if you do not know technique as it is a bit more advanced then let me know so I can explain). It seems that as in old good 8051 series (I was commercial-industrial design engineer with those 20 years ago) this works in Arduino based on newer Atmels just the same. However, I need to process several tens microseconds time intervals as fast as possible and not missing another interrupt. In other word,s I can give up on length of the code, but i need some places to execute the same code without of overhead of calling procedure (yes it takes time to make space for local variables on stack and then clean it up when returning). So I would prefer to save few microseconds and while programming inline function (not a macro please!) to maintain only one version I would prefer it to be fully inline expanded in the interrupt code.

It would not be an issue if we were talking about microcontrollers working 100MHz and above if we wonted to use that speed/power to control on the level of microseconds.
Logged

0
Online Online
Shannon Member
****
Karma: 215
Posts: 12489
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm not sure, but I think you are asking for more control on the optimization options passed to avr-gcc?
Logged

[ I won't respond to messages, use the forum please ]

Dallas, TX USA
Offline Offline
Faraday Member
**
Karma: 70
Posts: 2740
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Have no clue what you are talking about.
"inline" on gcc works just fine.
http://gcc.gnu.org/onlinedocs/gcc/Inline.html

--- bill
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 210
Posts: 13030
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

"inline" on gcc works just fine.

And adding the keyword is sometimes not necessary.  Small static functions are automatically inlined.
Logged

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Inline mechanism is a must for programming microcontrollers

It may make more sense if you can provide a practical example of what you are trying to do, then maybe others can help you get it done more efficiently (with or without inline).
Logged

Pages: [1]   Go Up
Jump to: