[avr] throttle back the clock when in power-loss mode

This commit is contained in:
Bart Van Der Meerssche 2011-02-17 23:48:31 +01:00
parent e3de39f026
commit 18d91b024f
1 changed files with 13 additions and 3 deletions

View File

@ -24,6 +24,7 @@
#include <avr/io.h> #include <avr/io.h>
#include <avr/interrupt.h> #include <avr/interrupt.h>
#include <avr/eeprom.h> #include <avr/eeprom.h>
#include <avr/power.h>
#include <util/delay.h> #include <util/delay.h>
@ -243,14 +244,23 @@ ISR(TIMER1_CAPT_vect)
{ {
disable_led(); disable_led();
// throttle the cpu clock to draw less amps
clock_prescale_set(clock_div_16);
event.brown_out++; event.brown_out++;
#ifdef DBG > 0
uint8_t i;
for (i=0; i<128; i++)
eeprom_write_byte((uint8_t *)(i + 0x0100), i);
#else
eeprom_update_block((const void*)&sensor, (void*)&EEPROM_sensor, sizeof(sensor)); eeprom_update_block((const void*)&sensor, (void*)&EEPROM_sensor, sizeof(sensor));
eeprom_update_block((const void*)&event, (void*)&EEPROM_event, sizeof(event)); eeprom_update_block((const void*)&event, (void*)&EEPROM_event, sizeof(event));
#endif
// uint8_t i; // restore the original clock setting
// for (i=0; i<128; i++) clock_prescale_set(clock_div_1);
// eeprom_write_byte((uint8_t *)i, i);
setup_led(); setup_led();
} }