IAR workbench ATmega16 : part of code optimization issue

Go To Last Post
15 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I want to use medium optimization for rest of code; but there is a function where i dont want any optimization. How can i do it?

This topic has a solution.

AVR Rocks but can be Bricked too smiley

Last Edited: Mon. Oct 26, 2015 - 07:59 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ask IAR.

Normally you set optimisation for the whole project.
You should be able to set different optimisation for individual files by right-click on the fileN.c

Otherwise you can use #pragma optimize

Shirley you can just use Help->Search "optimize"

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:
Shirley you can just use Help->Search "optimize"
Who's that girl? :lol:

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

"Shirly????" dont be dumb. you can just use my name instead of these @&*%^@*&^@% words....

AVR Rocks but can be Bricked too smiley

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OLD:
----
The problem is that when i use
__delay_cycles(F_CPU);
with optimization then i dont get 1 sec delay. i dont want to use timer bcz it is being used for other purpose like capture of event/gating.
so i want to disable optimization for this line.

 is updated to ::
------------------
even if I use optimization  __delay_cycles(F_CPU);
gives exactly what expected.

Problem Solved.
I didnt got 1sec because of my mistake.

AVR Rocks but can be Bricked too smiley

Last Edited: Fri. Jul 27, 2012 - 09:03 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

engineer.pk wrote:
"Shirly????" dont be dumb. you can just use my name instead of these @&*%^@*&^@% words....
:lol::lol::lol::lol::lol::lol::lol:

Shirley is a popular woman's name, nothing bad so far. Seems like some Brits are [ab]using it instead of "surely" :lol:

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

Last Edited: Wed. Jul 25, 2012 - 12:33 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Certain references get lost in the translation. The word 'shirley' sounds similar to 'surely'. It was used in a pigdog western imperialist movie called 'flying high'.

'bcz' that's a new one. Your neighbours like to use 'cuz'. Why can't we just use the word 'because'?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

nice one :)

AVR Rocks but can be Bricked too smiley

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:
Certain references get lost in the translation.
I was not a translation. It was just my Russian guess bekoz ay du not nou Inglish at oll :lol:

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

engineer.pk wrote:
The problem is that when i use
__delay_cycles(F_CPU);
with optimization then i dont get 1 sec delay. i dont want to use timer bcz it is being used for other purpose like capture of event/gating.
so i want to disable optimization for this line.

You should get the correct number of wasted cycles regardless of your optimisation settings.

Simply examine the code in C-SPY. You should be able to count the cycles / time exactly when you Simulate.

Sorry about my mis-spelled "surely". I don't think that you have ever revealed your name.

I think that I answered your question in a helpful way.

If you have a problem, please post the actual code.

David. (my name)

p.s. from IAR Help:

void __delay_cycles(unsigned long count);

So even if you are running an Xmega at 32MHz, you are comfortably within the maximum 4294967296.

Last Edited: Wed. Jul 25, 2012 - 01:09 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

i dont want to use timer bcz it is being used for other purpose like capture of event/gating.

Just because you have a free-running timer used for ICP doesn't mean you cannot have a "tick" at every overflow to use for internal timekeeping.

And apparently your alternative is to just have your AVR sit in one spot for an entire second?!? No servicing of USARTs; no events such as your capture/gating; no display update; no user button servicing.

I'd strongly suggest that you re-visit your program structure. Doesn't Mega16 have three timers?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Are you disabling interrupts ? ( which is actually a bad idea )

The delay function is simple counter loop.

~10% interrupt overhead means ~10% extended delay time.

__delay_cycles() is really meant for SHORT delays of maybe a few microseconds.

go with theusch's method. Overflow tick counter and a wait loop.

Mike Adams
ADI Development, Inc.
http://www.adidev.com

... When it has to actually work.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

MBedder wrote:

Shirley is a popular woman's name, nothing bad so far. Seems like some Brits are [ab]using it instead of "surely" :lol:

Just to clarify, Us brits use the above as a quick one liner as in the following example:

Q) "Surely you can manage that"

A) "Yes but dont call me Shirley"

:P Stephen

Codevisionavr & Avrstudio 4.18
Easyavr5A-Jtagicemk1

Call me Pedantic, But not after 9.

if Milk_Brilliant
else Codevision_Avrs==Better

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Timers are used for other purpose concurrently.
Timer 0 & Timer 2 for Gating & Control.
Timer 1 for capture.

AVR Rocks but can be Bricked too smiley

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

problem solved because i just solved it myself :)

http://www.avrfreaks.net/index.p...

AVR Rocks but can be Bricked too smiley