I use a 16MHZ ceramic resonator, but I forgot to burn the bootloader before and I uploaded the code directly via USB ASP programmer.
About the code, is quite long to put it completely at the moment.
I noticed that the sequence was very slow. Then, I realised that I had not burned the bootloader before.
I burned it and uploaded the sketch again.
In principle everything was fine at the beginning, but I realised that after a while the light sequence was doing strange things and not what I had put in the code.
I have tried it with another pcb and another atmega, doing the process of burning and uploading using the programmer, and it works fine.
My question is if due to this failure that I had, it could be that internally the atmega328p -au has broken down. And it doesn't run any program properly because of a memory overflow, for example.
And if it can be reset in some way, or if it is necessary to replace it with another one.
do yourself a favour and please read How to get the best out of this forum and modify your post accordingly (including code tags and necessary documentation for your ask).
I would try to bootload it again and reprogram it. Or even program it with an entirely different program.
This very slow working when not bootloaded is known. I had this a few times too, but was always able to bootload and reprogram it.
As the software works on a equal board, there can always be something wrong.... but i doubt it can be caused by programming it prior to bootload.
Problem was in the code (typical mistake of these forum topics...sorry for that).
I explain:
I connect the atmega to a Wireless adapter. So, when the pin is LOW, the Wireless connection with the computer is active.
But, sometimes there is EMIS or readings a little different, even the Wireless adapter can change sometimes a little the voltage of that pin. Then, the connection seems to have disconnected, but not really.
Problem was in the code with the sentence IF.
IF analogRead == 0, then connected
I have changed the sentence:
IF analogRead < 100, then connected
And it works, because the code always executes the correct lines of the IF. And before of that, the code, sometimes executed the lines of the ELSE.