笨办法,手动测试建立电压-功率表格。查表,。。。天。每格0。1w一次20w量程就要200次。有没有好办法啊。。。。求助
//icc-avr application builder : 2010-12-26 上午 01

02
// target : m16
// crystal: 4.0000mhz
#include <iom16v.h>
#include <macros.h>
int tabv[10]={1,2,3,4,5,6,7,8,9,0};//先绘制表格,每隔0.1w一个,计划做20w即200个
int p;
char s=0;
int ad=6;
void port_init(void)
{
porta = 0x00;
ddra = 0x00;
portb = 0x00;
ddrb = 0x00;
portc = 0x00; //m103 output only
ddrc = 0x00;
portd = 0x00;
ddrd = 0x00;
}
//call this routine to initialize all peripherals
void init_devices(void)
{
//stop errant interrupts until set up
cli(); //disable all interrupts
port_init();
mcucr = 0x00;
gicr = 0x00;
timsk = 0x00; //timer interrupt sources
sei(); //re-enable interrupts
//all peripherals are now initialized
}
//
void main(void)
{
init_devices();
while(1)
{
if(ad<tabv[s])
p=s; //查表得出功率值
else
s++;
}
//insert your functional code here...
}