[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [avr-gcc-list] How to control the optimizer from the C source?
From: |
Bernard Fouché |
Subject: |
RE: [avr-gcc-list] How to control the optimizer from the C source? |
Date: |
Fri, 13 Aug 2004 12:00:59 +0200 |
Perfect, it stands any -O value and it's also okay without '-O' (just in
time however!).
Would be nice however if something would warn the programmer that a time
critical register is touched. But well, we have to justify the monthly pay
check :-)
Thanks!
-----Message d'origine-----
De : address@hidden
[mailto:address@hidden la part de Joerg Wunsch
Envoyé : vendredi 13 août 2004 11:20
À : address@hidden
Objet : Re: [avr-gcc-list] How to control the optimizer from the C
source?
Bernard Fouché <address@hidden> wrote:
> the fun thing is that the optimizer does not spare many 'ldi r24,0x80' but
> change the code to have at the end of the function 'sts 0x0061,r24' once:
it
> delayed the second setting of 0x0061 to the end of the function. The
problem
> is that the clock prescaler register must be touched twice within 4 clock
> ticks. If we look at line 237a (for instance), There is:
How about that?
#include <avr/io.h>
#include <inttypes.h>
void set_clkdiv(int mode)
{
uint8_t clkpr;
switch(mode)
{
case 0:
case 1:
clkpr=0x00;
break;
case 2:
clkpr=0x01;
break;
case 4:
clkpr=0x02;
break;
case 8:
clkpr=0x03;
break;
case 16:
clkpr=0x04;
break;
case 32:
clkpr=0x05;
break;
case 64:
clkpr=0x06;
break;
case 128:
clkpr=0x07;
break;
case 256:
clkpr=0x08;
break;
}
cli();
CLKPR = 0x80;
CLKPR = clkpr;
sei(); //re-enable interrupts
}
--
J"org Wunsch Unix support engineer
address@hidden http://www.interface-systems.de/~j/
_______________________________________________
avr-gcc-list mailing list
address@hidden
http://www.avr1.org/mailman/listinfo/avr-gcc-list