SoftwareSerial changing speed unexpectedly

I even do the following test:

This is working:

#define READ_SMS "AT+CMGR=1"

//char buffer[32];
//sprintf(buffer, "%s%d", READ_SMS, index);
gsm_send( READ_SMS , answer, index);

This is not working

#define READ_SMS "AT+CMGR=1"

char buffer[32];
sprintf(buffer, "%s%d", READ_SMS, index);
gsm_send( READ_SMS , answer, index);

While:

  • buffer is not used in the function call
  • buffer is large enough to perform the sprintf with no buffer overflow