Causing a Trap effect for Address Error

Post your requests and ideas on the future development of mikroPascal for dsPIC30/33 and PIC24.
Post Reply
Author
Message
kingGrey
Posts: 158
Joined: 08 Mar 2007 00:40
Location: portland, OR

Causing a Trap effect for Address Error

#1 Post by kingGrey » 03 Oct 2007 00:31

Hi there,


I have tried to create an address trap scenario, but I have been unsuccessful. I might be doing something wrong... I was however able to use the Math error trap and I see how that works.

Could someone please show me a sample code for doing this for address Error trap.
this is the trap function i have:

Code: Select all

                         'Addr ERR
Sub procedure TrapTrap1  org $0008
  INTCON1.3 = 0
  LATB = $A0A0
  asm
     MOV [w15 - 32],w13
     MOV w13 LATD
  end asm
   Uart2_write_Text("ADDR ERROR" +  chr(13) + chr(10))
End Sub
but somehow its not being triggered....

Help Please
Thank You for your help
An expert is a man who has made all the mistakes which can be made, in a narrow field.
http://www.stevenswater.com/catalog/stevensProductdl3000.aspx?SKU=%2793750%27

User avatar
zristic
mikroElektronika team
Posts: 6608
Joined: 03 Aug 2004 12:59
Contact:

Re: Causing a Trap effect for Address Error

#2 Post by zristic » 03 Oct 2007 07:46

kingGrey wrote:

Code: Select all

                         'Addr ERR
Sub procedure TrapTrap1  org $0008
  INTCON1.3 = 0
  LATB = $A0A0
  asm
     MOV [w15 - 32],w13
     MOV w13 LATD
  end asm
   Uart2_write_Text("ADDR ERROR" +  chr(13) + chr(10))
End Sub
You are missing a coma character in the second asm line, between W13 and LATD.

In order to trigger the trap you have to perform word access to an odd address, something like this:

Code: Select all

asm
  mov #123, w0
  mov [w0], w1
end asm
There are also other situations which cause address trap, for more information see the document titled "dsPIC30F Family Reference Manual", Chapter 6.2.2.2.

kingGrey
Posts: 158
Joined: 08 Mar 2007 00:40
Location: portland, OR

#3 Post by kingGrey » 03 Oct 2007 19:23

Thanks for your help, i appreciate it
Thank You for your help
An expert is a man who has made all the mistakes which can be made, in a narrow field.
http://www.stevenswater.com/catalog/stevensProductdl3000.aspx?SKU=%2793750%27

Post Reply

Return to “mikroPascal for dsPIC30/33 and PIC24 Wish List”