Re: Большой размер прошивки после компиляции
Добавлено: Пт фев 15, 2013 12:27:51
Настраивал прямо в 4-ой студии... и нет никаких граблей...Kavka писал(а): А если нету makefile-а? Здравствуте грабли!?
Здесь можно немножко помяукать :)
https://radiokot.ru/forum/
Настраивал прямо в 4-ой студии... и нет никаких граблей...Kavka писал(а): А если нету makefile-а? Здравствуте грабли!?
Код: Выделить всё
TARGET = tar
F_CPU = 10000000
CSRC = freq.c
MCU_TARGET = atmega8
MCU = atmega8
ASRC =
OPTIMIZE = -Os -mcall-prologues
CC = avr-gcc
DEFS =
LIBS = -lm
DEBUG = dwarf-2
OBJCOPY = avr-objcopy
CFLAGS = -g -mmcu=$(MCU) -Wall -Wstrict-prototypes
#-------------------
all: freq.hex
#-------------------
freq.hex : freq.out
$(OBJCOPY) -R .eeprom -O ihex freq.out freq.hex
freq.out : freq.o
$(CC) $(CFLAGS) -o freq.out -Wl,-Map,freq.map freq.o
freq.o : freq.c
$(CC) $(CFLAGS) -Os -c freq.c
#-------------------
clean:
rm -f *.o *.map *.out
#-------------------
Program: 3592 bytes (43.8% Full)
Data: 270 bytes (26.4% Full)
Код: Выделить всё
bash-4.1$ make all
rm -rf *.o tar.elf *.eps *.bak *.a
rm -rf *.lst *.map
rm -rf tar.hex
avr-gcc -gdwarf-2 -Wall -Os -mcall-prologues -mmcu=atmega8 -c -o main.o main.c
main.c: In function 'SetFreq':
main.c:17: warning: statement with no effect
avr-gcc -gdwarf-2 -Wall -Os -mcall-prologues -mmcu=atmega8 -Wl,-Map,tar.map -o tar.elf main.o -lm
avr-objdump -h -S tar.elf > tar.lst
avr-objcopy -j .text -j .data -O ihex tar.elf tar.hex
avr-size -C --mcu=atmega8 tar.elf
avr-size: invalid option -- 'C'
Usage: avr-size [option(s)] [file(s)]
Displays the sizes of sections inside binary files
If no input file(s) are specified, a.out is assumed
The options are:
-A|-B --format={sysv|berkeley} Select output style (default is berkeley)
-o|-d|-x --radix={8|10|16} Display numbers in octal, decimal or hex
-t --totals Display the total sizes (Berkeley only)
--common Display total size for *COM* syms
--target=<bfdname> Set the binary file format
@<file> Read options from <file>
-h --help Display this information
-v --version Display the program's version
avr-size: supported targets: elf32-avr elf32-little elf32-big srec symbolsrec tekhex binary ihex
make: *** [size] Ошибка 1
Код: Выделить всё
avr-size -C --mcu=atmega8 tar.elfКод: Выделить всё
bash-4.1$ make all
rm -rf *.o tar.elf *.eps *.bak *.a
rm -rf *.lst *.map
rm -rf tar.hex
avr-gcc -gdwarf-2 -Wall -Os -mcall-prologues -mmcu=atmega8 -c -o main.o main.c
avr-gcc -gdwarf-2 -Wall -Os -mcall-prologues -mmcu=atmega8 -Wl,-Map,tar.map -o tar.elf main.o -lm
avr-objdump -h -S tar.elf > tar.lst
avr-objcopy -j .text -j .data -O ihex tar.elf tar.hex
avr-size --mcu=atmega8 tar.elf
avr-size: unrecognized option '--mcu=atmega8'
Usage: avr-size [option(s)] [file(s)]
Displays the sizes of sections inside binary files
If no input file(s) are specified, a.out is assumed
The options are:
-A|-B --format={sysv|berkeley} Select output style (default is berkeley)
-o|-d|-x --radix={8|10|16} Display numbers in octal, decimal or hex
-t --totals Display the total sizes (Berkeley only)
--common Display total size for *COM* syms
--target=<bfdname> Set the binary file format
@<file> Read options from <file>
-h --help Display this information
-v --version Display the program's version
avr-size: supported targets: elf32-avr elf32-little elf32-big srec symbolsrec tekhex binary ihex
make: *** [size] Ошибка 1
Код: Выделить всё
#define F_CPU 10000000UL
#define TIK 0.0000001
#include <stdio.h>
#include <avr/io.h>
int timer0;
int timer1;
int presc;
int SetFreq(char set){
float tik = (float)presc * TIK;
float period = (256.0-(float)timer0)*tik;
float freq = (1.0/period)/2.0;
freq = freq+10.0;
int temp = (int)(256.0-(((1.0/freq)/tik)/2.0));
if(temp>0 && temp<=256){
timer0 = temp;
}
return 1;
}
int main(void){
timer0 = 256-161;
timer1 = 999;
presc = 256;
SetFreq('1');
while(1)
{
//_delay_ms(500);
}
}
Код: Выделить всё
#define F_CPU 10000000UL
#define TIK 0.0000001
#include <stdio.h>
#include <avr/io.h>
#include <avr/interrupt.h>
int timer0;
int timer1;
int presc;
int SetFreq(char set){
float tik = presc * TIK;
float freq = (1/((256-timer0)*tik))/2;
freq = freq+10;
int temp = (int)(256-(((1/freq)/tik)/2));
if(temp>0 && temp<=256){
timer0 = temp;
//printf("%d", temp);
//puts("\r\n");
}
return 1;
}
int main(void){
timer0 = 256-161;
timer1 = 999;
presc = 256;
SetFreq('1');
while(1)
{
//_delay_ms(500);
}
}
Код: Выделить всё
text data bss dec hex filename
1316 0 6 1322 52a tar.elf
http://www.pic24.ru/doku.php/osa/articl ... out_errorsdem66 писал(а): Что еще можно сделать с теми вычислениями, те формулы что писали выше немного не те
int temp = (int)(256-(((1/120)/0.0000257)/2)) = 93.8728923482. Формулу для temp
int temp = (int)(256.0-(((1.0/freq)/tik)/2.0));
можно переписать в виде
temp = 256 - (tik/freq)/2