답변 : avr 빌드 추가 질문입니다.
페이지 정보
작성자 master 작성일18-12-06 09:10 조회4,872회 댓글1건본문
// MCU BASIC: https://www.basic4mcu.com
// DateTime : 2018-12-06 오전 9:12:58
// by Ok-Hyun Park
//
#define F_CPU 16000000UL
#include <avr/io.h>
#include <util/delay.h>
#include <stdio.h>
#include <avr/interrupt.h>
#include <math.h>
//
#define YES 1
#define NO 0
//
unsigned char door_open=NO;
unsigned int sec=0;
float distance;
//
void IR_ADC(){
float val,sum=0; unsigned int i=0;
for(i=0; i<=10; i++){ val=12343.85*pow(ADC,-1.15); sum+=val; _delay_us(200); }
distance=sum/10;
}
//
void Door_first_close(){ PORTC=1; _delay_ms(1000); PORTC=0; }
//
void Door_close(){ PORTC=1; }
//
void Door_open(){ PORTC=2; _delay_ms(1000); PORTC=0; }
//
ISR(TIMER1_COMPA_vect){
if(door_open==YES){ sec++; }
else if(door_open==NO){ PORTC=0; cli(); TCCR1B=(1<<WGM12)|(0<<CS12); TCNT1=0; sec=0; }
}
//
int main(void){
DDRC=0xFF;
TCCR1B=(1<<WGM12)|(0<<CS12); OCR1A=62499; TIMSK=(1<<OCIE1A);
ADCSRA=0xE7;
Door_first_close();
while(1){
IR_ADC();
if(distance<10){
if(door_open==YES){ sec=2; }
else if(door_open==NO){
cli(); Door_open(); TCCR1B=(1<<WGM12)|(1<<CS12); sei();
door_open=YES;
}
}
if(sec>=3){ sec=0; Door_close(); door_open=NO; }
}
}
// MCU BASIC: https://www.basic4mcu.com
// DateTime : 2018-12-06 오전 9:13:23
// by Ok-Hyun Park
Build started 6.12.2018 at 09:12:23
avr-gcc -mmcu=atmega128 -Wall -gdwarf-2 -std=gnu99 -DF_CPU=16000000UL -O1 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT main.o -MF dep/main.o.d -c ../main.c
avr-gcc -mmcu=atmega128 -Wl,-u,vfprintf -lprintf_flt -lm main.o -lprintf_flt -lm -o test.elf
avr-objcopy -O ihex -R .eeprom -R .fuse -R .lock -R .signature test.elf test.hex
avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings -O ihex test.elf test.eep || exit 0
AVR Memory Usage
----------------
Device: atmega128
Program: 5430 bytes (4.1% Full)
(.text + .data + .bootloader)
Data: 7 bytes (0.2% Full)
(.data + .bss + .noinit)
Build succeeded with 0 Warnings...
4.18에서 에러 안납니다.
컴파일러 옵션 캡쳐해서 올려드릴테니 참고하세요
댓글 : 1
조회수 : 4,872
두루미님의 댓글
두루미 작성일옵션 때문이었네요 감사합니다.