Address Traps, General

General discussion on mikroPascal PRO for dsPIC30/33 and PIC24.
Post Reply
Author
Message
JimKueneman
Posts: 417
Joined: 10 Jan 2009 22:03

Address Traps, General

#1 Post by JimKueneman » 10 May 2011 04:10

Let me ask this a different way. What is the most common cause of Address Traps? This problem is driving me nuts. I am using a 30F4013. There does not seem to be any consistent way to reproduce the issue. It sometimes will enter the trap interrupt after a few seconds (rare) and sometimes it will take hours. There is not one particular sequence of events that fires it off.

I am making use of heavily nested interrupt priorities but I am following the recommended silicon bug workaround in the errata sheet.

Example:

Code: Select all

  {$IFDEF FIX_NESTED_INTERRUPT_SILICON_BUG} asm DISI #4; end; {$ENDIF} // Silicon Bug in the 4013, if Interrupt is disabled, then Interrupt 2 of higher priority is called (nested) an Address Trap can be thrown
  T4IE_bit  := 0;            // Disable the interrupt
  T4IF_bit := 0;             // Reset the Interrupt flag
The occurrence is not better or worse with or without this fix.

It is a fairly complicated program, using currently 75% of the 32k.

Thanks for any help.
Jim

JimKueneman
Posts: 417
Joined: 10 Jan 2009 22:03

Re: Address Traps, General

#2 Post by JimKueneman » 10 May 2011 06:22

I think I found it. I have an array of Pointers to record structures that is 1..31 long. I was guarding against the lower side being greater than 0 but not above 31. I later defined $FE as being "Empty" so I was trying to pull a pointer from the array at index $FE..... :oops: It appears to randomly have been stepping on memory it did not own. I have now run it through a stress test that would guarantee a trap somewhere in the second run. I am now working on my third run through the stress test without a hint of a problem :D

Jim

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

Re: Address Traps, General

#3 Post by jpc » 10 May 2011 07:05

Jim,

thanks for sharing this, very important to see this sort of issue explained and resolved, without that there always remains some suspicion on the compiler. you took it away by posting your mistake like we all make them occasionally ( they are the hardest to discover btw)
Au royaume des aveugles, les borgnes sont rois.

JimKueneman
Posts: 417
Joined: 10 Jan 2009 22:03

Re: Address Traps, General

#4 Post by JimKueneman » 10 May 2011 13:11

jpc,

Yes, I did find an address calculation problem that caused Address Traps in an earlier version of mP using records so that thought was definitely in the back of my mind. The difference was that one was deterministic, it always failed at a particular point.

BTW I ran it through 6 stress tests last night and some other testing and have not seen a Trap since fixing this. I am very confident that was it.

Jim

Post Reply

Return to “mikroPascal PRO for dsPIC30/33 and PIC24 General”