3.6.7 How Do I Fix a “Can’t generate code...” Error?
This is a catch-all message which is generated if the compiler has exhausted all possible means of compiling a C expression, see 10 Error and Warning Messages. It does not usually indicate a fault in your code. The inability to compile the code can be a deficiency in the compiler, or an expression that requires more registers or resources than are available at that point in the code. This is more likely to occur on baseline devices. In any case, simplifying the offending expression, or splitting a statement into several smaller statements, usually allows the compilation to continue. You may need to use another variable to hold the intermediate results of complicated expressions.