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

firmware crash upon adding single opcode

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
gil.fonea@sds-tech.com



Joined: 24 Mar 2010
Posts: 24

View user's profile Send private message Send e-mail

firmware crash upon adding single opcode
PostPosted: Sun Jul 21, 2013 2:55 am     Reply with quote

Hi,

I am using 18F25K22 with compiler PCH V4.118.

My code is stable and working good.

Today i had to add a small while loop to sample a "signal1" input every 1ms:
Code:

while(local_counter < 1000)

   local_counter++;
   if (input(signal1) == 0)
      return (1);   //error 
     
   Delay_ms(1);   
          
}

The code is located within a 3rd level nested function.

The new code compiles well, but firmware does strange things: i2c communication does not work. The funny thing is that the additional code has nothing to do with i2c routines.

BTW, i commented all the additional code and left only with Delay_ms(1); and error still shows. commented the Delay_ms(1); as well, and problem gone.

How can 1 single Delay_ms(1) command affect all the code?????

Please help!

Gil
_________________
Gil F.
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Sun Jul 21, 2013 3:07 am     Reply with quote

First, obvious one. Are you using a delay anywhere inside interrupt routines?. If so (unless you have some errors turned off), you might now be getting 'interrupt disabled to prevent re-entrancy' as a warning, and every interrupt would be delayed for the 1mSec.
Second, at the top of the listing, what does the stack usage say?. You talk about the routine being '3rd level', but if interrupts then call other routines, and perhaps you have high priority also enabled, you may well be running out of stack.

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