Skip to main content
Lchal.1
Associate III
February 16, 2021
Question

problem at while loop

  • February 16, 2021
  • 12 replies
  • 2733 views

HI, i am using two timers in interrupt mode by setting 100khz frequency for each . one timer interrupt is for my power factor calculation and other one for current calculation. But the problem is when it comes to while loop. once my code enter into interrrupt functions works fine after coming out of the interrupt it is not entering while loop . and the logic inside the while loop is also not executing. can anyone help me with it please . why i am not able to enter and execute while loop.

Thank you

    This topic has been closed for replies.

    12 replies

    KnarfB
    Super User
    February 16, 2021

    The interrupts are quite frequent @100kHz. Maybe there is no time for the main loop left because one interupot is always pending? Lower the freq. for testing.

    Lchal.1
    Lchal.1Author
    Associate III
    February 17, 2021

    Even if i lower the frequency in one timer to 1khz and other timer as usual 100khz . still its not going to while loop and even it is affecting the other timer which i set to 100khz . can you help me what is the problem in my logic.

    Thank you

    Ozone
    Principal
    February 17, 2021

    We cannot see your code.

    I suggest to add code lines that toggle a GPIOs at the entry and exit of the invovled interrupt routines, and watch them with a scope.

    Supposedly, your interrupts overrun their time slot, at least occasionally. That should show on the scope.

    Ozone
    Principal
    February 18, 2021

    I would start with investigating the reason and location for the hardfault.

    This paper might help: https://www.keil.com/appnotes/files/apnt209.pdf

    Faults after a longer runtime are often stack overflows or race conditions, perhaps interrupt-related.

    Or out-of-bound access through overrun counters/indices.

    Lchal.1
    Lchal.1Author
    Associate III
    February 18, 2021

    Thank you