the code is very large. basically what I did is in loop(), I read in the string, break it into parameter tokens for interrupt, function index (will be used for predefined function pointer array) and the mode.
Based on the values of those token I called attachInterrupt(interrupt, FunctPtrs[index], mode);
I found that when I put a set of parameters into com port, the arduino read them off the com port correctly, then it can call attachInterrupt() one by one and post back a string information to let other end know the attachInterrupt() was called. I find that the first call is OK. When the second call the arduino did not post prompt back correctly and it hangs over there.
But when I call attachInterrupt() in setup with same values, I can call many times as I like. Of cause the parameters are predefined instead read from COM port. I checked the parameters read off COM port and print them back, all are correctly read and the values are correct.
static void (*FunctPtrs)();
FunctPtrs = rpm0;
FunctPtrs = rpm1;
FunctPtrs = rpm2;
FunctPtrs = rpm3;
FunctPtrs = rpm4;
FunctPtrs = rpm5;