Hi,
I work with PIC16F876 and i used timer1 with CCPx in Compare mode.
The problem is when CCP1IE and CCP2IE occurs in the same time.
I have a jitter for this condition and maybe i'll must to created a special condition for this case.
I would like to know if anybody have a solution for my problem.
Thanks by advance.
Regards.
I work with PIC16F876 and i used timer1 with CCPx in Compare mode.
Code:
void init_pic (void)
{
RBPU = 1; // Pull up désactivés
// Timer 0 (8 bits) utilisé pour le wachtdog a 2,3 s.
// T0CS = 0 ; // internal Clock
// PSA = 1 ; // timer0 = Wachtdog
// PS2 = 1 ; // \
// PS1 = 1 ; // => 111 + WDT => 18 ms x 128 = 2,304 s
// PS0 = 1 ; // /
// T0IE = 1;
ADCON1= 6 ; // Passe le port A en mode digital
TRISA = ConfigIOPortA ; // Configuration du port A
TRISB = ConfigIOPortB ; // Configuration du port B
TRISC = 0 ; // Configuration du port C
PORTA = 0x3F ; // Toutes les sorties à 5V
PORTB = 0xFF ; // Toutes les entrées à 5V
PORTC = 0 ; // Toutes les sorties à 0V
GIE = 1; // Valide toutes les interruptions
PEIE = 1 ;
CCP1IE = 1 ; // Interruption en mode comparaison autorisée
CCP2IE = 1 ;
TMR1IE = 1 ; // Interruption du Timer1 autorisée
}
static void interrupt inter(void) // Gestion du timer1 en mode compare
{
if (TMR1IF)
{
RC6 = 1 ;
RC7 = 1 ;
TMR1H = 0xEC ;
TMR1L = 0x77 ;
TMR1IF = 0 ;
}
if (CCP1IF)
{
CCP1IF = 0 ;
RC6 = 0 ;
// CCP1IF = 0 ;
}
if (CCP2IF)
{
CCP2IF = 0 ;
RC7 = 0 ;
// CCP2IF = 0 ;
}
}
void Init_compare (void)
{
{
TMR1H = 0xEC ; //on fixe la fréquence 65535-20000µs/4µs = 0xEC77
TMR1L = 0x77 ;
CCP1CON = 0b00001010 ;
CCP2CON = 0b00001010 ;
T1CON = 0b00100001 ; //Prescaler=1:4 Timer1=on
}
}
void Config_rapport_cycliqueV(unsigned char)
{
unsigned int Val1_tmp ;
Val1_tmp = (139*Vpos)/100 ;
Val1_tmp += 60785 ;
CCPR1L = Val1_tmp ;
CCPR1H = Val1_tmp >> 8 ;
}
void Config_rapport_cycliqueH(unsigned char)
{
unsigned int Val2_tmp ;
Val2_tmp = (139*Hpos)/100 ;
Val2_tmp += 60785 ;
CCPR2L = Val2_tmp ;
CCPR2H = Val2_tmp >> 8 ;
}
The problem is when CCP1IE and CCP2IE occurs in the same time.
I have a jitter for this condition and maybe i'll must to created a special condition for this case.
I would like to know if anybody have a solution for my problem.
Thanks by advance.
Regards.