pic18f24k20 errata

Thread Starter

bug13

Joined Feb 13, 2012
2,002
Hi guys

I am using this chip pic18f24k20, and I need to use RA3 as input. But if RA3 is pull low, it reset/hang my chip. My code seem to work when RA3 is pull high only.

Unfortunately I can't use other pin as this is the only pin left.

According the errata of this chip, I need to do something with the comparator input (which RA3 shares), I have tried a few thing but can't fix it.

Here is the errata:
Capture.PNG

here is my code:
Code:
    ANSEL = 0x00;          // disable digital input buffer
    ANSELH = 0x00;         // disable digital input buffer

    HLVDCONbits.HLVDEN = 0;     // disable high/low-voltage detection
    SSPCON1bits.SSPEN = 0;      // disable ssp
    CM2CON0bits.C2ON = 0;       // disable comparator 2
    CM1CON0bits.C1ON = 0;       // disable comparator 1
    ADCON0bits.ADON = 0;        // disable ADC

    // these code deal with errata
    // 22. Module: Comparators
    TRISAbits.TRISA3 = 0;       // output
    LATAbits.LATA0 = 1;         // high
    __delay_ms(2);
    TRISAbits.TRISA3 = 1;       // input
    PIE2bits.C1IE = 0;          // diable cm1 interrupt
    PIE2bits.C2IE = 0;          // idable cm2 interrupt
    PIR2bits.C1IF = 0;          // clear cm1 interrupt flag
    PIR2bits.C2IF = 0;          // clear cm2 interrupt flag
 

AlbertHall

Joined Jun 4, 2014
12,347
It doesn't sound like your problem is anything to do with that errata. A good method to get to the bottom of this kind of thing is to create a minimal software and hardware solution just to check RA3 operation. Alternatively, can you use the simulator (perhaps again with the minimal solution) to see what is going on.

For more help here, post schematic and full software.
 

Thread Starter

bug13

Joined Feb 13, 2012
2,002
It doesn't sound like your problem is anything to do with that errata. A good method to get to the bottom of this kind of thing is to create a minimal software and hardware solution just to check RA3 operation. Alternatively, can you use the simulator (perhaps again with the minimal solution) to see what is going on.

For more help here, post schematic and full software.
You are right AlbertHall, it's something wrong with my circuit. My pic is powered from a floating ground (12V - 9V), and there are some transistors on the input to convert the logic level so the pic can take normal TTL input.

What cause the problem is my pull low resistor on the RA3 input, instead of pull it to 9V (what is should be), I pull it to 0V.

It working now, thank you all for your helps!
 
Thread starter Similar threads Forum Replies Date
bug13 Microcontrollers 2
R Programming & Languages 1
Top