Strange behavior, or 'how did it get in this if statement?'

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
ToVa_285016
Level 5
Level 5
100 replies posted 50 replies posted 50 questions asked

Hi,

   

See the attached image.  When I am debugging the project, the processor gets inside an if statement that it absolutely should not be able to.  I must be missing something very simple, but this is baffling...

   

Thank you,
Tom

0 Likes
9 Replies
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Not an optimization result of compiler ? Turn it off in build

   

settings and see what happens.

   

 

   

Regards, Dana.

0 Likes
ToVa_285016
Level 5
Level 5
100 replies posted 50 replies posted 50 questions asked

Pardon my ignorance, where can I find this option?

   

Thank you,
Tom

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Here (build settings) -

   

 

   

http://www.cypress.com/documentation/application-notes/an89610-psoc-4-and-psoc-5lp-arm-cortex-code-o...     AN89610 - PSoC® 4 and PSoC 5LP ARM Cortex Code Optimization

   

 

   

Regards, Dana.

0 Likes
lock attach
Attachments are accessible only for community members.
ToVa_285016
Level 5
Level 5
100 replies posted 50 replies posted 50 questions asked

Hi,

   

I turned off Arm GCC/Compiler/Optimization/Optimization Level.  This seemed to fix the problem.  Here are my results with the settings,

   

None:  Enters the if statement correctly

   

Debug:  Enters into if statement even if conditions are not true

   

Minimal:  Enters into if statement even if conditions are not true

   

High:  Does not enter into statement, break points give an error

   

Speed:  Does not enter into statement, break points give an error

   

Size:  Does not enter into statement, break points give an error

   

 

   

See attached project.  I have not run into this before - seems strange for a project so simple, I swear I have had similar projects before...  Can someone explain why one kind does not allow me to enter into an if statement, and other kinds do it even when they should not?

   

Regards,
Tom

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given
        Consider filing a CASE on this - To create a technical or issue case at Cypress - www.cypress.com “Support” “Technical Support” “Create a Case” You have to be registered on Cypress web site first. If you would not mind post back the results for the benefit of the forum. Regards, Dana.   
0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

My experiences with single-stepping are quite the same. On the other hand I was able to proof that the program flow was quite correct, only the breakpoints were reached or not reached reproducably but not as expected. The real program flow was exactly as expected. So I decided for me to always set the optimization to "none" while debugging.

   

 

   

Bob

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given
        Of course setting optimization to none works great as long as you are not up against FLASH (code) size limitations, which if the case you have no choice but to optimize. Been there, done that. Regards, Dana.   
0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Since the optimization level can be set individually for every file you can save lots of bits and mips when lowering the level only for the files under test.

   

At the recent Customer Advisory Board (CAB) at Cypress in Portland we suggested to default the optimization level for the generated files to a high level.

   

 

   

Bob

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Actually the optimization level can be set to the f() level.

   

 

   

Regards, Dana.

0 Likes