Change gcc optimization level

Discussions and support about ChibiStudio, the free development environment for ARM.
dhruvin91
Posts: 12
Joined: Tue Oct 01, 2013 8:50 am

Change gcc optimization level

Postby dhruvin91 » Mon Feb 03, 2014 2:04 am

Hi,

Our program has unpredictable behavior on some instances. but if I add a line that should not make a difference program works.
I think this is because of optimization level. It might go away if I change optimization level from 3 to 2.

Does anyone know how to do so?
Thank you.

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Change gcc optimization level

Postby Giovanni » Mon Feb 03, 2014 9:22 am

HI,

Edit the Makefile in the project, the level is 2 by default (and note, you should not have instabilities at any optimization level, you risk to hide the real problem).

Giovanni

dhruvin91
Posts: 12
Joined: Tue Oct 01, 2013 8:50 am

Re: Change gcc optimization level

Postby dhruvin91 » Fri Feb 07, 2014 2:17 am

Thanks for the help. Yes you were right. This did not make much difference.

And I still need help. It would be great if I can get help with this.

I have following function

Code: Select all

boolean sendCommandCheckAck_fcn(uint8_t *cmd, uint8_t cmdlen, uint16_t timeout) {
    uint16_t timer = 0;
    uint8_t x;
   
    // write the command
    spiwritecommand_fcn(cmd, cmdlen);

    // Wait for chip to say its ready!
    while (readspistatus_fcn() != PN532_SPI_READY) {
        if (timeout != 0) {
            timer+=10;
            if (timer > timeout)
                return FALSE;
        }
        delay_ms(10);
    }
ghConsoleprint("h1\n");
    // read acknowledgement
    if (!spi_readack_fcn()) {
        return FALSE;
    }
    ghConsoleprint("h2\n");
    timer = 0;
    // Wait for chip to say its ready!
    x=readspistatus_fcn();
    while (x != PN532_SPI_READY) {
      x=readspistatus_fcn();
        if (timeout != 0) {
            timer+=10;
            if (timer > timeout)
               return FALSE;
        }
        delay_ms(10);
    }
    return TRUE; // ack'd command
}


Here if I change following code

Code: Select all

 x=readspistatus_fcn();
    while (x != PN532_SPI_READY) {
      x=readspistatus_fcn();

to following

Code: Select all

    while (readspistatus_fcn() != PN532_SPI_READY) {

The function would not work. With first code, STM32 detects PN532 but with second it does not.

Similarly if I remove "ghConsoleprint("h1\n");" than PN532 does not perform peer to peer detection/communication error rate increases.

I am not sure what could be the problem.
Thank you.

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Change gcc optimization level

Postby Giovanni » Fri Feb 07, 2014 8:25 am

I don't recognize any of the functions you call in that code, how am I supposed to help? also, please keep requests on the appropriate forums.

Giovanni


Return to “ChibiStudio”

Who is online

Users browsing this forum: No registered users and 24 guests