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.

TM4C123GH6PM: Do my while loop is runny slower than my interrupt?

Part Number: TM4C123GH6PM

I am using systic interrupt at 48000Hz,Every time interrupt occur my x2 and x1 values are updated, i have run in to confusion,when i print values on console using 115200 baud rate ,while my UARTprintf statement is inside my while loop,my x1 values are not displayed consequtively but with jumps in it like 12 then 62, but when i use UARTprintf inside my interrupt all values are repeated consequtively.I want to know whether it is problem with UART's speed or is my while loop taking too much time?

when is use UARTprintf("[%i %i] %i \n\n",x2,x1,out); inside while loop

when i use UARTprintf inside interrupt.

my while loop look like this.

  • Hello Muhammad,

    Based on what you are saying, I think you have the interrupt set to be too quick for what you want to do. The interrupt will keep firing and increment as UART communication occurs. UART is much slower than that 48kHz interrupt, so you are having dozens of interrupts occur with each UART transaction and that is why you are skipping values unless you print the UART inside the interrupt which slows it down because it waits for the UART to be finished sending before it allows the next interrupt to trigger.