First of all, sorry for my english… :(
I have a problem for 6 months that I can not solve.
The project concerns domotics and is a controller of 2-channel for led lights in pwm, rs485 for communication and the possibility to connect a button for direct on/off/dimmer.
The circuit works correctly, the RS485 communication also, the button also.
The problem is that after 1 or 2 days (the time is never the same) atmega328p lose values in the variables and/or in the constants and therefore no longer works anything.
Program don't crash, beacause there is a led blinking every seconds, and it blink forever.
I think the problem is a stack corruption but I can not find where I made some mistakes that damage it.
I've been looking for error in last 6 months but now I have to get to a conclusion.
I add in attachment complete atmel studio solution as it is in multiple files.
I know it will be hard work to analyze my code so if I do not have help it does nothing.
Atmega is ATMEGA328P, running 20Mhz.
If someone needs I can also attach schematic in pdf.
Thank you so much for those who want to help me.