A question about interrup uart.

General discussion on mikroC PRO for PIC32.
Post Reply
Author
Message
alcidesramos
Posts: 272
Joined: 17 Feb 2009 02:39
Location: Colombia
Contact:

A question about interrup uart.

#1 Post by alcidesramos » 02 May 2012 20:38

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.

User avatar
janko.kaljevic
Posts: 3565
Joined: 16 Jun 2011 13:48

Re: A question about interrup uart.

#2 Post by janko.kaljevic » 03 May 2012 10:10

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.

alcidesramos
Posts: 272
Joined: 17 Feb 2009 02:39
Location: Colombia
Contact:

Re: A question about interrup uart.

#3 Post by alcidesramos » 03 May 2012 16:26

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.
Attachments
Captura.JPG
Captura.JPG (16.27 KiB) Viewed 2387 times

User avatar
janko.kaljevic
Posts: 3565
Joined: 16 Jun 2011 13:48

Re: A question about interrup uart.

#4 Post by janko.kaljevic » 04 May 2012 09:26

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.

Post Reply

Return to “mikroC PRO for PIC32 General”