View previous topic :: View next topic |
Author |
Message |
falcon1877
Joined: 30 Sep 2012 Posts: 24
|
|
Posted: Mon Oct 01, 2012 11:51 am |
|
|
ok, i'll try it. Thanks all |
|
|
n-squared
Joined: 03 Oct 2006 Posts: 99
|
|
Posted: Mon Oct 01, 2012 1:31 pm |
|
|
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
|
|
Posted: Mon Oct 01, 2012 2:21 pm |
|
|
thanks guy, but it dosen't solve the problem |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Oct 01, 2012 2:35 pm |
|
|
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
|
|
Posted: Mon Oct 01, 2012 2:42 pm |
|
|
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
|
|
Posted: Mon Oct 01, 2012 2:52 pm |
|
|
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
|
|
Posted: Mon Oct 01, 2012 4:09 pm |
|
|
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 |
|
|
|