ATmega88的内部1.1V基准简易评估
发布时间:2008/6/3 0:00:00 访问次数:1134
硬件平台:
m8dk板子,usb和3v供电,板上无其他元件,仅m88和usb取电接口和isp接口,fluke 189真有效值表测量。
第一片m88:
1.0692@5v,1.0746@3v
第二片m88:
1.0924@5v,1.0973@3v
从结果可以发现总体而言m88的adc ref比m8改进不少,但是从之前的2.5v变成了1.1v,可能会对部分使用场合造成影响,但是精度提高不少,如果每片m88都能想第二片测试样品一样那就比较完美了。
atmega88 is not designed to be a replacement for atmega8, but is pin compatible and has a very similar feature set.
m88并不是设计成用来代替m8的,但是m88和m8的架构比较相象,而且m88有很多新的特性,特别是在功耗控制和io中断方面比较有优势,还集成了单线jtag调试接口,并且价格也和m8相差不大,所以在一些对功耗敏感的应用上用m88来代替m8是个不错的选择。
测试代码:
/*this is a sample of using the adc integrated in mega88*/
//registers:
//admux:
// 7 6 5 4 3 2 1 0
// refs1 refs0 adlar mux3 mux2 mux1 mux0
// refs1:refs0=1:1,内部1.1v基准,aref外部并接电容
// adlar=0 右对齐;adlar=1左对齐
// mux3..1=adcx:选择ad通道
//
//adcsra:
// 7 6 5 4 3 2 1 0
// aden adsc adate adif adie adps2 adps1 adps0
// aden=1,enable adc
// adsc=1,置一转换开始,完成后硬件复位
// adate=1,adc aoto trigger enable,adc连续转换模式
// adif=1,adc转换数据放入adcl,adch后该位置1
// adie=1,adc中断使能
// adps2:adps0=预分频选择:0-7=2,2,4,8,16,32,64,128
//
//adcl,adch:
// adc0-adc9
// (adlar=0)左对齐高两位在adch,(adlar=1)右对齐高8位在adch
//
//adcsrb:
// 7 6 5 4 3 2 1 0
// - acme - - - adts2 adts1 adts0
//
// adts2-0:adc auto trigger source
//
//didr0:
// 7 6 5 4 3 2 1 0
// - - adc5d adc4d adc3d adc2d adc1d adc0d
// adc5...0d: digital input disable
//
//
//
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/signal.h>
uint8_t adc_mux=0;
uint16_t adc_rel;
void adc_init(void)
{
ddrc=0x00;
portc=0x00;
adcsra=0x00;
admux=((1<<refs0)(1<<refs1)(adc_mux&0x0f));
adcsra=(1<<aden)(1<<adsc)(1<<adie)(1<<adps2)(1<<adps1); //64分频
}
signal(sig_adc)
{
//adc_rel=(adcw&0x3ff);
adc_rel=*( unsigned int *)0x05;
admux=(1<<refs0)(1<<refs1)(adc_mux&0x0f);
adcsra=(1<<adsc);
//portb=0x07;
}
void main(void)
{
ddrb = 0xff; /* output */
portb = 0xff; /* all off */
adc_init();
sei();
for(;;)
// portb=(adc_rel&0x00ff);
;
}
winavr20050214编译通过(需要手动修改makefile),目的仅是选择内部1.1v 基准,并在21脚进行测试。
硬件平台:
m8dk板子,usb和3v供电,板上无其他元件,仅m88和usb取电接口和isp接口,fluke 189真有效值表测量。
第一片m88:
1.0692@5v,1.0746@3v
第二片m88:
1.0924@5v,1.0973@3v
从结果可以发现总体而言m88的adc ref比m8改进不少,但是从之前的2.5v变成了1.1v,可能会对部分使用场合造成影响,但是精度提高不少,如果每片m88都能想第二片测试样品一样那就比较完美了。
atmega88 is not designed to be a replacement for atmega8, but is pin compatible and has a very similar feature set.
m88并不是设计成用来代替m8的,但是m88和m8的架构比较相象,而且m88有很多新的特性,特别是在功耗控制和io中断方面比较有优势,还集成了单线jtag调试接口,并且价格也和m8相差不大,所以在一些对功耗敏感的应用上用m88来代替m8是个不错的选择。
测试代码:
/*this is a sample of using the adc integrated in mega88*/
//registers:
//admux:
// 7 6 5 4 3 2 1 0
// refs1 refs0 adlar mux3 mux2 mux1 mux0
// refs1:refs0=1:1,内部1.1v基准,aref外部并接电容
// adlar=0 右对齐;adlar=1左对齐
// mux3..1=adcx:选择ad通道
//
//adcsra:
// 7 6 5 4 3 2 1 0
// aden adsc adate adif adie adps2 adps1 adps0
// aden=1,enable adc
// adsc=1,置一转换开始,完成后硬件复位
// adate=1,adc aoto trigger enable,adc连续转换模式
// adif=1,adc转换数据放入adcl,adch后该位置1
// adie=1,adc中断使能
// adps2:adps0=预分频选择:0-7=2,2,4,8,16,32,64,128
//
//adcl,adch:
// adc0-adc9
// (adlar=0)左对齐高两位在adch,(adlar=1)右对齐高8位在adch
//
//adcsrb:
// 7 6 5 4 3 2 1 0
// - acme - - - adts2 adts1 adts0
//
// adts2-0:adc auto trigger source
//
//didr0:
// 7 6 5 4 3 2 1 0
// - - adc5d adc4d adc3d adc2d adc1d adc0d
// adc5...0d: digital input disable
//
//
//
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/signal.h>
uint8_t adc_mux=0;
uint16_t adc_rel;
void adc_init(void)
{
ddrc=0x00;
portc=0x00;
adcsra=0x00;
admux=((1<<refs0)(1<<refs1)(adc_mux&0x0f));
adcsra=(1<<aden)(1<<adsc)(1<<adie)(1<<adps2)(1<<adps1); //64分频
}
signal(sig_adc)
{
//adc_rel=(adcw&0x3ff);
adc_rel=*( unsigned int *)0x05;
admux=(1<<refs0)(1<<refs1)(adc_mux&0x0f);
adcsra=(1<<adsc);
//portb=0x07;
}
void main(void)
{
ddrb = 0xff; /* output */
portb = 0xff; /* all off */
adc_init();
sei();
for(;;)
// portb=(adc_rel&0x00ff);
;
}
winavr20050214编译通过(需要手动修改makefile),目的仅是选择内部1.1v 基准,并在21脚进行测试。