after enabling interrupts, not reaching main's while(1) {...

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi All,

i have a strange thing happening, and can't understand whats the reason.

the following code snippet:

void main_init(void)
{
    irq_initialize_vectors();

    // Initialize the sleep manager
    sleepmgr_init();
    sysclk_init();
    board_init();
    battery_init();
    periodic_init((periodic_event_callback_t)periodic_cb);
    eeprom_init();
    app_init();

    /* init usb i/f and register handlers */
    usb_if_usb_init((usb_rx_callback_t)usb_incoming_data_handler,
                    (usb_event_callback_t)usb_attach_handler,
                    (usb_event_callback_t)usb_detach_handler);
}

void main_start(void)
{
    battery_start();
    udc_start();
    if (!udc_include_vbus_monitoring()) {
        usb_if_vbus_action(true);
    }
    cpu_irq_enable();
}

/*! \brief Main function. Execution starts here.
 */
int main(void)
{
    main_init();

    main_start();
	
    // The main loop manages only the power mode
    // because the USB management is done by interrupt
    while (1);
    {
        sleepmgr_enter_sleep();

        if (local_app_conf_changed)
        {
            local_app_conf_changed = false;
        }
    }

$ Fixed code tags - JS $

will never execute the while(1) {...}
(i see that the code is never executed. setting a breakpoint there and running, is disabled via the avr-studio - saying that setting bp at runtime is not allowed, even though the bp is set not at runtime.
setting a bp at main_start() will work).

any idea?

thanks in advance!
Mickey

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You probably enable an interrupt without providing an ISR() for it. Try the BADISR mechanism.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mickey_at wrote:

    while (1);


Remove the semicolon from that line, and you may see more action.

Sid

Life... is a state of mind

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm betting Chauncy found it. Got me once on a IF statement.

If you don't know my whole story, keep your mouth shut.

If you know my whole story, you're an accomplice. Keep your mouth shut. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi, Thank you all for your replies!
you were right! i miss-noticed the semi-colon.

Thanks again, you are great!