Page 1 of 1

using function in thread

Posted: Fri May 15, 2015 2:39 pm
by deadlyboy
hi every body

im using stm34f4 . in my current project i created a thread beside the main thread , in that thread i call a function like this :

Code: Select all

static WORKING_AREA(myThreadWorkingArea, 128);
static msg_t myThread(void *arg) {
     int16_t m ;
     while (TRUE) {
        m_PollData(&m);
     }
}


m_PollData collects some sensor data from i2c. in this function i called another function like this

Code: Select all

void m_PollData(int16_t *value)
{
    int foo();
   do_something....
}

when i compile the program , it does't work . but when i copy i of the codes from foo() and paste it to m_PollData and remove the called function it will be good and works fine.
from your sight what shuld be the problem.

thanks in advance
MA

Re: using function in thread

Posted: Fri May 15, 2015 2:54 pm
by Giovanni
Hi,

It could be a stack overflow, more functions nesting -> more stack is used.

Giovanni

Re: using function in thread

Posted: Fri May 15, 2015 8:46 pm
by deadlyboy
thanks

more functions nesting -> more stack is used


even if the nested function was inline??

Re: using function in thread

Posted: Fri May 15, 2015 10:28 pm
by Giovanni
It depends on compile options, with -O0 functions are not inlined I think.

Giovanni