CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

PIC18F4431 - IC (Input Capture Module)

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
fannylly



Joined: 17 Jan 2005
Posts: 2

View user's profile Send private message

PIC18F4431 - IC (Input Capture Module)
PostPosted: Mon Jan 17, 2005 3:48 am     Reply with quote

For the IC (Input Capture) module, I tried to capture RC receiver signal (pulsewidth),
i.e 1.15ms to 1.85ms, and the signal repeats every 20ms (50Hz)

1. If there is any pulsewidth capture, the IC1IF will be set, am I right?
2. And the value of the TMR5 will be latched into CAP1BUF register, am I right?

Below is my short code to capture the pulsewidth; (CAP mod: 0111, capture every rising to falling edge)

ORG 0X20
MAIN MOVLB 0X0F ;SELECT BANK 15
MOVLW B'01010001' ;TIMER 5 PRESCALER 1:4
MOVWF T5CON
MOVLW 0X00
MOVWF INTCON ;disable all interupt
MOVLW 0X02
MOVWF IPR3 ;IC1 HIGH PRIORITY
BSF TRISA,2 ;SET CAP1 AS INPUT
BCF PIR3,IC1IF ;CLEAR INTERRUPT FLAG
MOVLW 0X00
MOVWF CAP1CON
MOVLW B'00000111' ;SELECT MODE,every rising to falling edge
MOVWF CAP1CON

;TEST WHETHER ANY VALUE HAS BEEN CAPTURED
LOOP BTFSS PIR3,IC1IF ;VALUE CAPTURED?
GOTO $-2

MOVLW 0X00
MOVWF TRISC
BSF PORTC,4

END

1. Why there is no change at the IC1IF bit?
2. Is there anything I missed to configure that make my program not working?


For your information, the high signal RC signal to the CAP1 is 5V and low is 0V

Note: I confirm the input signal to CAP1 is correct because I check the signal on the oscilloscope. I manage to capture the RC receiver pulsewidth using CCP module, from that I then generate PWM using the ‘Power Control PWM module’.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Mon Jan 17, 2005 6:25 am     Reply with quote

Quote:
1. Why there is no change at the IC1IF bit?
2. Is there anything I missed to configure that make my program not working?
You are not enabling the IC1 interrupt (a write to PIEx is missing).

Which processor are you using?

As a note:
Code:
MOVLW 0X02
MOVWF IPR3 ;IC1 HIGH PRIORITY
You are not using the interrupts, so setting the interrupt priority is not required.
Guest








PostPosted: Mon Jan 17, 2005 9:16 am     Reply with quote

I am using PIC18F4431 - IC (Input Capture Module)

I will correct it, and let you know the result tomorrow.

I appreciate your help.

Thanks.
fannylly



Joined: 17 Jan 2005
Posts: 2

View user's profile Send private message

Updated, but still not working.
PostPosted: Tue Jan 18, 2005 10:16 am     Reply with quote

I have added " BSF PIE3,IC1IE"
But it still not working.
Please advise.

ORG 0X20
MAIN MOVLB 0X0F ;SELECT BANK 15
MOVLW B'01010001' ;TIMER 5 PRESCALER 1:4
MOVWF T5CON
MOVLW 0X00
MOVWF INTCON ;disable all interupt
MOVLW 0X02
MOVWF IPR3 ;IC1 HIGH PRIORITY
BSF TRISA,2 ;SET CAP1 AS INPUT
BCF PIR3,IC1IF ;CLEAR INTERRUPT FLAG
MOVLW 0X00
MOVWF CAP1CON
MOVLW B'00000111' ;SELECT MODE,every rising to falling edge
MOVWF CAP1CON
BSF PIE3,IC1IE


;TEST WHETHER ANY VALUE HAS BEEN CAPTURED
LOOP

BTFSS PIR3,IC1IF ;VALUE CAPTURED?
GOTO $-2
MOVLW 0X00
MOVWF TRISC
BSF PORTC,4

END

1. Why there is no change at the IC1IF bit?
2. Is there anything I missed to configure that make my program not working?


For your information, the high signal RC signal to the CAP1 is 5V and low is 0V

Note: I confirm the input signal to CAP1 is correct because I check the signal on the oscilloscope. I manage to capture the RC receiver pulsewidth using CCP module, from that I then generate PWM using the ‘Power Control PWM module’.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group