ECCP Pin do not work sometimes on my PIC microcontroller

Status
Not open for further replies.
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 :
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:
Have you checked the erratas for the micro in question? When I download the manual, immediately after, the erratas follow.

In all micros I looked at, comparators appear mentioned. Have you also verified what other functions those pins are involved with?

Make sure you initialize just the minimum necessary to verify how the EECP works. When a new piece of code is added you could eventually detect the offending setting.
 
PWM reset??? This chip has an auto reset when used in enhanced mode!
 
My program is large so it will be a very lengthy process. But I will try it lastly.

It's not something silly like the WDT resetting the chip?

Mike.
All other functions like reading ALL ADC pins working. I think they would not work in such a small time slot.

PWM reset??? This chip has an auto reset when used in enhanced mode!
What is the fix to it? Which register settings?
 
What is the fix to it? Which register settings?
CCPxAS register..
 
I have configured CCPxAS register too as-
CCP3AS= 0b01000000
I have tested this when there's Logic 0 on INT Pin all pwm pins are in shutdown mode.
In shuddown mode also the "affected" pin shows random voltage.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…