avr studio4 について
#include <avr/io.h>
#include "adc.h"
#define SENSOR_IR 1
#define SENSOR_PORT PORTC
#define SENSOR_DDR DDRC
#define LED_PORT PORTD
#define LED_DDR DDRD
// 点灯パターン 16x8ドット
unsigned int pat[]={
//123456789ABCDEFG
0b0011010001011100,
0b0101010001010010,
0b1001010001010010,
0b1001001010011100,
0b1111001010010100,
0b1001001010010100,
0b1001000100010010,
0b1001000100010010
};
int main(void)
{
#define DOTMAX (16*3)
#define THRESHOLD 200
#define SHIFTCNT 50
int adc;
int adc_back;
int line;
char iso;
char edge=0;
unsigned int cnt;
unsigned int cnt_mst;
unsigned int bitnum;
int turn;
ad_init(0);
turn=0;
iso=0;
SENSOR_DDR |= (1<<SENSOR_IR);
SENSOR_PORT |= (1<<SENSOR_IR);
LED_DDR |= 0xff;
turn=10000;
while(turn-->0);
cnt = 0;
cnt_mst = 1;
while(1)
{
bitnum = (DOTMAX * cnt) / cnt_mst;
bitnum += iso;
bitnum &= 0xf; // bitnum = bitnum mod 16
for(line=0; line<8; line++){
if((1<<bitnum) & pat[line])
LED_PORT |=(1<<line);
else
LED_PORT &= ~(1<<line);
}
cnt++;
adc_back = adc;
adc = ad_get();
if(edge==0) {
if(adc < (adc_back-THRESHOLD)) {
edge = ~edge;
cnt_mst = cnt-(cnt/(DOTMAX*2));
cnt=0;
turn++;
if(turn >= SHIFTCNT){
turn=0;
iso =(iso-1)& 0xf;
}
}
}else{
if(adc > (adc_back+THRESHOLD)) {
edge = ~edge;
}
}
}
return 0;
}
と入力してビルドしたところ
Build started 5.2.2007 at 02:21:46
avr-gcc -mmcu=atmega168 -Wall -gdwarf-2 -std=gnu99 -DF_CPU=1000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT loopled.o -MF dep/loopled.o.d -c ../loopled.c
../loopled.c: In function 'main':
../loopled.c:87:24: warning: 'adc' may be used uninitialized in this function [-Wmaybe-uninitialized]
avr-gcc -mmcu=atmega168 -Wall -gdwarf-2 -std=gnu99 -DF_CPU=1000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT adc.o -MF dep/adc.o.d -c ../adc.c
avr-gcc -mmcu=atmega168 -Wl,-Map=loopled.map loopled.o adc.o -o loopled.elf
avr-objcopy -O ihex -R .eeprom -R .fuse -R .lock -R .signature loopled.elf loopled.hex
avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings -O ihex loopled.elf loopled.eep || exit 0
avr-objdump -h -S loopled.elf > loopled.lss
AVR Memory Usage
----------------
Device: atmega168
Program: 526 bytes (3.2% Full)
(.text + .data + .bootloader)
Data: 16 bytes (1.6% Full)
(.data + .bss + .noinit)
Build succeeded with 1 Warnings...
とでてきました
どうすればビルドできますか?