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 support@ccsinfo.com

PIC24F address error

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



Joined: 20 Oct 2009
Posts: 18

View user's profile Send private message

PIC24F address error
PostPosted: Tue May 29, 2012 6:58 am     Reply with quote

Hi all,

I'm using PIC24F16KA102 and CCS 4.124. I have some complex code working fine but there is one address error that is driving me crazy.

I included the following code to debug the error.
Code:

#int_ADDRERR

   void ae_isr (void)
{
      #asm
      mov w15, w0
      sub #36, w0
      mov [w0++], w1
      mov w1, trapaddr
      mov [w0], w1
      and #0x7f, w1
      mov w1, trapaddr+2
      #endasm
      set_radio_mode (rf_sleep, 0) ;
      rtcie=false;
      //sleep (sleep_full) ;
      while (1);
}

If I look at the variable Trapaddr I see a value of 0XAB2, if I check this line of code in the assembly listing I see the following code.
Code:

552:                    if (*r_rssi>15)
  0AB2  805580     mov.w 0x0ab0,0x0000
  0AB4  784210     mov.b [0x0000],0x0008
  0AB6  E1246F     cp.b 0x0008,#15
  0AB8  360003     bra leu, 0x000ac0
1553:                       *r_rssi=15;
  0ABA  805585     mov.w 0x0ab0,0x000a
  0ABC  B3C0F0     mov.b #0xf,0x0000
  0ABE  784A80     mov.b 0x0000,[0x000a]


*r_rssi is passed into this function as an unsigned char *r_rssi and the address of declared byte is passed into this function.

Does anyone have any ideas why this code might be causing an Address error? I am quite sure this code is already being called multiple times but I can see the chain of events and one particular place where its called from which causes the error.

Eoin
Tressie



Joined: 07 Apr 2012
Posts: 12

View user's profile Send private message

Address Error
PostPosted: Fri Jul 06, 2012 6:02 am     Reply with quote

Hi Eoin87,

Did you ever manage to find the cause of your address error reset, because I have exactly the same thing happening.

Regards,
T. Wink
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Fri Jul 06, 2012 10:56 am     Reply with quote

There's no address error at 0xAB2, the faulty instruction is one assembly line above, not shown in the post.
Tressie



Joined: 07 Apr 2012
Posts: 12

View user's profile Send private message

PostPosted: Fri Jul 06, 2012 2:38 pm     Reply with quote

FvM wrote:
There's no address error at 0xAB2, the faulty instruction is one assembly line above, not shown in the post.


Hi FvM. Nice to have your expertise along for the ride.

Well, if the PCD V4.081 address error trap handler/ debug code is good for PCD V4.132 as well, then the source of my address error reset seems to be within some code that the compiler automatically adds just after a device header include statement. PCD bug, maybe?

The use of certain other sections of code (ModBus CRC calculation), or the use of CCS EEPROM access code elsewhere in the project seems to be triggering the exception condition, but nothing short of omitting the offending statements and subroutine calls will help. I can't seem to find any of the known address error causes in the spacially unrelated trap inducing source, so I'm stumped.

Okay, I'm now handling the exception that the second address error invokes, so the controller no-longer resets. As far as I can tell, the error and subsequent trap have no effect on my program's operation, and everything continues on swimmingly just after the error handler completes. What might be the implications of just leaving it there?

Regards,
T. Smile

We
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Fri Jul 06, 2012 4:13 pm     Reply with quote

There have been PCD bugs that raise an address error, but in most cases they are brought up by user code errors. The final error can also occur in library code, e.g. if a function is supplied with wrong parameters. In so far I won't guess about the cause for your observations.

With some basic understanding of PIC24 instruction set, you should be able to "see" the cause for an address error when analyzing the code. In special cases, it may be necessary to trace code execution at the disassembly level in MPLAB debugger. Sometimes the problem can be reproduced in MPLAB SIM, without actual processor hardware.

If an address error is handled by exception routine, the instruction causing the error is skipped. If this instruction isn't superfluous (most likely it isn't), a required calculation result will be missing.
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