Would you like to react to this message? Create an account in a few clicks or log in to continue.

You are not connected. Please login or register

P16F88x - INT and IOCB interrupt service does not work

2 posters

Go down  Message [Page 1 of 1]

Nacho9319



I did a simulation with the PIC16F887 in which I use the external interrupt service (INT) and Interrupt on Change (IOCB) and does not work. I tried with other interrupt service like Timer 0, Timer 1, ADC, UART and works OK.
The circuit has already been tested in other software and even in a physical circuit and works properly, however SimulIDE closes as soon as I run the simulation.
I have already checked the three XML files (_int, _perif and _regs) of p16F88x but I cannot find the problem.

I hope you can help me.
Thanks in advance.
Greetings

arcachofo

arcachofo

Hi.
External interrupts are working for me.
Can you share your circuit and firmware to test it?
And.. which SimulIDE version are you using?

This code works for me:
Code:
// Compiler: Mplabx_xc8  Device: 16f887

#include <xc.h>
#include <pic16f887.h>

void __interrupt() myisr();

// Programa principal
void main(){
    // Configura registradores gerais
    ANSEL  = 0x00;
    ANSELH = 0x00;
    C1ON  = 0;
    C2ON  = 0;
   
    // Configura direcao e valores para entradas e saidas
    TRISB  = 0x03;
    TRISC  = 0x00;
    PORTC  = 0x01;

    // Configura OPTION_REG
    OPTION_REGbits.INTEDG = 1;

    // Configura interrupção externa
    INTCONbits.INTF = 0;
    INTCONbits.RBIF = 0;
    INTCONbits.GIE  = 1;
    INTCONbits.INTE = 1;
    INTCONbits.RBIE = 1;
   
    // Loop infinito
    while (1){
        // if (RB0==0) PORTD ^= 0b00000001;       
    }
}

// ISR
void __interrupt() myisr(){
    //PORTC = 0b00000011;
    if(INTF){
        PORTC ^= 0b00000001;
        INTCONbits.INTF = 0;
    }
    INTCONbits.RBIF = 0;
}

Nacho9319



Of course, thank you.
The version of SimulIDE that I'm using is 1.0.0
My codes are in assembler Pic-As and C. Where can I send you my circuit an firmware?

arcachofo

arcachofo

My codes are in assembler Pic-As and C. Where can I send you my circuit an firmware?
For example Zip the folder containing the project and attach it to a post here (max 50KB).

If it is the first time, here you can see how to attach files:
https://simulide.forumotion.com/t383-how-to-add-pictures-and-attachnents-to-your-posts

Nacho9319



Than you for the tip.
Here you have my files.

Nacho9319



Sorry. Here
Attachments
P16F88x - INT and IOCB interrupt service does not work AttachmentInterruptP16F887.zip
You don't have permission to download attachments.
(14 Kb) Downloaded 3 times

Nacho9319



Thanks to your code, I realized that you do not use the sleep mode in the while loop. In my code I do use it, so I removed it and the simulation now works correctly.
Thank you very much for your help.

arcachofo

arcachofo

Thanks to your code, I realized that you do not use the sleep mode in the while loop. In my code I do use it, so I removed it and the simulation now works correctly.
Ok, sleep is not implemented in 1.0.0.

Your circuit is a bit complex for me to test it correctly.
But in version 1.1.0 PIC sleep is partially implemented.
Maybe it could work in that version.

Links for direct downloads here:
https://launchpad.net/simulide/+download

Nacho9319



I understand. And I'm looking forward to the new version.
Thank you very much for your help!
Greetings!!

arcachofo likes this post

Sponsored content



Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum