View previous topic :: View next topic |
Author |
Message |
benoitstjean
Joined: 30 Oct 2007 Posts: 566 Location: Ottawa, Ontario, Canada
|
PIC24EP512 - Force address trap to get #INT_ADDRERR [CLOSED] |
Posted: Mon Nov 23, 2020 11:02 am |
|
|
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: 9243 Location: Greensville,Ontario
|
|
Posted: Mon Nov 23, 2020 11:08 am |
|
|
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
|
Re: PIC24EP512 - Force address trap to get #INT_ADDRERR |
Posted: Mon Nov 23, 2020 1:17 pm |
|
|
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: 19539
|
|
Posted: Tue Nov 24, 2020 4:11 am |
|
|
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
|
|
Posted: Sun Nov 29, 2020 8:10 am |
|
|
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 |
|
|
|