Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
7 years, 10 months ago.
About CMSIS-rots create thread beside the main.cpp
hi I'm trying to use osThreadCreate to create a thread
it's find on write on the main.cpp
But when I use it on the test.cpp file I create
the thread cant work!
this is my code
main.cpp
- include "mbed.h"
- include "cmsis_os.h"
- include "rtos.h"
void dump(const char* out); void test_thread(); void test1(void const *arg); extern void test3(void const *arg); Serial pc(USBTX, USBRX);
int main() { pc.baud(115200);
pc.printf("\n\rstart example\r\n");
test_thread();create thread test3 in the test_thread.cpp error
- if 1 osThreadDef (test1, osPriorityNormal, 512); osThreadCreate( osThread(test1), NULL);
- endif
- if 0 osThreadDef (test3, osPriorityNormal, 512); osThreadCreate( osThread(test1), NULL);
- endif
while(1) { pc.printf("\n\rentere delay\r\n"); osDelay (1000); } }
void test1(void const *arg){
while(1){
pc.printf("test1\n"); osDelay (1000);
} }
test_thread.cpp
- include "mbed.h"
- include "cmsis_os.h"
- include "rtos.h"
void test_thread(); void test3(void const*);
extern Serial pc;
- if 1 void test_thread(){
printf("create test3\n"); osThreadDef (test3, osPriorityNormal, 512); osThreadCreate( osThread(test3), NULL);
}
void test3(void const *arg){ osStatus status; while(1){ pc.printf("test3-1\n"); osDelay (1000); } }
}
- endif
in the main.cpp it look find when turn the 0 to 1 to create thread test3 in the main.cpp but it cant work when i use the function test_thread() to creat thread test3 on test_thread.cpp(it compile success). it will get stuck after printing create test3.
I have no idea to fix it thanks!