So the past couple weeks we've been working on our autonomous code on a test robot. Over this time we've been having problems and wracking our brains about outputs that just don't seem to make sense. I managed to track down at least one of the problems today and it appears to be a compiler bug. This is not a request for help but just trying to inform everyone else of the issue.
If you use the following statement:
Code:
long coeff_1 = 90/2*40;
coeff_1 will equal 8. Now this is obviously not the correct value (it should be 1800). For some reason, the compiler appears to do math in initalization statements (for long's at least) in a 8-bit space (1800 = 8 in an 8-bit space).
If you use this code:
Code:
long coeff_1 = 1800;
it will work correctly.
The long and the short of it is to always do any math out before putting it in the source code. While it's more work for you, it results in correctly generated code.
I'm not sure where to report this bug to Microchip so if anyone knows, please tell me.
Matt