Code freeze on simple functions

Discussion in 'Troubleshooting' started by JDorval, Feb 17, 2014.

  1. JDorval

    JDorval New Member

    Joined:
    Jan 23, 2014
    Messages:
    5
    Likes Received:
    0
    Hello, my code is freezing on very simple code.
    For debugging purposes I use serial.println()

    String number = "5";
    Serial.println("starting conversion");
    int stringNumber = number.toInt();
    Serial.println("conversion done");

    When i execute this, it gets stuck at the .toInt() function

    Also, when I try to divide a long :

    long duration = 2000;
    Serial.println("division start");
    long result = duration / 25;
    Serial.println("division end");

    Same problem occurs, the code just seems to stop there , it never gets to "division end".
    Anyone got any insight on why code is bugging with these common operations? My code is working fine on some arduino uno board, but it won't work on the embeded board on the udoo.
    thanks a lot !
     
  2. JDorval

    JDorval New Member

    Joined:
    Jan 23, 2014
    Messages:
    5
    Likes Received:
    0
    After more investigation, any kind of calculation freezes the code. I can't even make an addition such as

    int i = 0;
    i = i+1;
     
  3. ariadrianto

    ariadrianto New Member

    Joined:
    Feb 22, 2014
    Messages:
    4
    Likes Received:
    0
    Thats right, I got this freeze too.

    Just a small calculation and it hang.
    What should we do ?
     
  4. DangerousThing

    DangerousThing New Member

    Joined:
    Jan 23, 2014
    Messages:
    21
    Likes Received:
    0
    What language are you using? I'm assuming that it's c++, but it could be objective c. In just boring c I was able to get calculations to works.
     
  5. Stebar59

    Stebar59 New Member

    Joined:
    Nov 17, 2013
    Messages:
    5
    Likes Received:
    0
    Hi,
    I have also a "freezing" problem but it is not because of the operation: it is due to a String variable declaration!!
    This is my code:

    // ----------------------------------------------------------------------------------
    String test;

    void setup() {
    Serial.begin(9600);
    }

    void loop() {
    Serial.println("Test");
    delay(1000);
    }
    // ---------------------------------------------------------------------------------

    If I comment out the String declaration the loop is workin as expected.
    With the declaration I can compile the code and download it but I have no outputs, i.e. the program is freezing.

    Some ideas?

    Stefano
     

Share This Page