Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Problem triggering interrupts for Motion Feedback-Input capture mode module in PIC18F

Status
Not open for further replies.

gonespa

Member level 1
Joined
Sep 10, 2012
Messages
32
Helped
2
Reputation
4
Reaction score
1
Trophy points
1,288
Activity points
1,654
Hi,

I Am trying (for now just using the MPLABX simulator) to trigger an interrupt each time any of the associated PINs (CAP1,2 & 3) changes state.

If I configure the MCU this way:

Code:
TRISAbits.TRISA2 = 1;
    TRISAbits.TRISA3 = 1;
    TRISAbits.TRISA4 = 1;
    
    T5CONbits.TMR5ON = 1; 
    

    CAP1CONbits.CAP1M0 = 0; 
    CAP1CONbits.CAP1M1 = 0;
    CAP1CONbits.CAP1M2 = 0;
    CAP1CONbits.CAP1M3 = 1;

    CAP2CONbits.CAP2M0 = 0; 
    CAP2CONbits.CAP2M1 = 0;
    CAP2CONbits.CAP2M2 = 0;
    CAP2CONbits.CAP2M3 = 1;

    CAP3CONbits.CAP3M0 = 0; 
    CAP3CONbits.CAP3M1 = 0;
    CAP3CONbits.CAP3M2 = 0;
    CAP3CONbits.CAP3M3 = 1; 
 
    
    PIR3bits.IC1IF = 0;
    PIR3bits.IC2QEIF = 0;
    PIR3bits.IC3DRIF = 0;
    
    PIE3bits.IC1IE = 1;
    PIE3bits.IC2QEIE = 1;
    PIE3bits.IC3DRIE = 1; 

    INTCONbits.PEIE = 1; 
    
    INTCONbits.GIE = 1;

The ISR is this one:

Code:
void interrupt isr(void)
{
   
    step();
    
    if (contador == 5)
    {
        contador = 0;
    }
    else
    {
        contador++;
    }
    
    PIR3bits.IC1IF = 0;
    PIR3bits.IC2QEIF = 0;
    PIR3bits.IC3DRIF = 0;
    
}

And then force a PIN change using the stimulus on any of the CAPx pins, I observe that the corresponding PIR3 bit is set, but the ISR is never triggered. I tried with a watchpoint and it is evident too due to the fact that, each time the ISR is triggered the variable "contador" is incremented, something that never happens...

I tried to play changing the order in which each flag is activated with no success. Is anything I am missing?
 

Try the fonction case instade of the fonction if
 

Try the fonction case instade of the fonction if


You mean inside the ISR?. It doesn´t even reach it, it is never executed so I don´t see how that would solve anything...
 

1. Which PIC18F are you using ?
2. Does the Pins you have used for External Interrupt sensing has ADC and Or Comparator functions ?
3. If yes, Have you disabled them ?
 

1. Which PIC18F are you using ?
2. Does the Pins you have used for External Interrupt sensing has ADC and Or Comparator functions ?
3. If yes, Have you disabled them ?

The MCU is the pic18f4431.

When I originaly posted I forgot to set the Pins to Digital (they were in their default status, as Analog). But I recently solved that with no effect. ISR is still not triggered. The code is now like this:

Code:
 TRISAbits.TRISA2 = 1;
    TRISAbits.TRISA3 = 1;
    TRISAbits.TRISA4 = 1;
    ANSEL0bits.ANS2 = 0;
    ANSEL0bits.ANS3 = 0;
    ANSEL0bits.ANS4 = 0;
    
 
    T5CONbits.TMR5ON = 1;       
    
   
    CAP1CONbits.CAP1M0 = 0; 
    CAP1CONbits.CAP1M1 = 0;
    CAP1CONbits.CAP1M2 = 0;
    CAP1CONbits.CAP1M3 = 1;
    CAP2CONbits.CAP2M0 = 0; 
    CAP2CONbits.CAP2M1 = 0;
    CAP2CONbits.CAP2M2 = 0;
    CAP2CONbits.CAP2M3 = 1;
    CAP3CONbits.CAP3M0 = 0; 
    CAP3CONbits.CAP3M1 = 0;
    CAP3CONbits.CAP3M2 = 0;
    CAP3CONbits.CAP3M3 = 1; 
    
    PIR3bits.IC1IF = 0;
    PIR3bits.IC2QEIF = 0;
    PIR3bits.IC3DRIF = 0;
    

    PIE3bits.IC1IE = 1;
    PIE3bits.IC2QEIE = 1;
    PIE3bits.IC3DRIE = 1;      


    INTCONbits.PEIE = 1;     
    

    INTCONbits.GIE = 1;
 

Have you enabled pullups on those Capture pins ? Or do you have pullup resistors on those input pins ?
 
Have you enabled pullups on those Capture pins ? Or do you have pullup resistors on those input pins ?

There is no circuit, I am using the MPLABX simulator. I think there are no internal pullups in PORTA, which is the one linked to the Motion Feedback module
 

It is apparently a limitation of the MPLABX simulator and the PIC18F series. It does not support the Motion Feedback module. Tested in a real circuit and it works.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top