using function in thread

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
deadlyboy
Posts: 27
Joined: Wed Nov 26, 2014 9:27 am

using function in thread

Post 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
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: using function in thread

Post by Giovanni »

Hi,

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

Giovanni
deadlyboy
Posts: 27
Joined: Wed Nov 26, 2014 9:27 am

Re: using function in thread

Post by deadlyboy »

thanks

more functions nesting -> more stack is used


even if the nested function was inline??
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: using function in thread

Post by Giovanni »

It depends on compile options, with -O0 functions are not inlined I think.

Giovanni
Post Reply