Connect with us

Task function in program

Discussion in 'Microcontrollers, Programming and IoT' started by vead, May 15, 2017.

Scroll to continue with content
  1. vead

    vead

    473
    14
    Nov 27, 2011
    Hello
    I was reading document , there was topic Task function with part of program. its related to RTOS program.
    Code:
    int main ( void )
    {
    vInitSystem();// Initialization of peripherals
    while(1) // Infinitive function calling loop
    {
    vTask1(); // Calling task function named vTask1
    vTask2(); // Calling task function named vTask2
    vTask3(); // Calling task function named vTask3
    }
    }
    . generally we connect microcontroller with different types of devices (LED, LCD, Keypad, button , switch, Motor ..etc) For specific purpose. there are different type of task such as turn on LED, turn off LED, wait , Run Motor, display message..etc there are three task in program that means device is doing three task. I don't understand, which type of task's it may be ?
    can anyone explain with example
     
  2. Harald Kapp

    Harald Kapp Moderator Moderator

    10,023
    2,136
    Nov 17, 2011
    Anything that may be required for the program to do its job.
    e.g.
    - read keyboard
    - update display
    - write somethinmg to a logfile
    ... whatever you need to do.
     
    vead likes this.
  3. vead

    vead

    473
    14
    Nov 27, 2011
    I have only two doubt
    type 1. do we create task in program for only one device ?
    Task1 turn ON LED
    Task2 delay
    Task3 Turn Off LED
    Type 2 do we create task in program for multiple devices ?
    task 1 Turn on LED
    Task 2 turn On Motor
    Task 3 display message on LCD
     
  4. Harald Kapp

    Harald Kapp Moderator Moderator

    10,023
    2,136
    Nov 17, 2011
    That depends on the complexity and the kind of task.
    In principle you can use both methods, but encapsulating all the code that is required to e.g. control one device (e.g. LED) into a single task is what I'd prefer.
    Imagine working on a big project with many programemrs. You can then assign each programme one task to develop. It would require a lot of communication between programmers if for example one programmer were to design the task for 'LED on', another programmer the task for 'LED off'. You'd have to ensure that these two programmers are syncronized in their use of ressources (ports, timers), in the use of consistent nomenclature etc.
    How much simpler to assigng one programmer to create a task e.g. LED_Control with ('on', 'off', 'blink' etc.) as sub-programms of that single task while another programmers is occupied with e.g. controlling a motor.
     
  5. vead

    vead

    473
    14
    Nov 27, 2011
    I have downloaded book and pdfs I am studying documents . it has been long time searching but still have many doubts. Can you give me some simple assignment or task for further research just for learning
     
  6. Harald Kapp

    Harald Kapp Moderator Moderator

    10,023
    2,136
    Nov 17, 2011
    I'm truly sorry, but I do not have tha kind of material at hand.
     
  7. vead

    vead

    473
    14
    Nov 27, 2011
    Thanks for your effort and time. I am not asking for any material. it will be fine for me if you can tell me with specific device (LED or LCD) as you told me in your previous post
    whats the requirement ?
    which device is connected with microcontroler ?
    how many task we are going to do ?
    what will priority of task ?
    all of answers I am looking in simple example. I have downloaded some sample code. but its more difficult to understand. if possible can you explain all things in single example..
     
    Last edited: May 15, 2017
  8. Harald Kapp

    Harald Kapp Moderator Moderator

    10,023
    2,136
    Nov 17, 2011
    These are questions i can't aswer for you. It is your task as a developer to decide what is cnnected where and how and how you are going to control it.
    There is no universal standard for this.
    Downloaded samle code is not much worth when you don't know in which context it is meant to be used. That is information that usually can be found at the same place where you found the code.

    This is all stuff not easily and quickly explained in a few lines.
    Use your favorite search engine and look up 'task scheduling fundamentals', read the material you find.
     
  9. vead

    vead

    473
    14
    Nov 27, 2011
    sorry for taking so much time. if you look at my first post I tried to explain with example. I am not asking answers. I am asking only idea. suppose you have only Microcontroller , LED and LCD. and you have connected LCD and LED to Microcontroller. what could you do with these devices using RTOS program. I am asking at least five task. what you can make using RTOS program that may be benefit for someone. I am asking example of task that you can do with these devices.
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-