Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Compiler has troubles with structures? (http://www.chiefdelphi.com/forums/showthread.php?t=44496)

steven114 21-02-2006 15:33

Compiler has troubles with structures?
 
I've been having the strangest problems - my code has random issues. Sometimes the printf() calls don't substitute variables at all (for example, if I
Quote:

printf("(%d,%d): %d"...
it would print
Quote:

(,):
. Other times, the exact same code with no modifications will print out whatever it is I'm trying to print just fine (ex: (254,254): 127) or something. I don't understand why it prints out a blank space - even if I'm passing something incorrectly, it would print a 0 or an extremely large number. Why would it be blank? Also, whenever this event happens, the PWM outputs go crazy. It starts spitting out either full forward, full reverse, or something in between (even if the last line in the code sets it to 127). The ADCs stop working properly (Get_Analog_Value returns something above 3000) and sometimes upon downloading code, it just crashes and sits in program mode (even after a reset, it won't leave program mode...)

I'm not using interrupts, no pointer arithmetic, and I even disabled the timers. What I found was that by rearranging the order of my code (switching two lines, etc) I could affect exactly what got corrupted. A friend of mine a couple of years ago told me that the MCC compiler generates incorrect code when it uses structures (which I use for my PID control) and commenting out the structures seems to cause the problems to disappear. Does anyone know of some such issues, or any clue what might be wrong? I can post some code snippets a bit later today (when I get to my laptop) or just email you the entire thing, if you're interested... it's very strange, and I worked on it for probably nineteen hours straight, yesterday, without making much headway on this.

Thanks for any pointers,
Steven

devicenull 21-02-2006 18:28

Re: Compiler has troubles with structures?
 
I have not seen this problem.. and all my code uses two large structures to control everything. What you may want to try is turning optimizations off (Project->Build Options-> MCC18 Compiler)


All times are GMT -5. The time now is 03:18.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi