This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RTOS/MSP432P401R: Trying to get TI RTOS work

Part Number: MSP432P401R

Tool/software: TI-RTOS

Hi everybody,

I am a student trying to get in touch with the MSP432P401R launchpad and a simple chassi which includes two steppermotors, two hall sensors and a small joystick.

I want to start some simple threads:

- mainTread blinking LED

-adcThread - starting two threads reading in analog Values of the joystick in x and y

-pwmTread -controlling motor speed via pwm

-hallTread -count the hallsensor data input to know how fast and how far does it go

so far the code compiles and everything seems to be working, but it is stuck somewhere and the output never shows up. I tried out different configurations with different priority level, but nothing works. The PWM output, adcTread and the hallsensor thread never start.

I thought I made everything right, but I think I have a simple bug in the implementation of the TI-RTOS. I am new to the topic and I hope somebody can help me and give me a little push to the right direction to get the code to run.

Here is a link to my Gitlab Repository:

gitlab.com/cfritz182/TI_RTOS

Thanks in advance for a helping hand to get to start with TI-RTOS.

  • Christian,
    Thank you for posting your code. I will take a look at it and get back to you on Thursday. Have you also tried or had any issues with the other examples? What has been your process for adding threads and when did it stop functioning?

    Thanks,
    Chris
  • I started from the TI example called thermostat. there I changed my adc reading into joystick. than I changed the pwm output to the ports I use to control the motor. With this it seems that I does not work. Maybe I made a bad mistake in the board.h file or the MSP432.h or .c files. I am not sure. The normal procedure I think is to just initialize the pins in the Msp432....c files and board.h and msp432....h to change to the right pin and structure and so on. Or not?

    I think that it is more kind of a initialization problem, rather than being a really difficult scheduling task.

    Best wishes,
    Christian
  • Christian,

    (1) In the main_tirtos.c file you create 4 threads all with the same attributes. However, you created separate attributes for each and only the first attribute is a detached thread. The other 3 are initialized but not configured as detached threads. I cannot find any places in the code where you join to these threads. I would recommend keeping the threads detached if you do not plan on using them and for simplicity you could reuse the attrs pointer to create all threads.
    (2) The mainThread is the same priority as the other threads but never stops (sleeps, pends,etc).
    (3) GPIO_init() is called in pwm.c, hall.c and gpiomain.c
    (4) Similar to the mainThread, the pwmThread does not stop. If it is the highest priority task it will run forever.
    (5) The two threads created in adcThread have the same issue as mainThread.

    I would encourage you to go back through the examples found in SimpleLink Academy. Specifically, look at how the RTOS moves between the different threads. In the Multi-thread RTOS thermostat (dev.ti.com/.../ note that in each thread there is a usleep() API that allows other threads to be executed. Alternatively you can pend (sem_wait) operation based upon a semaphore (see this example: dev.ti.com/.../ )

    Regards,
    Chris
  • Thank you really much,
    these were the points I had an understanding issue with the termostat example. Now it gets crystal clear what happens, I always thought that the scheduler hops from one thread to another if they are all the same priority. So I will add the sleep commands to the tasks. The idea was to create threads that never stops ( but of course they have to go to sleep and let other threads run).

    So I will go back to the code and try to solve my problem on the weekend.

**Attention** This is a public forum