View Single Post
  #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.