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

PIC24EP512 - Force address trap to get #INT_ADDRERR [CLOSED]

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
benoitstjean



Joined: 30 Oct 2007
Posts: 566
Location: Ottawa, Ontario, Canada

View user's profile Send private message

PIC24EP512 - Force address trap to get #INT_ADDRERR [CLOSED]
PostPosted: Mon Nov 23, 2020 11:02 am     Reply with quote

Device: PIC24EP512GP806
Compiler: 5.026

Hi all.

Quick question: I think I should know this but what's the fastest way to force an address trap to occur so that I get the #INT_ADDRERR interrupt?

I have the code to catch it and display the address, I just want to force it. I thought that if I was to overflow a character string by writing more than it can hold it would cause the interrupt but I doesn't appear to do it.

Thanks!

Ben


Last edited by benoitstjean on Mon May 17, 2021 1:03 pm; edited 3 times in total
temtronic



Joined: 01 Jul 2010
Posts: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Nov 23, 2020 11:08 am     Reply with quote

Fastest way ? Have ME program the PIC.....sigh...

Honestly, what's the datasheet say as to what really causes the action to happen ? I'm betting somewhere in the 800+ pages, it 'might' say.

Be nice, I got 4" (10 centimeters) of wet, heavy 'white stuff' here to deal with....

Jay
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: PIC24EP512 - Force address trap to get #INT_ADDRERR
PostPosted: Mon Nov 23, 2020 1:17 pm     Reply with quote

benoitstjean wrote:

Quick question: I think I should know this but what's the fastest way to force an address trap to occur so that I get the #INT_ADDRERR interrupt?

See FvM's post:
http://www.ccsinfo.com/forum/viewtopic.php?t=36479
Ttelmah



Joined: 11 Mar 2010
Posts: 19515

View user's profile Send private message

PostPosted: Tue Nov 24, 2020 4:11 am     Reply with quote

The PIC does not have hardware bounds checking.
If you want to bounds check for the array limits you have to do this
yourself. The address error trap occurs if you (for example) attempt to
perform a word access to a location on an odd memory address.

In fact array overflows can do some very nasty things resulting in a complete
processor hang. For example:
Code:

int16 array[16];
int16 ctr;

//Then execute
   for (ctr=0;ctr<20;ctr++)
      array[ctr]=0x00;

//will probably never exit!....

What happens is that the default memory allocation will be for 'ctr' to
be held in the locations immediately after 'array'. So when ctr gets to 16
it overwrites the value held in ctr!. This then sets ctr to 0, so it then clears
the same area of memory again. When ctr gets to 16, the same happens
again. Result a complete hang of the code.... :(

In fact hardware bounds checking settable to limit to an array is almost
unheard of. Even on processors with hardware memory managers the
limits are set to the area 'owned' by the process, not the bounds of
a single array. So the same sort of overflow can still happen without a
hardware error.
benoitstjean



Joined: 30 Oct 2007
Posts: 566
Location: Ottawa, Ontario, Canada

View user's profile Send private message

PostPosted: Sun Nov 29, 2020 8:10 am     Reply with quote

Ok, thanks guys. I was able to get the code to crash with the error by using pointers. I tested what I wanted to test.

Thanks!

Ben
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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