Interrupt priority question

Beta Testing discussion on mikroPascal PRO for PIC32.
Post Reply
Author
Message
Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Interrupt priority question

#1 Post by Dany » 10 Apr 2015 15:19

Hi, I am using the mP for PIC32 compiler (v3.50) with the P32MX534F064H, and I have questions about the (USB) interrupt.

My 1st question (code below is extract from the USB device library examples):

Code: Select all

procedure USB0Interrupt(); iv IVT_USB_1; ilevel 7; ics ICS_SRS; // <---- (1)
  begin
    USBDev_IntHandler();
  end;

...
    IPC11 := dword(7) shl USBIP0; // <---- (2)
    U1IE_bit := 1;
    EnableInterrupts;
...
Why is the setting of the USB interrupt priority is still explicitely beeded - see (2) - while it is already given in the definition of the interrupt procedure - see (1) -.
Is the definition "ilevel 7;" used in any way? I would expect it takes care of the IPC11 content...

Another general (not compiler related, but example related) question: will the statement "IPC11 := dword(7) shl USBIP0" not destroy other settings already made in IPC11?

And last but not least (also not compiler related): I can not find a complete table of interrupt (priority) related registers... Who knows where?

Thanks in advance... :D
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

jpc
Posts: 1986
Joined: 22 Apr 2005 17:40
Location: France 87

Re: Interrupt priority question

#2 Post by jpc » 11 Apr 2015 16:51

the IV, IVLEVEL and ICS only inform the compiler(which uses this information to optimize context saving i suppose) , they do not set anything ( no code is generated ) so we have to set the interrupt priority in our initialisationcode.
Make sure the 2 are identical or you make encounter ( usually nasty) surprises.

Setting these priorities is best done by setting the individual bits, these are all nicely labeled in the definitionfile, for the USB interface they are called USBIPx_bit, for other interfaces these have similar labels.

The documentation of these P32 chips is a bit difficult sometimes, you will have to go through quite some different documents sometimes, for good understanding of all peripherals there are separate documents. These priority registers are documented if i remember well in the general datasheet of the family you use.
Au royaume des aveugles, les borgnes sont rois.

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Re: Interrupt priority question

#3 Post by Dany » 12 Apr 2015 14:44

jpc wrote:the IV, IVLEVEL and ICS only inform the compiler(which uses this information to optimize context saving i suppose) , they do not set anything ( no code is generated ) so we have to set the interrupt priority in our initialisationcode.
Make sure the 2 are identical or you make encounter ( usually nasty) surprises.
Thanks for the explanation!
jpc wrote:Setting these priorities is best done by setting the individual bits, these are all nicely labeled in the definitionfile, for the USB interface they are called USBIPx_bit, for other interfaces these have similar labels.
Yes, indeed.
jpc wrote:The documentation of these P32 chips is a bit difficult sometimes, you will have to go through quite some different documents sometimes, for good understanding of all peripherals there are separate documents. These priority registers are documented if i remember well in the general datasheet of the family you use.
Well, I found out that in the "Family reference" datasheet of PIC32 (section interrupts), and there only the registers "IPCx" are mentioned, wheren "x" is not specified further.
In the datasheet of the "PIC32MX5XX/6XX/7XX" itself I can find all registers actually available, including the "USBIP" bits, residing in "IPC11". For the meaning of the "IPC11" bits I have to go back to the Family reference datasheet...
I expected then in the reference section "USB" a reference to "USBIP", but there was none.

So, it is indeed as you say: one has to look into a lot of documents... :shock:

Thanks for all info and the quick answer! :D
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

Post Reply

Return to “mikroPascal PRO for PIC32 Beta Testing”