![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
fannylly
Joined: 17 Jan 2005 Posts: 2
|
PIC18F4431 - IC (Input Capture Module) |
Posted: Mon Jan 17, 2005 3:48 am |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Mon Jan 17, 2005 6:25 am |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Mon Jan 17, 2005 9:16 am |
|
|
I am using PIC18F4431 - IC (Input Capture Module)
I will correct it, and let you know the result tomorrow.
I appreciate your help.
Thanks. |
|
![](templates/subSilver/images/spacer.gif) |
fannylly
Joined: 17 Jan 2005 Posts: 2
|
Updated, but still not working. |
Posted: Tue Jan 18, 2005 10:16 am |
|
|
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’. |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|