PICKIT WI-Fire PIC32MZ2048EFG100 200MHz IRQ

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

PICKIT WI-Fire PIC32MZ2048EFG100 200MHz IRQ

Post by stefan.erni »

Hi Ben

I change the compiler Option for the PIC32 from your last help.
"Find the part of the Parameters that says -O1 ,Change this to -Os"

After this the IRQ is working, but I can only write 1-4 commands in the IRQ rutine. If I enable the another 2 command the program it not longer running
IRQ_commands.PNG
(12.45 KiB) Downloaded 2651 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: PICKIT WI-Fire PIC32MZ2048EFG100 200MHz IRQ

Post by Benj »

Hello,

This bug is a bit beyond me as I'm not too familiar with the PIC32 range as of yet, I've been posting on the Microchip forum to try and find some answers.

The thread is available here.
http://www.microchip.com/forums/m969350.aspx

Their latest suggestion is to try and add a exception handler. So maybe try adding the following code via the supplementary code window in the project options, change the code in the while loop for a port connected to LEDs to allow you to see the values being generated.

Code: Select all

// declared static in case exception condition would prevent
// auto variable being created
static enum {
    EXCEP_IRQ = 0,            // interrupt
    EXCEP_AdEL = 4,            // address error exception (load or ifetch)
    EXCEP_AdES,                // address error exception (store)
    EXCEP_IBE,                // bus error (ifetch)
    EXCEP_DBE,                // bus error (load/store)
    EXCEP_Sys,                // syscall
    EXCEP_Bp,                // breakpoint
    EXCEP_RI,                // reserved instruction
    EXCEP_CpU,                // coprocessor unusable
    EXCEP_Overflow,            // arithmetic overflow
    EXCEP_Trap,                // trap (possible divide by zero)
    EXCEP_IS1 = 16,            // implementation specfic 1
    EXCEP_CEU,                // CorExtend Unuseable
    EXCEP_C2E                // coprocessor 2
} _excep_code;

static char * ExcepStr[]={
/*00*/    "0x00 IRQ  Interrupt",
/*01*/    "0x01 MOD  TLB Modified",
/*02*/    "0x02 TLBL TLB exception (load or instruction fetch)",
/*03*/    "0x03 TLBS TLB exception (store)",
/*04*/    "0x04 AdEL Address err exception (load or ifetch)",
/*05*/    "0x05 AdES Address err exception (store)",
/*06*/    "0x06 IBE  Bus error (ifetch)",
/*07*/    "0x07 DBE  Bus error (load/store)",
/*08*/    "0x08 Sys  Syscall exception",
/*09*/    "0x09 Bp   Breakpoint exception",
/*10*/    "0x0A RI   Reserved Instruction exception",
/*11*/    "0x0B CpU  Coprocessor Unusable exception",
/*12*/    "0x0C Ov   Arithmetic Overflow",
/*13*/    "0x0D Trap Trap (possible divide by zero)",
/*14*/    "0x0E",
/*15*/    "0x0F FPE  Floating Point exception",
/*16*/    "0x10 IS1  implementation specfic 1",
/*17*/    "0x11 CEU  CorExtend Unuseable",
/*18*/    "0x12 C2E  coprocessor 2",
/*19*/    "0x13 TLBRi TLB Read Inhibit",
/*20*/    "0x14 TLBEi TLB Execute Inhibit",
};
static unsigned int _epc_code;
static unsigned int _excep_addr;
static unsigned int _excep_vaddr;

// this function overrides the normal _weak_ generic handler
void __attribute__((optimize("O0"))) _general_exception_handler(void)
{
    asm volatile("mfc0 %0,$8"  : "=r" (_excep_vaddr));
    asm volatile("mfc0 %0,$13" : "=r" (_epc_code));
    asm volatile("mfc0 %0,$14" : "=r" (_excep_addr));

    _excep_code = (_epc_code & 0x0000007C) >> 2;

	TRISB = 0x0000;

    while (1) {
        PORTB = 0x00;
        delay_s(1);
        PORTB = 0x55;
        delay_s(1);
        PORTB = 0xAA;
        delay_s(1);
        PORTB = _excep_code;
        delay_s(1);
        PORTB = _excep_addr;
        delay_s(1);
    }
}

Let me know how you get on.

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: PICKIT WI-Fire PIC32MZ2048EFG100 200MHz IRQ

Post by stefan.erni »

Hi Ben

Unfortunately, I have not managed that the IRQ works. I'm using the chipkit wi-fire version c.
If I turn off the IRQ the program works. With the IRQ it's hanging.
Attachments
Flowcode_Emg_2018_icsp1.fcfx
(11.63 KiB) Downloaded 221 times

Post Reply