Hi,
I´m planning in using th eEmonlib on the ATmega 2560.
With which modifications should i be careful?
Is the Clock frequency (16MHz) a problem ?
Best regards
Archived Forum |
|
Port Emonlib to Mega 2560Submitted by Guest on Tue, 08/05/2012 - 16:44Hi, I´m planning in using th eEmonlib on the ATmega 2560. With which modifications should i be careful? Is the Clock frequency (16MHz) a problem ? Best regards » |
Re: Port Emonlib to Mega 2560
The clock on the Atmega328 also runs at 16Mhz, I don't have any experience using the 2560. Please let us know how you get on.
Re: Port Emonlib to Mega 2560
Atmega328 EmonLib.cpp
long EnergyMonitor::readVcc() {
long result;
ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
delay(2);
ADCSRA |= _BV(ADSC);
while (bit_is_set(ADCSRA,ADSC));
result = ADCL;
result |= ADCH<<8;
result = 1126400L / result;
return result;
}
change ->
Atmega2560 EmonLib.cpp
long EnergyMonitor::readVcc() {
long result;
ADMUX = _BV(REFS0) | _BV(MUX5) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
delay(2);
ADCSRA |= _BV(ADSC);
while (bit_is_set(ADCSRA,ADSC));
result = ADCL;
result |= ADCH<<8;
result = 1126400L / result;
return result;
}