Just a few notes.
First, please don't cross post, otherwise different people will answer the same questions without knowing from each other and that just wastes time.
And now to the question. The best advice is to do as little computation in the interrupt as possible.
So can you not change the code so it does the int to string conversion outside of it?
Calling sprintf or doing that conversion in the interrupt handler will probably take quite a while and therefore delay other interrupts.
So don't use sprintf. It's an advanced ANSI function, dangerous to use, many traps which are not detected at compile time.
If you really want to use it, things to look out
- in
http://forums.freescale.com/freescale/board/message?board.id=CW816COMM&message.id=3902#M3902>"sprintf(str, "%s", 4);"
%s expects a string. %i or %u are for ints.
- I think the library provided sprintf is not thread safe out of the box, so in order to use it in a interrupt handler
you have to change libdefs.h and recompile the ANSI lib. (advanced, recommendation: don't use sprintf in interrupt handlers :smileywink: )
- sprintf needs a lot of stack, more than usually given. Calling sprintf from within an int handler means: your app needs more than twice the amount of a single sprintf call. Be really careful with the stack size.
So best is if you can move your computations out of the int handler. If not, do the computation with a special purpose int to string conversion routine.
Daniel