Take the 2-minute tour ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

I am working on a STM32f4 board and I have a problem with passing pointer as input in a function. I have my main :

    float32_t var;
    function(&var);

And my function :

    void function(float32_t* x){
        *x = 1.;
    }

But, oddly, when I debug this code, the x address doesn't fit the var address (x address is 0x00000000 pointer in function) and the value of var is not 1 after function calling. Why do I have this problem ? Moreover, this kind of function worked efficiently...

In fact, I found a new bug, once I launched the debugger a error occurs

No source available for ""

I never had this message...

I use the GCC GNU ARM compiler with these options :

     -mcpu=cortex-m4; -mthumb; -Wall; -ffunction-sections; -g; -O0; -fno-builtin; -DSTM32F407VG; -DSTM32F4XX; -I.;
share|improve this question
2  
I'm not really sure what the C standards say about 1. I've always used 1.0 which might be worth a try. It might also be worth adding complete compilable code along with details on the compiler you're using. –  PeterJ Jul 16 '13 at 7:40
 
I use the library given by ST and the core-m4 driver. The compiler is GNU GCC ARM with theses options : -mcpu=cortex-m4; -mthumb; -Wall; -ffunction-sections; -g; -O0; -fno-builtin;; -DSTM32F407VG; -DSTM32F4XX; -I.; –  user2412542 Jul 16 '13 at 7:44
 
= 1. Looks odd to me too.. –  m.Alin Jul 16 '13 at 7:45
 
For the 1., I already tested the two ways to write it (1. and 1.0) and both work. –  user2412542 Jul 16 '13 at 7:45
 
You can edit that extra info into the question to make it cleaer, sometimes comments get hidden as more are posted. Do you have a way to test the code works (maybe send to a serial port / LCD etc)? That would help isolate if it's a code generation problem or just a debugger problem. –  PeterJ Jul 16 '13 at 7:55
show 2 more comments

3 Answers

This sounds like a simple case of bad linking, because some of your object files aren't up to date, while the prototype of the function has changed.

Try clean away all your .o-files, and rebuild your source.

share|improve this answer
add comment

Nobody can explain why the Debugger launches this error at the start :

No source available for ""

Thks.

share|improve this answer
 
It's a little tough since you haven't told us what debugger you are using. However, I have seen this when using gdb in Eclipse, and as soon as I start running the code it finds the source files and displays them properly. –  Joe Hass Jul 26 '13 at 19:16
add comment

That sounds like the compiler optimized away your instructions (although you specified -O0 which should disable optimizations).

Can you try to define your variable as

volatile float32_t var;

And then try again?

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.