Atmega328P resets with usng of sprintf


I build a small pcb with an Atmega328P. I can run software as far as everyting is ok. I have a convertion with sprintf.

 char formattedCurrent[5];
 actualCurrent = byteAdditional(buf[0], buf[1], buf[2], buf[3]);
 // sprintf(formattedCurrent, "%4dmA", actualCurrent);
 lcd.setCursor(CURSOR_ACTUAL_CURRENT, 1);
 // lcd.print(formattedCurrent);
 lcd.print(actualCurrent );

The value of actualCurrent is between 0 and 4600.
This code works as long as I not use the row with sprintf.

some idea?

char formattedCurrent[5];

  sprintf(formattedCurrent, "%04dmA",


Oh found it:
4000mA\n => 7

char formattedCurrent[7];

works fine now.