We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
2 questions:
1) See http://www.keil.com/support/man/docs/c51/c51_le_bit.htm I don't understand the meaning of the following description. "Functions that disable interrupts (#pragma disable) and functions that are declared using an explicit register bank (using n) cannot return a bit value. The Cx51 Compiler generates an error message for functions of this type that attempt to return a bit type."
Can someone provide more explanagtion and example for my reference ? Thanks!
2) For interrupt, see http://www.keil.com/support/man/docs/c51/c51_le_interruptfuncs.htm "Interrupt function declarations may not include a return value. They must be declared as void (see the above examples). The compiler emits an error message if any attempt is made to define a return value for the interrupt function. The implicit int return value, however, is ignored by the compiler."
Why interrupt function(interrupt service routine, ISR) can not have return value? Should declare as void ?
Can someone tell me why ? Thanks!
About part 2: "Functions that disable interrupts (#pragma disable)"
has nothing to do with the fact that interrupt functions don't return a result. It's about normal functions, that return a value, but shall NOT be interrupted.
See more in http://www.keil.com/support/docs/1700.htm
It is about the temporary interrupt disable, that -by the way- must use the JBC instruction, the only one that can test and reset a bit in one uninterruptable instruction. (atomicy)
In the document you will see that the Carry flag is used to save the previous EA state. Other solutions are possible, but would create larger code. So, now as the carry flag is inside the PSW (as the two register bank flags in the part 1 of your question), the restriction has the same cause, bit functions are not possible, as they also need the carry flag as a return value.
Clear now?
You should have searched simply for "pragma disable" in the Keil pages and could have read it yourself.