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 May 17, 2021 1:07 pm     Reply with quote

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
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Tue May 18, 2021 12:17 am     Reply with quote

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.
benoitstjean



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

View user's profile Send private message

PostPosted: Tue May 18, 2021 8:44 am     Reply with quote

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
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