gnupic: Setting up CCP2 module


Previous by date: 12 Nov 2002 02:29:57 -0000 Re: gpsim - 16F877 - Installation Problem?, Ralf Forsberg
Next by date: 12 Nov 2002 02:29:57 -0000 SDCC and CVS, John Duncan
Previous in thread:
Next in thread:

Subject: Setting up CCP2 module
From: Rick Mann ####@####.####
Date: 12 Nov 2002 02:29:57 -0000
Message-Id: <FA8B564C-F5E5-11D6-8B50-0030657C1C3A@latencyzero.com>

Okay, I'm having the hardest time figuring out PIC16F877 peripherals. 
Every time  I think I've learned how to set them up, they jump up and 
bite me again.

I'm using the CCP2 module on the PIC (pin PortC:1) to decode IR. I have 
an IR detector whose output goes low when there's an IR carrier 
present. I've verified that it's working by using a scope.

However, the interrupt is not happening on capture. Here is the code 
I'm using to set it up:

> 	;	------------------------------------------
> 	;	Set up the CCP2 module
> 	;	------------------------------------------
> 	
> 	bsf		STATUS,RP0			;	Select bank 1
> 	bcf		STATUS,RP1
> 	
> 	bcf		PIE2,CCP2IE			;	Disable the CCP2 interrupt
> 	movlw	b'11000010'			;	PortC outputs 'cept for RX/TX & C:1
> 	movwf	TRISC
>
> 	bcf		STATUS,RP0			;	Select Bank 0
> 	
> 	;	The CCP2 pin is already set as an input
> 	
> 	movlw	b'00000100'			;	Capture every falling edge
> 	movwf	CCP2CON
> 	
> 	movlw	b'00111001'			;	Enable TMR1, internal clock, 1:8 prescale
> 	movwf	T1CON
> 	
> 	bcf		PIR2,CCP2IF			;	Clear the CCP2 interrupt flag
> 	
> 	bsf		STATUS,RP0			;	Select bank 1
> 	bsf		PIE2,CCP2IE			;	Enable the CCP2 interrupt
> 	
> 	bcf		STATUS,RP0			;	Select Bank 0
> 	bsf		INTCON,PEIE			;	Enable peripheral interrupts

Elsewhere in the code I enable general interrupts. I know interrupts in 
general are working, because other interrupts do happen.

So, what am I forgetting? I want a high-to-low transition on RC1/CCP2 
to capture the time value and generate an interrupt. I want Timer 1 to 
be prescaled 1:8, and to increment off the instruction clock.

Thanks in advance!

--Rick



Previous by date: 12 Nov 2002 02:29:57 -0000 Re: gpsim - 16F877 - Installation Problem?, Ralf Forsberg
Next by date: 12 Nov 2002 02:29:57 -0000 SDCC and CVS, John Duncan
Previous in thread:
Next in thread:


Powered by ezmlm-browse 0.20.