UPDATE: I think I found the reason of the issue.
If I remove WHICHEVER function the melody just repeat once, so the problem is solved!
For example when I remove the two PWM declarations (PWM_Init, PWM_Set_Duty and PWM_Start) the melody infinite repetition doesn't occurs!
So i tried adding those functions later, inside the "while(1)" cycle, but the problem returns...
Maybe is a memory problem, or a CPU issue, I don't know exactly. I think so because WHATEVER big function I remove the problem is solved (for example if I remove the void interrupt() function or the int RGB() function the problem doesn't occur).
But RAM is just 18% used and ROM just 30%, that I can read on the compiler log...
Do you know how I can work around the problem? Maybe with some code simplification (removing useless routines)?