View previous topic :: View next topic |
Author |
Message |
Geps
Joined: 05 Jul 2010 Posts: 129
|
Timer0 Interrupt Affecting Change On B Interrupt |
Posted: Tue Aug 31, 2010 4:47 am |
|
|
Hi,
I've noticed that my Timer 0 is disrupting my Change On B interrupt on my PIC18F4520. The change on B works fine provided I edit out the setup_timer_0 (RTCC_DIV_128) line. As soon it isn't commented out the Change On B seems to happen just before the Timer 0 overflows and the function is called.
I've looked at both sections of the datasheet: http://ww1.microchip.com/downloads/en/DeviceDoc/39631a.pdf
And can't find any common elements between the two.
Any ideas?
Cheers, |
|
|
Geps
Joined: 05 Jul 2010 Posts: 129
|
|
Posted: Tue Aug 31, 2010 8:48 am |
|
|
Some progress.....
I've rewritten the program and am copy-and-pasting it bit by bit.
When it's waiting in this while loop:
Quote: | while(!DataCollected && !ErrorFlag) {
} |
It doesn't respond to the changes on B.
The data collected flag however is set by that interrupt.
The Timer2 overflow interrupt is used to timeout and sets ErrorFlag successfully.
Only after it has completed the loop does RB respond as it should. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Aug 31, 2010 2:02 pm |
|
|
1. You need to post a short, compilable test program. Test your code
before you post it to make sure it compiles with no errors.
2. Also post your compiler version.
3. Also describe the external circuit(s) on PortB. Measure the voltage
levels that are present in the idle state, and in the active state, and
post them. For example, if you have a push-button switch on one pin,
check the voltage with a scope or a voltmeter when the button is released
and when it's pressed. Post those voltages.
In other words, post the code, the compiler version, and the hardware. |
|
|
Geps
Joined: 05 Jul 2010 Posts: 129
|
|
Posted: Wed Sep 01, 2010 2:24 am |
|
|
I'd spent so long looking at the code I figured it must have been due to the hardware capabilities of the device rather than my own software.
Turns out I had left a disable_interrupt(INT_RB); at the very end of the Timer0 interrupt.
Apologies! |
|
|
|