1
votes

Porting from PIC32MX to MZ (PIC32MZ2048EFG100) and am banging head against wall trying to generate a simple RX interrupt on UART3. Please see code below.

void main(void} {
    __builtin_disable_interrupts();
    //Ensuring all pins config as digital
    ANSELA = 0x0000;
    ANSELB = 0x0000;
    ANSELC = 0x0000;
    ANSELD = 0x0000;
    ANSELE = 0x0000;
    ANSELF = 0x0000;
    ANSELG = 0x0000;

    //Convenient macrso to do IOUNLOCK
    #define PPSUnLock() {SYSKEY=0x0;SYSKEY=0xAA996655;SYSKEY=0x556699AA;CFGCONbits.IOLOCK=0;} 
    #define PPSLock() {SYSKEY=0x0;SYSKEY=0xAA996655;SYSKEY=0x556699AA;CFGCONbits.IOLOCK=1;}

    //Peripheral Pin Select (PPS) Settings for UART3
    PPSUnLock();
    U3RXRbits.U3RXR = 0b1010;
    RPA14Rbits.RPA14R = 0b0001;
    PPSLock();

    //Config UART3
    U3MODEbits.UEN0 = 0;  //no flow control
    U3MODEbits.UEN1 = 0;
    U3MODEbits.LPBACK = 0; // no loopback
    U3MODEbits.ABAUD = 0; //no autobaud
    U3MODEbits.BRGH = 0;
    U3MODEbits.PDSEL0 = 0; //8 data bits, no parity
    U3MODEbits.PDSEL1 = 0;
    U3MODEbits.STSEL = 0; // 1 stop bit

    U3STAbits.URXISEL0 = 0; //RX Interrupt on first byte in FIFO
    U3STAbits.URXISEL1 = 0;

    U3BRG = CLOSEST_UBRG_VALUE115200; //Macro defined elsewhere, but it works

    //Int priorities
    IPC39bits.U3EIP = 6;
    IPC39bits.U3EIS = 3;

    //Int flags
    IFS4bits.U3RXIF = 0;

    //Int enable/disable
    IEC4bits.U3EIE = 0;
    IEC4bits.U3TXIE = 0;
    IEC4bits.U3RXIE = 1; //Enable int on RX

    //Enable multi-vector interrupts
    INTCONSET = _INTCON_MVEC_MASK;
    __builtin_enable_interrupts();

    //Turn on UART3
    U3STAbits.URXEN = 1;
    U3STAbits.UTXEN = 1;
    U3MODEbits.ON = 1;

    UART_txEXTCOMandWait('A'); //Function defined elsewhere - I get successful byte "A" sent to my terminal. So TX works.


    while(1){Nop();}; //wait in endless loop for interrupt to occur on keystroke
}

Below is my ISR:

void __ISR_AT_VECTOR (_UART3_RX_VECTOR, IPL6SOFT) U3Interrupt(void) {
    unsigned int test=0;
    Nop(); //Setting a breakpoint here

}

I successfully see an "A" on my terminal screen when running the program, so settings are correct for TX. Typing in text in my terminal screen yields no interrupts. Have verified with scope that signal is making it to the PIC32.

What am I missing here? I'm burning a ton of time on something that should be trivial.

Thanks guys.

1

1 Answers

1
votes

Figured it out... It should be:

 //Int priorities
 IPC39bits.U3EIP = 6;
 IPC39bits.U3EIS = 3;

Interesting how this had been working in production on PIC32MX for years.