Could also be a stack overflow, as (s)printf needs quite a bit of stack space.
Also, as the OP guesses sprintf might be the issue (which is not using termio at all), the usual printf issues might be causing it too.
- non matching arguments to the format
- sprintf (as it is defined by ANSI) does not support to check for destination buffer overflows
- stack space overflows
Also, wondering if in this statement
> The reason is when I remove the sprintf, since it works well.
calls to sprintf only were removed while keeping printf calls, or were both sprintf and printf calls removed?
printf is the only one using termio, so if the issue is with sprintf only, then termio is out of the picture.
I did once post a trivial snprintf version here, but I don't see it attached in this thread
https://community.freescale.com/message/17411#17411
Daniel