Jump to content
Salibensuleiman

code stuck at the end of setup

Recommended Posts

Hi,

I am wondering why when I make the debug using  CCS, the code at the end of the setup opens a new window with following code and stuck there, I do not have any serial function, I tried to send the data to the serial monitor but it fails so I created a new project without any serial monitor statements/function.

#include <Energia.h>

int main(void)
{
    init();

    setup();

    for (;;) {
        loop();
        if (serialEventRun) serialEventRun();
    }

    return 0;
}

 

Any help would be appreciated. 

Thanks

Share this post


Link to post
Share on other sites

I'm not quie clear on your question, and at the risk that it's obvious...

for(;;) = loop forever

If your Engergia code has an empty loop(), and never does anything to generate a serial event, then it's going to be "stuck" in a loop that repeatedly checks for a serial event.

So, what's in your loop() code? What do you expect to see?

Share this post


Link to post
Share on other sites

This code is the loop code from Energia's main(). init() set's up the chip, setup() is your setup() in the Sketch and then finally loop() is the loop code in your Sketch.

It will indeed loop forever calling SerialEventRun() and your loop(). If you do not have a SerialEvent installed by implementing void serialEvent() in your Sketch then it won't be called.

As @NurseBob mentioned, what is in your setup() and loop() code. Is it really stuck in setup() or is it halting within the for(;;){} piece of code.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×