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

Timer0 Interrupt Affecting Change On B Interrupt

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Geps



Joined: 05 Jul 2010
Posts: 129

View user's profile Send private message

Timer0 Interrupt Affecting Change On B Interrupt
PostPosted: Tue Aug 31, 2010 4:47 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Aug 31, 2010 8:48 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Aug 31, 2010 2:02 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Sep 01, 2010 2:24 am     Reply with quote

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. Embarassed

Apologies!
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