My code is for serial communication and led blinking using timer interrupt, where led is toggle at a fix interval of time with some line prints on serial terminal and for fix time i have used timer.
Scenario:
I am sending data "while" on the serial terminal in continuous manner and when timer is expired, interrupts occurs and my led toggles with again serial data "RED LED blinked for 500 ms" on terminal. Ideally this timer function should get called only when timer get expired and rest of the time my while loop should execute and while loop data should be printed on the terminal. But this is not happening, the serial prints are not like as it should be printed.
Let me know what is the actual reason behind this.
I have changed baud-rate(115200 to 9600), and output was quite similar. But if u print only 'w' instead of "while" then also behaviour is similar, but timer "RED LED blinked for 500 ms" prints 2 times. Not getting clear idea where timer is busy for this behavior.
Below is my code:
define d9 "while\r\n"
int main(void) {
//Serial Communication Inilization done
//Timer Initialization done
while (1)
{
// This line prints continuously on the terminal
LPUART_DRV_SendDataPolling(INST_LPUART1, (uint8_t *) d9, strlen(d9));
}
}
Actual Output:
...
while
while
while
wRED LED blinked for 500 ms
hRED LED blinked for 500 ms
iRED LED blinked for 500 ms
lRED LED blinked for 500 ms
eRED LED blinked for 500 ms
while
while
...
Expected Output:
...
while
while
while
RED LED blinked for 500 ms
while
while
...