mnsp90
Newbie level 4
- Joined
- May 22, 2014
- Messages
- 6
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 76
HI all,
I am working on a display card based on PIC16F877A for a ups system.
In that all the input and output voltages and currents are measured using timer1 interrupt.
But to measure input and output frequency I am using CCP module.
But here I am facing an issue. When I write code for both CCP1 and CCP2 modules, Only one of them is working and the other is not at all working.
Since I have used interrupt for measuring voltages and currents I have not used CCP interrupt. I am just monitoring CCPIF and once it is set I am storing the CCPR value in a variable and disabling the CCPIF flag. the code for frequency measurement I am using is shown below.
IN that code only CCP1 is working and CCP2 is not working.Can anyone please let me know the mistake??
And also Can We use 2 interrupt service routines here? If yes how can we differentiate them??
I am working on a display card based on PIC16F877A for a ups system.
In that all the input and output voltages and currents are measured using timer1 interrupt.
But to measure input and output frequency I am using CCP module.
But here I am facing an issue. When I write code for both CCP1 and CCP2 modules, Only one of them is working and the other is not at all working.
Since I have used interrupt for measuring voltages and currents I have not used CCP interrupt. I am just monitoring CCPIF and once it is set I am storing the CCPR value in a variable and disabling the CCPIF flag. the code for frequency measurement I am using is shown below.
IN that code only CCP1 is working and CCP2 is not working.Can anyone please let me know the mistake??
And also Can We use 2 interrupt service routines here? If yes how can we differentiate them??
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 if(PIR1bits.CCP1IF) { PIR1bits.CCP1IF=0; out_prd1 = CCPR1; } if(PIR1bits.CCP1IF) { CCP1CON=0x00; out_prd = CCPR1-out_prd1; temp = out_prd>>2; F_out = TIMERFREQ/temp; //F_out = F_out>>3; out_prd1=CCPR1; } if(PIR2bits.CCP2IF) {PIR2bits.CCP2IF=0; in_prd1= CCPR2; } if(PIR2bits.CCP2IF) { CCP2CON=0x00; in_prd = CCPR2-in_prd1; temp1 = in_prd>>2; F_in = TIMERFREQ/temp1; //F_in = F_in>>3; in_prd1=CCPR2; }
Last edited by a moderator: