Go to Post "You know you're a robotics kid when you sit on Chief Delphi and hit refresh over and over again waiting for new pictures and videos of other teams" - pwnageNick [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 21-02-2006, 15:33
steven114 steven114 is offline
Programming Wizard and Team Captain
AKA: Steven Schlansker
FRC #0114 (Eaglestrike)
Team Role: Programmer
 
Join Date: Feb 2004
Location: Los Altos, CA
Posts: 335
steven114 is a jewel in the roughsteven114 is a jewel in the roughsteven114 is a jewel in the rough
Send a message via AIM to steven114
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
__________________
Shift to the left, shift to the right!
Pop up, push down, byte, byte, byte!
  #2   Spotlight this post!  
Unread 21-02-2006, 18:28
devicenull devicenull is offline
Robot? We need a robot?
no team
 
Join Date: Sep 2004
Rookie Year: 1234
Location: n/a
Posts: 359
devicenull is just really nicedevicenull is just really nicedevicenull is just really nicedevicenull is just really nicedevicenull is just really nice
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)
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
I need a easy & free c compiler aksimhal Programming 7 31-01-2006 22:05
C18 Compiler v.3.00 Problems prograid Programming 6 10-01-2006 22:10
C18 v2.4 compiler location b_mallerd Programming 1 14-12-2005 16:43
IMPORTANT regarding the new C Compiler dlavery General Forum 12 14-01-2005 05:05


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

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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