Skip to main content
kasun_duminda92
Associate II
July 2, 2013
Question

CMSIS RTOS Variable Problem

  • July 2, 2013
  • 2 replies
  • 652 views
Posted on July 02, 2013 at 17:56

This discussion was mistakenly add in this section. It should be in the STM32 Discovery section. So it was moved there.

#discovery #stm32 #rtos #cmsis
This topic has been closed for replies.

2 replies

dthedens23
Associate
July 2, 2013
Posted on July 02, 2013 at 20:18

I cannot say why it is hanging.  perhaps your stack size is way to small?

osThreadDef(Funct, osPriorityNormal, 1, 256);

Waking a thread every 1ms is pretty harsh.  Try every 50ms and increment count by 50.

I can say that you have two threads nakedly accessing the same variable.  That access is not thread safe,

First, the variable should use the keyword ''volatile''

second, there should be a mutex that each thread calls to gain access to the variable.  Only one thread at a time can ''hold'' the variable, to read or modify and then, the thread releases the mutex.

NOTE: in this simple example it might not matter to much, since one thread is the consumer and the other thread is the provider.  But naked access will cause problems.

Amel NASRI
Technical Moderator
July 30, 2013
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.