PIC32MZ Interrupt Support (SOLVED)

Post here to discuss any new features, components, chips, etc, that you would like to see in Flowcode.
Post Reply
Brendan
Posts: 43
http://meble-kuchenne.info.pl
Joined: Tue Dec 08, 2020 2:12 pm
Has thanked: 35 times
Been thanked: 10 times

PIC32MZ Interrupt Support (SOLVED)

Post by Brendan »

Hi Guys.

The Interrupt component appears to have serious issues with PIC32MZ (and I do take on-board the complexities against other PIC devices - hence avoiding a bug report), though I have many varied applications using this device (specifically - PIC32MZ2048EFG144) for which I'm having to work around the present inability to simply declare an interrupt in the flow and use it - whether UART, timer, etc...etc. Available interrupts do appear in the options list for the component - just that they don't work.

Is it reasonable to request an updated/working interrupt component for the PIC32MZ that will function as seamlessly, or even perhaps a dedicated component if operational parameters need to be uniquely declared?

Many thanks,
Brendan
Last edited by Brendan on Mon Oct 31, 2022 4:59 pm, edited 2 times in total.

Steve-Matrix
Matrix Staff
Posts: 1253
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 167 times
Been thanked: 277 times

Re: PIC32MZ Interrupt Support

Post by Steve-Matrix »

Hi Brendan,

Can you please provide more details of the specific issue(s) you are having, perhaps with relevant examples?

Brendan
Posts: 43
Joined: Tue Dec 08, 2020 2:12 pm
Has thanked: 35 times
Been thanked: 10 times

Re: PIC32MZ Interrupt Support

Post by Brendan »

Thanks Steve - Much appreciated.

It's for professional application and I'm regrettably not at liberty to share my code.

Examples however would be to declare a UART Rx interrupt calling a very simple service routine (e.g. setting a variable), where the program will then refuse to process UART data and hangs the code (in my case).

Another would be to (say) toggle a port bit for a heartbeat LED timer, where timer overflow never appears to call the routine.

Never a problem with 'lesser' devices - just the PIC32MZ2048EFG144 (and doubtless others in this family) that I'm unfortunately wedded to.

I should however add that, with various register settings in C blocks, I've presently got two hardware UARTs solidly running duplex at 115.2 (no flow control), though presently using polling to branch and service Rx buffers, with Rx port bits dynamically enabled/disabled to prevent unserviced buffer overflows.

Registers settings used (not all necessarily required but some hang-overs from debug). Keeping things as simple as possible (and not requiring 200MHz core clock speed), I've simply set the core clock speed to be the same 100MHz as the peripheral bus clocks.

ANSELA = 0x0000;
ANSELB = 0x0000;
ANSELC = 0x0000;
ANSELD = 0x0000;
ANSELE = 0x0000;
ANSELF = 0x0000;
ANSELG = 0x0000;
ADCCON1bits.ON = 0; // disable ADC

// Disable both UARTs before register configuration
U1MODEbits.ON = 0;
U3MODEbits.ON = 0;

// Expressly enable timer interrupts (interrupt issue debug/experimentation)
T1CONbits.ON=1;
T2CONbits.ON=1;
T3CONbits.ON=1;
T4CONbits.ON=1;
T5CONbits.ON=1;
T6CONbits.ON=1;
T7CONbits.ON=1;
T8CONbits.ON=1;
T9CONbits.ON=1;

U1RXR = 0b1010; // Rx on F4
TRISFbits.TRISF4 = 1; // Set F4 as input pin
RPF5R = 0b0001; // Set F5 as ch.1 TxD pin
U1MODEbits.BRGH = 0; // Standard speed mode (i.e. <1.5Mbps)
U1BRG = 100000000 / (16 * 115200) - 1;// This is the formula straight from the datasheet (assumes PBCLK#2 = 100MHz)
U1STA = 0; // Disable the TX and RX pins, clear all flags
U1STAbits.UTXEN = 1; // Enable the TX pin
U1STAbits.URXEN = 1; // Enable the RX pin - dynamically enabled/disabled in the flow to prevent unserviced buffer over-run
U1MODEbits.PDSEL = 0; // PDSEL controls how many data bits and how many parity bits we want, this is the default of 8-bit data, no parity bits that most terminals use
U1MODEbits.STSEL = 0; // STSEL controls how many stop bits used.

U3RXR = 0b0000; // Rx on D3
TRISDbits.TRISD3 = 1; // Set D3 as input pin
RPD2R = 0b0001; // Set D2 as ch.3 TxD pin
U3MODEbits.BRGH = 0; // Standard speed mode (i.e. <1.5Mbps)
U3BRG = 100000000 / (16 * 115200) - 1;// This is the formula straight from the datasheet (assumes PBCLK#2 = 100MHz)
U3STA = 0; // Disable the TX and RX pins, clear all flags
U3STAbits.UTXEN = 1; // Enable the TX pin
U3STAbits.URXEN = 1; // Enable the RX pin - dynamically enabled/disabled in the flow to prevent unserviced buffer over-run
U3MODEbits.PDSEL = 0; // PDSEL controls how many data bits and how many parity bits we want, this is the default of 8-bit data, no parity bits that most terminals use
U3MODEbits.STSEL = 0; // STSEL controls how many stop bits used.

The above settings are then effectively married with Flowcode by including CH1 and CH3 UART components in the dashboard, and "initialised" with the same port settings declared above.

Best regards,
Brendan

BenR
Matrix Staff
Posts: 1739
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 440 times
Been thanked: 603 times

Re: PIC32MZ Interrupt Support

Post by BenR »

Hello Brendan,

This is ringing a bell for me, please can you check that the Boot ISA Selection config setting in Build -> Project Options is set to MIPS32 and not microMIPS. Hopefully that should solve the problem for you.

Brendan
Posts: 43
Joined: Tue Dec 08, 2020 2:12 pm
Has thanked: 35 times
Been thanked: 10 times

Re: PIC32MZ Interrupt Support (SOLVED)

Post by Brendan »

Thank you Ben - What a great call, and words can't express the pain and time your recollection has saved.

Yes, the register was indeed set for microMIPS... Changed, a debug interrupt timer routine added, and working like a charm. Maybe if this could be set to MIPS32 by default...?

This gotcha' permanently committed to grey matter :D

Best regards,
Brendan

BenR
Matrix Staff
Posts: 1739
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 440 times
Been thanked: 603 times

Re: PIC32MZ Interrupt Support (SOLVED)

Post by BenR »

Hi Brendan,

Excellent I'm really glad that solved the problem for you.

Yes good call I'll change the defaults to be the correct MIPS32 setting as it's a right pain to debug.

Post Reply