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

18f4520 random restart
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Apr 30, 2018 1:38 am     Reply with quote

eng/ IBRAHIM wrote:

But the RESTART problem still occurs.

Do an experiment. What if you are getting division by zero ?
I'm not sure what the CCS integer division routines do if you
divide by zero, but it may be causing your restart. Modify
your VARW loop as shown below:
Code:

int16 temp;

for(VARW=0;VARW<=2100;++VARW)
   {
    // Disable interrupts temporarily when reading a 16-bit number
    //  that is changed inside an interrupt routine.
    disable_interrupts(GLOBAL); 
    temp = isr_ccp_delta;
    enable_interrupts(GLOBAL);

    // Put in some protection code.
    if(temp == 0)   // If divisor is 0, then:
       temp = 100;  // Set it to a nominal value (You pick the value)

    frequency = (125000 / temp);
   ]
temtronic



Joined: 01 Jul 2010
Posts: 9081
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Apr 30, 2018 5:12 am     Reply with quote

another test to do....
since this is some kind of AC motor controller, remove the AC motor and it's driver and run the program. Does it run fine or restart ?
Also describe the interface and motor. Has any of that been changed
It'd difficult to undestand how this program worked 'fine' in the 877 but fails in this PIC.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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