avr studio编译的时候报错,要如何改正? 5
报错的那行是make:***[main.o]Error-1073741502只有这一个错误。程序是#ifndefADC_H#defineADC_H#defineFILMA...
报错的那行是make: *** [main.o] Error -1073741502
只有这一个错误。
程序是
#ifndef ADC_H
#define ADC_H
#define FILMASK 3
#define FILNUM 4
#define WARP(X) X=((X+1)&FILMASK)
uchar FilterBuf[FILNUM];
uchar Dx=0;
uchar AdValue;
uchar Filter(uchar * value);
void delayms(uint i)
{
uint j;
while(i--)
{
for(j=0;j<30;j++);//至少20才能让ADC比较正常
}
}
void ADC_init()
{
ADMUX=0X60;
ADCSRA=0X87;
}
uint get_adc(uchar channel)
{
uint a=0,b=0;
uchar c;
c=0x60+channel;
ADMUX=c;
delayms(1);
while(!(c==ADMUX));
ADCSRA|=0X40;
while(!(ADCSRA&0X10));
a=ADCL;
b=ADCH;
ADCH=0x00;
ADCL=0x00;
ADCSRA&=0Xef;
return b;
}
/*---------------------------------------------------------------------------
---------------------------------------------------------------------------*/
void getdata()
{
AdValue=get_adc(1);
FilterBuf[WARP(Dx)]=AdValue;
AdValue=Filter(FilterBuf);
}
uchar Filter(uchar * value)
{
uchar i;
uint tt=0;
for(i=0;i<FILNUM;i++)
{
tt +=value;
}
return tt/FILNUM;
}
#endif
#include<iom16v.h>
#include<macros.h>
#include"12864.h"
#include"INIT.h"
#include"ADC.h"
#define uint unsigned int
#define uchar unsigned char
int ads,m;
int kp=3;ki=0,kd=37;
int temp=0;
int pid(int input)
{
//输入范围:
//输出范围:
static int n1,n2,n3,res;
//int res;
n1=input-159;
//n1=n1*n1;
res=22+kp*n1*n1/153+(n1-n2)*kd;
n3=n2;
n2=n1;
return res;
}
void main(void)
{
ADC_init();
IO_init();
LCD_init();
PORTB&=~0x01;
PORTB|=0x02;
Delay_ms(200);
display_map(QQ);
Delay_ms(20000);
LCD_Clr_All();
while(1)
{
getdata();
//LCD_Num_Str_Disp(6,2,AdValue);
//if(temp>0) LCD_Num_Str_Disp(6,1,temp);
//else LCD_Num_Str_Disp(6,1,-temp);
DDRD|=0X30;
TCCR1A=0X63;
TCCR1B=0X1B;
/*if(AD[1]>140)
{
m=AD[1]-140;
}
else
{
m=0;
}*/
OCR1A=99;
temp=pid(AdValue);
if(temp>99)temp=99;
if(temp<0)temp=0;
OCR1B=temp;
//QF;
}
} 展开
只有这一个错误。
程序是
#ifndef ADC_H
#define ADC_H
#define FILMASK 3
#define FILNUM 4
#define WARP(X) X=((X+1)&FILMASK)
uchar FilterBuf[FILNUM];
uchar Dx=0;
uchar AdValue;
uchar Filter(uchar * value);
void delayms(uint i)
{
uint j;
while(i--)
{
for(j=0;j<30;j++);//至少20才能让ADC比较正常
}
}
void ADC_init()
{
ADMUX=0X60;
ADCSRA=0X87;
}
uint get_adc(uchar channel)
{
uint a=0,b=0;
uchar c;
c=0x60+channel;
ADMUX=c;
delayms(1);
while(!(c==ADMUX));
ADCSRA|=0X40;
while(!(ADCSRA&0X10));
a=ADCL;
b=ADCH;
ADCH=0x00;
ADCL=0x00;
ADCSRA&=0Xef;
return b;
}
/*---------------------------------------------------------------------------
---------------------------------------------------------------------------*/
void getdata()
{
AdValue=get_adc(1);
FilterBuf[WARP(Dx)]=AdValue;
AdValue=Filter(FilterBuf);
}
uchar Filter(uchar * value)
{
uchar i;
uint tt=0;
for(i=0;i<FILNUM;i++)
{
tt +=value;
}
return tt/FILNUM;
}
#endif
#include<iom16v.h>
#include<macros.h>
#include"12864.h"
#include"INIT.h"
#include"ADC.h"
#define uint unsigned int
#define uchar unsigned char
int ads,m;
int kp=3;ki=0,kd=37;
int temp=0;
int pid(int input)
{
//输入范围:
//输出范围:
static int n1,n2,n3,res;
//int res;
n1=input-159;
//n1=n1*n1;
res=22+kp*n1*n1/153+(n1-n2)*kd;
n3=n2;
n2=n1;
return res;
}
void main(void)
{
ADC_init();
IO_init();
LCD_init();
PORTB&=~0x01;
PORTB|=0x02;
Delay_ms(200);
display_map(QQ);
Delay_ms(20000);
LCD_Clr_All();
while(1)
{
getdata();
//LCD_Num_Str_Disp(6,2,AdValue);
//if(temp>0) LCD_Num_Str_Disp(6,1,temp);
//else LCD_Num_Str_Disp(6,1,-temp);
DDRD|=0X30;
TCCR1A=0X63;
TCCR1B=0X1B;
/*if(AD[1]>140)
{
m=AD[1]-140;
}
else
{
m=0;
}*/
OCR1A=99;
temp=pid(AdValue);
if(temp>99)temp=99;
if(temp<0)temp=0;
OCR1B=temp;
//QF;
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询