BASIC4MCU | 질문게시판 | avr 빌드 추가 질문입니다.
페이지 정보
작성자 두루미 작성일2018-12-05 23:04 조회5,983회 댓글0건본문
pow 관련 질문했었는데 해결되지 않아 다시 질문합니다.
#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 int sec = 0;
float distance;
unsigned char door_open = NO;
ISR(TIMER1_COMPA_vect)
{
if(door_open == YES)
{
sec++;
}
else if(door_open == NO)
{
PORTC = 0b00000000;
cli();
TCCR1B = (1<<WGM12)|(0<<CS12);
TCNT1 = 0;
sec = 0;
}
}
void IR_ADC()
{
float val;
float 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 = 0b00000001;
_delay_ms(1000);
PORTC = 0b00000000;
}
void Door_close()
{
PORTC = 0b00000001;
}
void Door_open()
{
PORTC = 0b00000010;
_delay_ms(1000);
PORTC = 0b00000000;
}
int main(void)
{
DDRC = 0xFF;
PORTC = 0x00;
DDRF = 0x00;
PORTF = 0x00;
TCCR1A = 0x00;
TCCR1B = (1<<WGM12)|(0<<CS12);
TCCR1C = 0x00;
TIMSK = (1<<OCIE1A);
OCR1A = 62499;
TCNT1 = 0;
ADMUX=0x00;
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;
}
}
}
avr studio 4.19 사용했습니다..
댓글 0
조회수 5,983등록된 댓글이 없습니다.