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

Comparator interrupt coming all the time

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



Joined: 21 Oct 2005
Posts: 2

View user's profile Send private message

Comparator interrupt coming all the time
PostPosted: Fri Jun 27, 2008 1:30 am     Reply with quote

Hi,
if got this problem with comparator interrupt for some time now ;)
Pin B1 is toggled with 4/5 the time low and 1/5 high, but Pin B3 is always low and there is now reason for the COMP interrupt to come as A4 is high all the time....
I'm using the 18F2550
Code:
#include "C:\Programme\PICC\Examples\m.h"
#byte COCON = 0xfb4
#byte PIR2 = 0xfa1

#int_COMP
void COMP_isr(void) {
   int cur;
   output_high(PIN_B1);
   cur = COCON;
   output_low(PIN_B1);
}

void main()
{
   setup_comparator(A0_A3_NC_NC_OUT_ON_A4);
   enable_interrupts(INT_COMP);
   enable_interrupts(GLOBAL);

   while (1) {
      output_high(PIN_B3);
      output_low(PIN_B3);
   }
}
Ttelmah
Guest







PostPosted: Fri Jun 27, 2008 2:28 am     Reply with quote

What are your fuses?.
A4, is multiplexed onto a couple of things. One is the USB RCV input, when using an external transceiver. This overrides it's operation as a comparator output pin (TRIS is ignored). It acts as an input, and won't then reflect the comparator behaviour.
I'd suggest stepping the code through in MPLAB, till you get to the main loop, and seeing what is in all the configuration registers. Though comparator inputs, are the 'default' on POR, sometimes, CCS fiddles with configurations on other parts of the chip, leading to problems.
I'd be most suspicious that A4, is not really reflecting the comparator output.
What compiler version?.

Best Wishes
salamander22
Guest







PostPosted: Fri Jun 27, 2008 4:05 am     Reply with quote

thx for your hint and you are right with the A4 output, but the problem is the main_loop not running at all. And my comperator inputs are on static voltages now...
and I'm working with recent version:)
Ttelmah
Guest







PostPosted: Fri Jun 27, 2008 4:33 am     Reply with quote

Add a small delay between the high and low outputs, in the main, and see if anything becomes visible. Your other set/reset, on B1, has an instruction between, which will take a few machine cycles, and could make the difference in terms of seeing the loop.
Give a version number. Somebody can test and see if it works for them, if we know the actual version, but 'recent', for CCS, could refer to several different versions....
The timings seem odd, since even if the interrupt was continuously triggered, I'd still expect the ratio between high and low, on B1, to be perhaps 30:1, not 5:1.

Best Wishes
Guest








PostPosted: Fri Jun 27, 2008 8:46 am     Reply with quote

Thanks for your help, in the end it where multiple problems comming together: at first it needs some time to get out/into the isr whitch I did not think of and then I mixed up the input logic -> It could not work...
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