TMR1 on PIC18F4550 does not increment

Thread Starter

stasse

Joined Sep 6, 2010
2
Hey all,
i'm trying to set up timer 1 on a pic18f4550 in compare mode with the CCPregisters.

When i simulate i see TMR1L go to 0xFF and then to 0x00 but the upper byte of TMR1 does not increment? I do not know what i'm doing wrong.

I use the pic18f4550, mplab ide environment, c18 compiler en a ICD3 debugger

Here is my setupcode:

Rich (BB code):
void setupTimer()
{
	const tLong constValueForCCPR1 = ((configTICK_TIME	 * (OSC_FREQ / OSC_PER_INST)) / 1000 );	//1000 is om msec van tick_time aan te passen
	tLong valueForCCPR1;
 
	//timecount clearen
	TMR1H = (tByte) 0x00;
	TMR1L = (tByte) 0x00;
 
	//waarde in CCPR1 register steken
	valueForCCPR1 = constValueForCCPR1;
	CCPR1L = ( tByte ) ( valueForCCPR1 & ( tLong ) 0xff );
	valueForCCPR1 >>= (tLong) 8;
	CCPR1H = ( tByte ) ( valueForCCPR1 & ( tLong ) 0xff );	
 
	//Compare mode
	CCP1CONbits.CCP1M0 = SET_BIT;
	CCP1CONbits.CCP1M1 = SET_BIT;
	CCP1CONbits.CCP1M2 = CLEAR_BIT;
	CCP1CONbits.CCP1M3 = SET_BIT;
 
	//alle instellingen qua timer1 en interrupts voor timer1
	PIE1bits.CCP1IE = SET_BIT;		// CCP1 Interrupt Enable
	//IPR1bits.TMR1IP = SET_BIT;		// CCP1 Interrupt Priority High
 
	T1CONbits.TMR1CS = CLEAR_BIT;		// Timer 1 Clock Source Bit -- zero equals internal clock
	T1CONbits.T1CKPS1 =	CLEAR_BIT;		// Prescale value
	T1CONbits.T1CKPS0 = CLEAR_BIT;		// Prescale value
	T1CONbits.RD16 = SET_BIT;			// Enable 16bit mode
 
	T3CONbits.T3CCP2 = CLEAR_BIT;		//Timer3 and Timer1 to CCPx Enable bits
	T3CONbits.T3CCP1 = SET_BIT;			//Timer3 and Timer1 to CCPx Enable bits
 
	T1CONbits.TMR1ON = SET_BIT;			// Timer 1 On Bit
	//freeRTOS gebruikt 	INTCONbits.GIEL  nog, ma ik denk dak die ni moet gebruiken?
 
	//INTCONbits.INT0IE = CLEAR_BIT; //deze regel moet eerder bij startscheduler
	INTCONbits.GIEL = SET_BIT;
 
	//RCONbits.IPEN = 0;
	INTCONbits.GIEH = SET_BIT;
}
does anyone see what i'm doing wrong?
 
Top