![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
benoitstjean
Joined: 30 Oct 2007 Posts: 553 Location: Ottawa, Ontario, Canada
|
PIC24EP512 - Force address trap to get #INT_ADDRERR [CLOSED] |
Posted: Mon May 17, 2021 1:07 pm |
|
|
Compiler: 5.024
Device: PIC24EP512GP806
Hi again,
Had this topic opened a while back ( http://www.ccsinfo.com/forum/viewtopic.php?t=59058&highlight=intaddrerr ) but finally, Ttelmah's code example from that thread didn't generate the interrupt and I managed to solve the issue by finding the cause of the crash.
But now I am trying to find a way to force the code to crash with an #INT_ADDR interrupt and for the life of me, I can't!
Anyone has any simple loop code (tested and working) I can try to make this thing crash with that specific interrupt?
Thanks!
Ben
Last edited by benoitstjean on Tue May 25, 2021 11:33 am; edited 1 time in total |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19369
|
|
Posted: Tue May 18, 2021 12:17 am |
|
|
The example I gave, I said would 'probably' lock, not cause a trap
error. The point is that this will fail if (and only if), the counter is held in
the bytes immediately after the array. It won't though cause an address
trap. The easiest way to cause an
address trap, is to do an int16 access to an odd byte address. So:
Code: |
unsigned int8 * pointer;
unsigned int16 array[] = {0, 1, 2, 3, 4];
int16 val;
pointer=&array[0]; //This will be an even address
//so we now have a byte pointer into an int16 array.
//Now increment the byte pointer, so it is to an odd address
//since it is a byte pointer, it allows us to increment it by one.
pointer++;
//Now do an int16 access to this:
val=*(int16 *)pointer;
|
This will cause a trap error, since using the pointer as a pointer to an
int16, makes the compiler use 'word' based fetches. The pointer in this
case is to 'byte' based data, so when I increment it it merrily increments
by one byte. Then I perform a word based fetch from an odd address.
Result 'trap error'.
Now if the pointer had been to int16 data, so:
unsigned int16 * pointer;
when I incremented by '1', it'd actually increment by 2 addresses, since
it then 'knows' that the size of the element is an int16, and would
automatically increment by the size of the element pointed to, so would
not give an error. |
|
![](templates/subSilver/images/spacer.gif) |
benoitstjean
Joined: 30 Oct 2007 Posts: 553 Location: Ottawa, Ontario, Canada
|
|
Posted: Tue May 18, 2021 8:44 am |
|
|
Thanks for the info. Yeah, I saw that your other post said 'probably'.
This other code your provide works as expected. This is perfect to simulate for testing.
Again, thank you for your time, very appreciated!
Ben |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|