Atmega 32u4 and VBUS/sleep mode
hello,
for project first used arduino leonardo , have built our own.
for tests working on the sparkfun promicro board.
our problem deal usb functionalities. want put atmega in eco power mode , wake external interruption or interrupt vector of usb.
but when set vbuste bit of usbcon register atmel isn't recognized more computer, , flag vbus doesn't rise ( full_bat_warn() doesn't launch).
here main part of program:
for project first used arduino leonardo , have built our own.
for tests working on the sparkfun promicro board.
our problem deal usb functionalities. want put atmega in eco power mode , wake external interruption or interrupt vector of usb.
but when set vbuste bit of usbcon register atmel isn't recognized more computer, , flag vbus doesn't rise ( full_bat_warn() doesn't launch).
here main part of program:
code: [select]
void setup()
{
init_io(); // input , output setup
init_pwm();//init battery charge
init_accelerometer(int_pin_accel);
strip.begin();
strip.show(); // initialize pixels 'off'
usbcon |= _bv(vbuste);
delay(1000); //delay connect via usb before sleep_mode()
}
void loop()
{
char motion;
char shake;
static char mode = off_mode;
if(update_motion_flag){
update_motion_flag = 0;
shake = detect_motion(&motion);
}
switch (mode)
{
case off_mode :
entersleep();
if(shake)
{
if(vbus)
full_bat_warn();
mode = normal_mode;
}
break;
case charge_mode :
charge_control();
break;
case low_b_mode :
break;
case normal_mode :
if (state_batterie()==empty)
{
low_bat_warn();
mode = off_mode;
break;
}
mode = launch_normal();
break;
}
}
void entersleep(void)
{
set_sleep_mode(sleep_mode_pwr_down);
sleep_enable();
sleep_mode();
/* program continue here. */
/* first thing disable sleep. */
sleep_disable();
}
Arduino Forum > Using Arduino > Microcontrollers > Atmega 32u4 and VBUS/sleep mode
arduino
Comments
Post a Comment