Lower priority task with getchar() halts higher task in FreeRTOS - how to fix that?












0















I have two functions:



shell() uses getchar() to get user input



playLED() plays a LED animation



I have two tasks running in FreeRTOS



    xTaskCreate(
shell,
"shell",
512,
NULL,
1,
NULL);

xTaskCreate(
playLED,
"playLED",
512,
NULL,
15,
NULL );
vTaskStartScheduler();


Then I noticed the LED animation play become step-wise, it changes only when getchar() received input from user, instead of a smooth animation.



I've already set LED priority a lot higher, however this didn't fix the halt. Is there anything else that I should configure somewhere?



The code is run on NXP LPC54018 board with MCUXpresso. A similar problem on a different device can be found at https://os.mbed.com/questions/781/Skip-getchar-if-no-input-using-interrupt/










share|improve this question

























  • Can you better describe your environment (CPU, libraries, µC, toolset)? getchar() is not part of FreeRTOS. So only answers specific to your environment can be given.

    – Codo
    Oct 27 '18 at 9:17











  • Thanks for the reply. I am using it with a MCUxpresso on NXP LPC 54018

    – Suicide Bunny
    Oct 29 '18 at 17:59
















0















I have two functions:



shell() uses getchar() to get user input



playLED() plays a LED animation



I have two tasks running in FreeRTOS



    xTaskCreate(
shell,
"shell",
512,
NULL,
1,
NULL);

xTaskCreate(
playLED,
"playLED",
512,
NULL,
15,
NULL );
vTaskStartScheduler();


Then I noticed the LED animation play become step-wise, it changes only when getchar() received input from user, instead of a smooth animation.



I've already set LED priority a lot higher, however this didn't fix the halt. Is there anything else that I should configure somewhere?



The code is run on NXP LPC54018 board with MCUXpresso. A similar problem on a different device can be found at https://os.mbed.com/questions/781/Skip-getchar-if-no-input-using-interrupt/










share|improve this question

























  • Can you better describe your environment (CPU, libraries, µC, toolset)? getchar() is not part of FreeRTOS. So only answers specific to your environment can be given.

    – Codo
    Oct 27 '18 at 9:17











  • Thanks for the reply. I am using it with a MCUxpresso on NXP LPC 54018

    – Suicide Bunny
    Oct 29 '18 at 17:59














0












0








0








I have two functions:



shell() uses getchar() to get user input



playLED() plays a LED animation



I have two tasks running in FreeRTOS



    xTaskCreate(
shell,
"shell",
512,
NULL,
1,
NULL);

xTaskCreate(
playLED,
"playLED",
512,
NULL,
15,
NULL );
vTaskStartScheduler();


Then I noticed the LED animation play become step-wise, it changes only when getchar() received input from user, instead of a smooth animation.



I've already set LED priority a lot higher, however this didn't fix the halt. Is there anything else that I should configure somewhere?



The code is run on NXP LPC54018 board with MCUXpresso. A similar problem on a different device can be found at https://os.mbed.com/questions/781/Skip-getchar-if-no-input-using-interrupt/










share|improve this question
















I have two functions:



shell() uses getchar() to get user input



playLED() plays a LED animation



I have two tasks running in FreeRTOS



    xTaskCreate(
shell,
"shell",
512,
NULL,
1,
NULL);

xTaskCreate(
playLED,
"playLED",
512,
NULL,
15,
NULL );
vTaskStartScheduler();


Then I noticed the LED animation play become step-wise, it changes only when getchar() received input from user, instead of a smooth animation.



I've already set LED priority a lot higher, however this didn't fix the halt. Is there anything else that I should configure somewhere?



The code is run on NXP LPC54018 board with MCUXpresso. A similar problem on a different device can be found at https://os.mbed.com/questions/781/Skip-getchar-if-no-input-using-interrupt/







freertos






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 29 '18 at 18:02







Suicide Bunny

















asked Oct 27 '18 at 0:08









Suicide BunnySuicide Bunny

142110




142110













  • Can you better describe your environment (CPU, libraries, µC, toolset)? getchar() is not part of FreeRTOS. So only answers specific to your environment can be given.

    – Codo
    Oct 27 '18 at 9:17











  • Thanks for the reply. I am using it with a MCUxpresso on NXP LPC 54018

    – Suicide Bunny
    Oct 29 '18 at 17:59



















  • Can you better describe your environment (CPU, libraries, µC, toolset)? getchar() is not part of FreeRTOS. So only answers specific to your environment can be given.

    – Codo
    Oct 27 '18 at 9:17











  • Thanks for the reply. I am using it with a MCUxpresso on NXP LPC 54018

    – Suicide Bunny
    Oct 29 '18 at 17:59

















