delay_ms & 90s2313

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

i'm writing a basic hardware test program which just flashes some LED's


#include "verkeerslicht.h"

int main()
{
//initialise hardware
//port D output
DDRB = 0xFF;
PORTB = 0x00;
while (1)
{
	PORTB = 193;
_delay_ms(1);
	PORTB = 66;
	PORTB = 68;
	PORTB = 28;
	PORTB = 36;
	PORTB = 68;
}


}

this however, compiles to:
Program: 3584 bytes (175.0% Full)
on a 90s2313 !?
if i leave out the delay i only consume 6.3%

What do i need to change in order to be able to use the _delay_ms routine?

i'm using Winavr20060125 and AVRstudio (latest version & sp)
F = 8000000

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

What optimisation level are you using? The _delay_ms routine uses floating point calculations, which are optimised to integer constants on the higher optimisation levels (small code usage) but are left alone (huge usage for float routines) on lower opimisations. Using -Os is your best bet.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

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

i had no optimalisation selected :oops: , with -Os selected --> 8%

thanks