Go to Post A winning robot is not a winning robot unless you have winning drivers too. You need the time to develop both. - Jim Zondag [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 07-01-2009, 16:27
Racer26 Racer26 is offline
Registered User
no team
Team Role: Alumni
 
Join Date: Apr 2003
Rookie Year: 2003
Location: Beaverton, ON
Posts: 2,229
Racer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond repute
Help with Timers on PIC18F in C18 (what the 2004-2008 RCs had)

I'm having trouble with this piece of code.

Code:
   	if(sManualUp == 0 && oldManualUp == 1){
		mZEnable = 0;
		mZSleep = 0;
		mXSleep = 1;
		mXEnable = 1;
		mDirection = 1;
		OpenTimer0( TIMER_INT_ON & T0_16BIT & T0_SOURCE_INT & T0_PS_1_1 );
		INTCON2bits.TMR0IP = 1;
		INTCONbits.TMR0IE = 1;
		INTCONbits.GIE = 1;
		INTCONbits.PEIE = 1;
		WriteTimer0(45535);

	}else if(sManualUp == 1 && oldManualUp == 0){
		INTCONbits.GIE = 0;
		INTCONbits.PEIE = 0;
		INTCONbits.TMR0IE = 0;	
		
	}
	oldManualUp = sManualUp;
If I replace the else if with a while(sManualUp == 0){} it works. As soon as I do this, my code runs away. Any ideas? This is on a PIC18F4550, it IS using the USB interface on it.
  #2   Spotlight this post!  
Unread 07-01-2009, 17:33
OScubed's Avatar
OScubed OScubed is offline
Lee Drake, CEO, OS-Cubed Inc.
AKA: Lee Drake
FRC #1511 (Rolling Thunder)
Team Role: Parent
 
Join Date: Mar 2008
Rookie Year: 2006
Location: Rochester, NY
Posts: 156
OScubed has a reputation beyond reputeOScubed has a reputation beyond reputeOScubed has a reputation beyond reputeOScubed has a reputation beyond reputeOScubed has a reputation beyond reputeOScubed has a reputation beyond reputeOScubed has a reputation beyond reputeOScubed has a reputation beyond reputeOScubed has a reputation beyond reputeOScubed has a reputation beyond reputeOScubed has a reputation beyond repute
Send a message via ICQ to OScubed Send a message via AIM to OScubed Send a message via MSN to OScubed
Re: Help with Timers on PIC18F in C18 (what the 2004-2008 RCs had)

Are you sure oldManualUp is intialized? Did you check for nulls? Neither will be true if oldManualUp is uninitialized. sManualUp must be initialized since evaluating it to zero works. Remember that:

variable == Value (any value in cluding zero) will only work if variable is intialized to a value and is non-null.
__________________
Lee Drake, CEO, OS-Cubed, Inc.
Business Mentor - team 1511
Rochester, NY

Building optimal, stable, secure solutions to your business challenges.

  #3   Spotlight this post!  
Unread 08-01-2009, 00:54
Racer26 Racer26 is offline
Registered User
no team
Team Role: Alumni
 
Join Date: Apr 2003
Rookie Year: 2003
Location: Beaverton, ON
Posts: 2,229
Racer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond repute
Re: Help with Timers on PIC18F in C18 (what the 2004-2008 RCs had)

Yeah, thats definitely not the issue, it seems that its somehow running away with the interrupts and jumping to strange spots in the code that it manifestly shouldn't be. Its like the program counter (which gets stored when the interrupt service routine is called) is getting corrupted, and then when it goes to exit the interrupt, it jumps to some invalid location.
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
Help with Kevin Watson's 2008 code 2526 Programming 6 05-02-2008 16:53
Please help. I've had it with this camera Inverted Programming 6 14-01-2007 22:35
What are with the Ls in Kevin's code??!!! HELP!!! RbtGal1351 Programming 2 18-02-2005 16:57
What type of timers for autonomous? thoughtful Programming 1 09-12-2003 02:28
What team had the best human player? charlie_grr General Forum 16 11-06-2003 12:20


All times are GMT -5. The time now is 19:31.

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