cancel
Showing results for 
Search instead for 
Did you mean: 

EWARM breakpoints not working....

jason23
Associate II
Posted on December 11, 2013 at 11:57

The subject line is not strictly right. I can set breakpoints but not on all of my code. Here is the story so far.

I have written some code for the STM32F0 Discovery board. The code runs both SPI ports as masters, TX only and USART1 for TX and RX. All of these work as required. I am in the process of writing a parser for the RX data from the USART. I have parsed the data using <SP> as the delimiter and am now comparing the first string parsed (a command word) with an array of commands to identify which command function call I need to make. The loop for the compare works fine but the CMD_index (uint16_t) came back as unavailable. I then checked that I have declared it properly and then it comes back with a value of 3616 (0x0e20). Further investigation shows that this is the value found if CMD_index is a pointer set to NULL. At this point I notice an error in the build window telling me that CSTACK is not in the correct range. Further more I cannot set breakpoints on all of my code, only selected parts. If I single step the code the IDE will jump over sections of code that it should stop at.

At this point I was getting frustrated so I decided to get back to a clean version of the code. My code started life as the SysTick example. I copied off my code, re-named the complete examples directory and downloaded a new copy from ST. I then run up the SysTick code to check all is OK. Satisfied with that I then copied my code (main.c and main.h) over the SysTick code and did a Rebuild All. I now do not get any issues with CSTACK but I still can only set breakpoints on some of my code.

Any ideas, anyone?

Jason

3 REPLIES 3
frankmeyer9
Associate II
Posted on December 11, 2013 at 13:56

How are your build/optimization settings ?

If you let the compiler optimize your code, he may remove expressions and variables, and reorder expressions as he sees fit. And, of course, you can't set breakpoints on not-actually-existing code, or watch not-actually-existing variables.

I'm no IAR user, but for gcc, a build flag ''-O0'' would disable any optimization, enforcing execution of the code as written.

At this point I notice an error in the build window telling me that CSTACK is not in the correct range.

 

Don't know IARWB, but according to my interpretation, a static compile-time analysis of your project predicts a stack overflow at runtime. Increasing the stack size would help here.

I believe IAR has a user forum as well, which might be better prepared for toolchain-specific questions.

jason23
Associate II
Posted on December 11, 2013 at 15:36

Hi fm,

You are an absolute star. I went and looked in the compiler options and found that it was set for high optimisation for speed. This was a requirement for the GPIO example code. I changed this to NONE and the problem is solved.

Thanks for the help.

Jason

Posted on December 11, 2013 at 16:14

''I changed this to NONE and the problem (sic) is solved''

Well, there wasn't actually any problem  as such in the first place;  other than a misunderstanding of how compilers work - but, hopefully, that is now fixed...?