Issue with Command Handling in AVR128DA48 UART Communication

I am using AVR128DA48 microcontroller to control an LED in serial communication. The way I set it up is not complex;
I’m sending ‘ON and ‘OFF commands from a python script over UART to toggle the LED on the microcontroller. Funny how I am encountering an issue where the first command is ignored, but the second one triggers a response.

Here’s what happens:
  • I send ‘ON – the microcontroller does not respond.
  • I send ‘OFF – it responds with ‘LED ON.
  • I send ‘ON again !! – it responds with ‘LED OFF.
It makes me feel like the board is always responding to the previous command, and I don't know why 🥲.

Normally I know microcontroller has simple firmware that reads serial data, processes the ‘ON or ‘OFF commands, toggles the LED accordingly, and sends back a confirmation message like ‘LED ON or ‘LED OFF.

But what could be causing the delay or missed first command that I am facing?

How can I ensure that the board processes the first command correctly and responds immediately?

I made sure to verifying the baud rate and ensuring it matches on both ends as 9600

Even flushing the serial buffer before and after sending commands in the python script.
file0.jpg
Was this page helpful?