Pravin Gosavi
Member
Hello I want to generate PWM using ECCP of PIC16F1939 microcontroller. The two pins are supposed to generate waveforms alternately. ( I used pulse steering function of the ECCP module. For sometime the pulses are steered to one pin and for sometime to the other pin. ) The pins sometimes generate the waveform I desire perfectly. But sometimes only one pin generates the waveform and the other shows random noise and a voltage of about 1 to 3 volts.
The pins used are RE1 (P3B) and RB5 (P3A) of ECCP3 module. I have turned comparators off. I have also used APFCON register. I cannot post whole program. Here is some part of initialisation :
After this I have used microC's internal function ADC_Init();
and then infinite while loop.
Any suggestions?
The pins used are RE1 (P3B) and RB5 (P3A) of ECCP3 module. I have turned comparators off. I have also used APFCON register. I cannot post whole program. Here is some part of initialisation :
C:
OSCCON = 0X7A; //16MHZ internal
C1ON_bit = 0;
C2ON_bit = 0; // Disable Comparators
APFCON = 0X50; // Alternate Pin Function
PR2 = 249;
CCP3CON = 12;
CCPR3L = 0;
TMR2IF_bit = 0;
T2CON = 0X04;
while (TMR2IF_bit == 0);
TMR2IF_bit = 0;
LATA = 0X00;
LATB = 0X00;
LATC = 0X00;
LATD = 0X00;
LATE = 0X00;
PORTA = 0X00;
PORTB = 0X00;
PORTC = 0X00;
PORTD = 0X00;
PORTE = 0X00;
TRISA = 0XEF;
TRISB = 0X1F;
TRISC = 0X18;
TRISD = 0X00;
TRISE = 1;
TMR2IE_bit = 1;
GIE_bit = 1;
PEIE_bit = 1;
After this I have used microC's internal function ADC_Init();
and then infinite while loop.
Any suggestions?
Last edited by a moderator: