lcgamboa / picsimlab

PICsimLab - Programmable IC Simulator Laboratory
GNU General Public License v2.0
442 stars 85 forks source link

PICGenios board with PIC18F4580, crash upon invoking TIMER2. #102

Closed abhishekaudupa closed 5 months ago

abhishekaudupa commented 5 months ago

PICSimLab crashes upon trying to use the TIMER2 module in PICGenios board with PIC18F4580 MCU.

When I initialize the timer2 module and switch the timer on using TMR2ON bit, the program crashes. The line for which PICSimLab crashes is shown below.

#include <xc.h>

    void __interrupt() isr() {
        static unsigned int ctr = 0;
        if (TMR2IF) {
            if (ctr++ == 2500) {
                ctr = 0;
                PORTB = PORTB ^ 1;
            }
            TMR2IF = 0;
        }
    }

    void main(void) {
        TRISB = 0;
        PORTB = 0;

        GIE = 1;
        PEIE = 1;

        TMR2IF = 0;
        TMR2IE = 1;
        PR2 = 125;
        TMR2ON = 1;  //crash (doesn't crash for TMR2ON = 0)

        while (1);
        return;
    }

image image

lcgamboa commented 5 months ago

Hi @abhishekaudupa ,

thank you for reporting the issue. The problem in Picsim was fixed in commit f3cfb55.

abhishekaudupa commented 5 months ago

@lcgamboa Thank you and you're welcome.

lcgamboa commented 5 months ago

Test version with TIMER2 error fixed :PICSimLab_0.9.1_240204_win64_setup.exe