It is currently 23 Feb 2019 14:01

All times are UTC + 1 hour




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: PIC32MZ Interrupt bug
PostPosted: 17 Jan 2019 09:42 
Offline

Joined: 19 Sep 2013 11:36
Posts: 24
Hey, ME Team

We had a big problem with interrupt priorities, they actually never worked. But we found reason and solution

there is asm code

RDPGPR   SP, SP
ADDIU   SP, SP, -16
SW   R30, 12(SP)
MFC0   R30, 12, 2
SW   R30, 8(SP)
MFC0   R30, 14, 0
SW   R30, 4(SP)
MFC0   R30, 12, 0   
SW   R30, 0(SP)
INS   R30, R0, 1, 15 
ORI   R30, R0,5120 // bug; must be: ORI   R30, R30,5120 
MTC0   R30, 12, 0   


Reason why interrupt priorities not work is that every time when interrupt is called, code switches interrupts off so there is on way
that higher priority interrupt will call the handler. After finishing interrupt routine, asm enables interrupts.

We fixed it in asm and proved that priorities work after fix.

ORI R30, R0,5120 // bug; must be: ORI R30, R30,5120


Also, please consider changing help and example files where you sugested to use IRQ priority 7 is not the best idea.
We prefer irq priority 4 as base priority. It gives us a way to use higher or lower priorities than base priority.
Using Priority 7 as base priority gives you no easy way to add something that is higher. Only changing all the code
and facing lot's of code flow logic bugs that are hard to find. Etc you receive something from uart, decided to answer,
but uart tx code uses tx irq with higher priority, it not happens, and code enters deadlock. We had that situation actually


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: