Page 1 of 1

A question about interrup uart.

Posted: 02 May 2012 20:38
by alcidesramos
Hello . if i configured my uart2 interrup this form:


/ Set interrupt priority levels to 3
U2IP0_bit = 0; // Set UART2 interrupt
U2IP1_bit = 1; // priority level
U2IP2_bit = 1; // to 3

UART2_Init(115200); // Initialize UART2 module
Delay_100ms; // Wait for UART module to stabilize

U2RXIE_bit = 1; // Enable UART Receive Interrupt
EnableInterrupts();


and use this code for vector of interrup.


void interrupt() iv IVT_UART_2 ilevel 7 ics ICS_SRS {
...
U2RXIF_bit = 0; // Clear UART2 RX Interrupt flag
}

my true priority is 3 of 7?

why and can put

void interrupt() iv IVT_UART_2 ilevel 3 ics ICS_SRS {
...
U2RXIF_bit = 0; // Clear UART2 RX Interrupt flag
}

the compiler shoe error.


thank you.


king regard.
Alcides Ramos.

Re: A question about interrup uart.

Posted: 03 May 2012 10:10
by janko.kaljevic
Hello,

To set Interrupt priority to 3 use this:

Code: Select all

/ Set interrupt priority levels to 3
U2IP0_bit = 1; // Set UART2 interrupt
U2IP1_bit = 1; // priority level
U2IP2_bit = 0; // to 3
In order to interrupt work your interrupt level declared in IP bits have to match level declared in ISR.
So in this case your ISR should be:

Code: Select all

void interrupt() iv IVT_UART_2 ilevel 3 ics ICS_AUTO {
...
U2RXIF_bit = 0; // Clear UART2 RX Interrupt flag
}
ICS_SRS priority level have to be 7, and on some PIC32 you can set it's level in Edit Project window.
If the interrupt priority level does not match ICS_SRS level compiler will throw an error.

Best regards.

Re: A question about interrup uart.

Posted: 03 May 2012 16:26
by alcidesramos
Ok but the compiler no permit change the ICS_SRS priority level this option is disabled.

I send picture.

other question. if i have 2 interrup and my ICS_SRS priority level =3.

than i can't do:

void interrupt() iv IVT_UART_1 ilevel 3 ics ICS_AUTO {
...
U1RXIF_bit = 0; // Clear UART1 RX Interrupt flag
}

void interrupt() iv IVT_UART_2 ilevel 7 ics ICS_AUTO {
...
U2RXIF_bit = 0; // Clear UART2 RX Interrupt flag
}

the question is, i cant put two diferrent interrup nivel if have only ICS_SRS set.

Please, help me with this.


King regard.


Alcides Ramos.

Re: A question about interrup uart.

Posted: 04 May 2012 09:26
by janko.kaljevic
Hello,

I said that some of PIC32 can set ICS_SRS level to any. For example PIC32MX795F512L.
Other PIC32 have ICS_SRS level set to 7, and can not be changed by user.

ICS_SRS instructs CPU to use Shadow Register Set. And it will be used only for interrupt which priority level matches shadow set priority.

So the best is to use shadow set for highest priority interrupt. All other interrupts will use primary register set.

Best regards.