I had searched in the Discussion Forum for the whole moring but I couldn't find the right way to solve the problem I met,so I send this message hoping you guys can help me!Thanks in advance:-)My problem is as follows: 1.I want to define a macro,which is similar like function.It will be used in my communction interrupt service routine(so you can see that why I don't choose to call a function to realize it) 2.here's the definition of this macro: #define Macro_TestRxEnd(sbit Header_flag,uchar Header,uchar Tailer) \ { \ Return_flag = 0; \ if (!Header_flag) \ { \ if (Rxbuf == Header) \ { \ Header_flag = 1; \ ptRxBuf++; \ } \ else \ { ptRxBuf = xBuf; } \ else \ { \ if (Rxbuf == Tailer) \ { Return_flag = 1; } \ } 3.then the compile result is : Error C304: Bad Macro Parameter List so can anyone help me find out the right way to define such a long macro? I'm waiting for your good ideas earnestly!
:-)special thanks to Dan and Andy for shareing your experience to me and other friends,you both have a kind heart and a preciseness attitude toward work[from Andy's saying that he do mind even for 1minute,so I guess you are preciseness :-) Just as the Chinese ancient proverb say: Among any three people walking, I will find something to learn for sure.Today I learn a lot from you.And I've accepted Andy's strong advice that not to use macor in this condition.As to the point: but all messages have the same format, I presume: 1. A header; 2. a body; 3. a tail. I would structure the ISR on this basis, rather than try to detect each message type independently... The ISR need to tell the main program which frame is received now,that is to return relative flags, so if not detect each message type independently,how can the ISR translated frame message to main program? By your way,the ISR can only tell the main program that a total frame is received,but the main has to test the rxbuf(header) again to find out the kind of frame. During this weekend I can't come here to read the later responses and write back,so please allow me to reply next Monday:-)Wish you all have a good weekend!
"By your way,the ISR can only tell the main program that a total frame is received" Not true. The code I posted was just an idea of an outline; you need to fill in the details - including how to integrate it with the rest of your system For example, You could make the msg_type variable public...? No doubt you will also need to add other stuff shared between the ISR and the main code... Don't forget that 'volatile' keyword...!!
Today I've re-organized my uart-isr program on the base of the above good advice,and I get many useful ideas from this message,thank you all:-)