Task execution point, synchronization and resource sharing

shan-ahmed wrote on Tuesday, October 27, 2015:

Well Im more like at early stage than a beginner to free RTOS… & out from no where and without any kinda of helping material I hv got an assignment from my tutor to perform the following.

The complete scenario is as follows:
Microcontroller to be used: PIC 18F452.
Software Development IDE : MPLAB from Microchip
Hardware Software Simulator: Proteus Simulator
Compiler: Microchip C18 Lite Compiler
RTOS: FreeRTOS

Application Description is as follows:
A task called my_task1 is receiving data from the PORTA through port change
interrupt using credit tracking synchronization and sends average of last four
samples to my_task2. my_task2 will receive this sample and send it to PORTB
which has LEDs connected to it. There are other three tasks namely my_task3,
my_task4 and may_task5 which need mutually exclusive access to PORTD. The
function of my_task3 is to send 0x00 to PORTD every 100 mili-seconds, my_task4
is to send 0x0F to PORTD every 500 mili seconds and my_task5 is to send 0xFF
every 1000 mili seconds. During implementation use timing services provided by
the RTOS whenever applicable and don’t use your own delay routines.

Seriously I dont want you people to do it for me, but I dont know anytthing about it, I just want you people me drive me through… I will be very grateful… :slight_smile:

rtel wrote on Wednesday, October 28, 2015:

Sorry for the delay in replying, it appears several emails have got stuck in moderation over the last few days, even though the forum is set to automatically approve all posts from users who have logged in.

Note that the PIC18 is not a good target for a pre-emptive RTOS and has not been maintained in a long time.

The tasks that are writing to port D periodically could use software timers http://www.freertos.org/RTOS-software-timer.html and simple critical sections for mutual exclusion (taskENTER_CRITICAL() before accessing the port, then taskEXIT_CRITICAL() after accessing the port).

A direct to task notification with the eSetValueWithOverwite action would be a quick way of sending a value from an interrupt to a task http://www.freertos.org/xTaskNotifyFromISR.html