Can you better describe your environment (CPU, libraries, µC, toolset)? getchar() is not part of FreeRTOS. So only answers specific to your environment can be given.

– Codo
Oct 27 '18 at 9:17





Can you better describe your environment (CPU, libraries, µC, toolset)? getchar() is not part of FreeRTOS. So only answers specific to your environment can be given.

– Codo
Oct 27 '18 at 9:17













Thanks for the reply. I am using it with a MCUxpresso on NXP LPC 54018

– Suicide Bunny
Oct 29 '18 at 17:59





Thanks for the reply. I am using it with a MCUxpresso on NXP LPC 54018

– Suicide Bunny
Oct 29 '18 at 17:59












2 Answers
2






active

oldest

votes


















1














Does getchar() disable interrupts at all when receiving input? In that case the FreeRTOS scheduler will not be able to run the high priority task.






share|improve this answer
























  • Thanks for the reply. That's what I suspect but I don't know how to fix that. My expectation that the interrupt should be isolated to this task only but somehow it affect everything

    – Suicide Bunny
    Oct 29 '18 at 17:58



















0














I think vTaskDelay(1) in the beginning of the task with getChar will resolve the problem.



Also you can change order of creation of tasks, it can also help.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53017678%2flower-priority-task-with-getchar-halts-higher-task-in-freertos-how-to-fix-th%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Does getchar() disable interrupts at all when receiving input? In that case the FreeRTOS scheduler will not be able to run the high priority task.






    share|improve this answer
























    • Thanks for the reply. That's what I suspect but I don't know how to fix that. My expectation that the interrupt should be isolated to this task only but somehow it affect everything

      – Suicide Bunny
      Oct 29 '18 at 17:58
















    1














    Does getchar() disable interrupts at all when receiving input? In that case the FreeRTOS scheduler will not be able to run the high priority task.






    share|improve this answer
























    • Thanks for the reply. That's what I suspect but I don't know how to fix that. My expectation that the interrupt should be isolated to this task only but somehow it affect everything

      – Suicide Bunny
      Oct 29 '18 at 17:58














    1












    1








    1







    Does getchar() disable interrupts at all when receiving input? In that case the FreeRTOS scheduler will not be able to run the high priority task.






    share|improve this answer













    Does getchar() disable interrupts at all when receiving input? In that case the FreeRTOS scheduler will not be able to run the high priority task.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Oct 27 '18 at 7:04









    stathisvstathisv

    38614




    38614













    • Thanks for the reply. That's what I suspect but I don't know how to fix that. My expectation that the interrupt should be isolated to this task only but somehow it affect everything

      – Suicide Bunny
      Oct 29 '18 at 17:58



















    • Thanks for the reply. That's what I suspect but I don't know how to fix that. My expectation that the interrupt should be isolated to this task only but somehow it affect everything

      – Suicide Bunny
      Oct 29 '18 at 17:58

















    Thanks for the reply. That's what I suspect but I don't know how to fix that. My expectation that the interrupt should be isolated to this task only but somehow it affect everything

    – Suicide Bunny
    Oct 29 '18 at 17:58





    Thanks for the reply. That's what I suspect but I don't know how to fix that. My expectation that the interrupt should be isolated to this task only but somehow it affect everything

    – Suicide Bunny
    Oct 29 '18 at 17:58













    0














    I think vTaskDelay(1) in the beginning of the task with getChar will resolve the problem.



    Also you can change order of creation of tasks, it can also help.






    share|improve this answer




























      0














      I think vTaskDelay(1) in the beginning of the task with getChar will resolve the problem.



      Also you can change order of creation of tasks, it can also help.






      share|improve this answer


























        0












        0








        0







        I think vTaskDelay(1) in the beginning of the task with getChar will resolve the problem.



        Also you can change order of creation of tasks, it can also help.






        share|improve this answer













        I think vTaskDelay(1) in the beginning of the task with getChar will resolve the problem.



        Also you can change order of creation of tasks, it can also help.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 22 '18 at 20:20









        SG92SG92

        416




        416






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53017678%2flower-priority-task-with-getchar-halts-higher-task-in-freertos-how-to-fix-th%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            To store a contact into the json file from server.js file using a class in NodeJS

            Redirect URL with Chrome Remote Debugging Android Devices

            Dieringhausen