Tool/software: TI-RTOS
Hello,
I have a code working using pthread call but I tried switching to rtos call structure and the code compiles with no errors/warnings but the code no longer works.
Below is the main function using pthread calls
#include <pthread.h> #include <stdint.h> #include <xdc/std.h> #include <ti/sysbios/knl/Task.h> /* RTOS header files */ #include <ti/sysbios/BIOS.h> /* Example/Board Header files */ #include "Board.h" #include "get_data.h" /* Stack size in bytes */ #define THREADSTACKSIZE 2048 int main(void) { pthread_t thread; pthread_attr_t attrs; struct sched_param priParam; int retc; int detachState; // Call driver init functions Board_initGeneral(); // Set priority and stack size attributes pthread_attr_init(&attrs); priParam.sched_priority = 1; detachState = PTHREAD_CREATE_DETACHED; retc = pthread_attr_setdetachstate(&attrs, detachState); if (retc != 0) { // pthread_attr_setdetachstate() failed while (1); } pthread_attr_setschedparam(&attrs, &priParam); retc |= pthread_attr_setstacksize(&attrs, THREADSTACKSIZE); if (retc != 0) { // pthread_attr_setstacksize() failed while (1); } retc = pthread_create(&thread, &attrs, get_data_Thread, NULL); // This throws a warning... if (retc != 0) { // pthread_create() failed while (1); } BIOS_start(); return (0); }
And here is it using rtos commands
#include <stdint.h> #include <xdc/std.h> #include <ti/sysbios/knl/Task.h> /* RTOS header files */ #include <ti/sysbios/BIOS.h> /* Example/Board Header files */ #include "Board.h" #include "get_data.h" #define TASK_STACK_SIZE 2048 uint8_t appTaskStack[TASK_STACK_SIZE]; Task_Struct task0; int main() { Board_initGeneral(); Task_Params taskParams; // Configure task Task_Params_init(&taskParams); taskParams.stack = appTaskStack; taskParams.stackSize = TASK_STACK_SIZE; taskParams.priority = 0; Task_construct(&task0, (Task_FuncPtr)get_data_Thread, &taskParams, NULL); BIOS_start(); return 0; }
Any help is greatly appreciated