CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

ADDRESS ERROR TRAP INTERRUPT PIC24H
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Ttelmah



Joined: 11 Mar 2010
Posts: 19540

View user's profile Send private message

PostPosted: Thu Jun 09, 2016 12:39 am     Reply with quote

'RESTART_TRAP_CONFLICT', is what you get, if you don't have a handler for the error. When this happens, the stack/trapaddr is lost.

You need to have the handler:
Code:

unsigned long trapaddr;

#INT_ADDRERR
void ADDRERR_isr(void)
{
#asm
mov w15, w0
sub #38, w0
mov [w0++], w1
mov w1, trapaddr
mov [w0], w1
and #0x7f, w1
mov w1, trapaddr+2
#endasm
clear_interrupt(INT_ADDRERR);
restart_cpu(); //This causes a _software reset_.
}



This then means you then soft reboot, with the value stored in 'trapaddr'.

Then check for 'RESTART_SOFTWARE', and see what is in trapaddr.
younder



Joined: 24 Jan 2013
Posts: 53
Location: Brazil

View user's profile Send private message

PostPosted: Fri Jun 10, 2016 11:15 am     Reply with quote

Hi Ttelmah,

I have the trap routine handler already in my code (Same as yours posted on this tread Fri Jul 24, 2015 1:58 am), except for the two new lines below:

Code:

clear_interrupt(INT_ADDRERR);
restart_cpu(); //This causes a _software reset_.


Without these two lines, the MCU is restarting and calling 'RESTART_TRAP_CONFLICT'.

I'll test it again to see if it will works now.

Thanks buddy
Hugo
_________________
Hugo Silva
younder



Joined: 24 Jan 2013
Posts: 53
Location: Brazil

View user's profile Send private message

PostPosted: Fri Jun 10, 2016 3:31 pm     Reply with quote

Now I have changed my ISR trap handler to:

Code:

unsigned long trapaddr;
#INT_ADDRERR
void ADDRERR_isr(void)
{
#asm
mov w15, w0
sub #38, w0
mov [w0++], w1
mov w1, trapaddr
mov [w0], w1
and #0x7f, w1
mov w1, trapaddr+2
#endasm
clear_interrupt(INT_ADDRERR);
reset_cpu(); //This causes a _software reset_.
}


And I still get 'RESTART_TRAP_CONFLICT', but this time with trapaddr=8C06188D (coud not find this address in the .LST!)

The Point is that if I compile my code with CCS V5.051 there is no trap conflict! .... would that be a compiler (5.059) bug?
_________________
Hugo Silva
younder



Joined: 24 Jan 2013
Posts: 53
Location: Brazil

View user's profile Send private message

PostPosted: Tue Jun 21, 2016 5:29 pm     Reply with quote

Finnaly I've found that the trap conflict was due to a compiler (v5.059) bug when copying an array element from one array to another
when the source is a structure declared as 'const'....

http://www.ccsinfo.com/forum/viewtopic.php?t=55193

This is why I was not able to see the err_addr after mcu is reset.

Hugo
_________________
Hugo Silva
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2, 3
Page 3 of 3

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group