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

Timer can't run after reset. :confused:
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
falcon1877



Joined: 30 Sep 2012
Posts: 24

View user's profile Send private message

PostPosted: Mon Oct 01, 2012 11:51 am     Reply with quote

ok, i'll try it. Thanks all Very Happy
n-squared



Joined: 03 Oct 2006
Posts: 99

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Mon Oct 01, 2012 1:31 pm     Reply with quote

Code:

#int_timer0
void timer()
{
   //do something
  // you don't have to clear timer 0 as it already overflowed to zero.
}


#int_rb
void interrupt()
{
  int8 value;
  value = input_b(); // get data from port B to clear interrupt condition
   //do something
}


that should most probably do the trick.
_________________
Every solution has a problem.
falcon1877



Joined: 30 Sep 2012
Posts: 24

View user's profile Send private message

PostPosted: Mon Oct 01, 2012 2:21 pm     Reply with quote

thanks guy, but it dosen't solve the problem Sad
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Oct 01, 2012 2:35 pm     Reply with quote

Quote:

set_tris_b(0b11110000);
enable_interrupts(int_timer0);
enable_interrupts(int_rb);
setup_timer_0(RTCC_DIV_4|RTCC_INTERNAL);
set_timer0(0);
enable_interrupts(GLOBAL); <<< when I run step by step I found that program will be crashed after run this line


I suspect that by "crash" you really mean that the program is not
responsive or that it's not doing your main task very often.

Well, comment out one or both of the enable_interrupts(int_xxxx) lines
to find out which interrupt is causing the problem (or maybe they both are).

Example:
Quote:

set_tris_b(0b11110000);
// enable_interrupts(int_timer0);
enable_interrupts(int_rb);
setup_timer_0(RTCC_DIV_4|RTCC_INTERNAL);
set_timer0(0);
enable_interrupts(GLOBAL);

Here, I have commented out the int_timer0 enable line. Now the program
will only run with int_rb enabled. Notice that GLOBAL interrupts are
enabled. See if the program now works without "crashing".
falcon1877



Joined: 30 Sep 2012
Posts: 24

View user's profile Send private message

PostPosted: Mon Oct 01, 2012 2:42 pm     Reply with quote

yeah, I tested, when I comment like this , program run normally :
Code:

set_tris_b(0b11110000);
 enable_interrupts(int_timer0);
 //enable_interrupts(int_rb);
 setup_timer_0(RTCC_DIV_4|RTCC_INTERNAL);
 set_timer0(0);
 enable_interrupts(GLOBAL);


I found that when i rerun a program, timer0 work correctly but int_rb doesn't work anymore .... so that this problem cause by int_rb ??
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Oct 01, 2012 2:52 pm     Reply with quote

Describe all external circuits on the PIC pins RB4-RB7. Tell the
components, values, connections, and voltages.
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Mon Oct 01, 2012 4:09 pm     Reply with quote

It's still not clear to me.

Are you using real hardware or Proteus?

How do you KNOW what's working and what isn't?

Mike
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