|
|
View previous topic :: View next topic |
Author |
Message |
salamander
Joined: 21 Oct 2005 Posts: 2
|
Comparator interrupt coming all the time |
Posted: Fri Jun 27, 2008 1:30 am |
|
|
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
|
|
Posted: Fri Jun 27, 2008 2:28 am |
|
|
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
|
|
Posted: Fri Jun 27, 2008 4:05 am |
|
|
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
|
|
Posted: Fri Jun 27, 2008 4:33 am |
|
|
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
|
|
Posted: Fri Jun 27, 2008 8:46 am |
|
|
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... |
|
|
|
|
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
|