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 CCS Technical Support

Comparator interruption for 16F877A [solved]
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
apcaye



Joined: 22 May 2009
Posts: 29
Location: Brazil

View user's profile Send private message

PostPosted: Wed May 27, 2009 2:20 pm     Reply with quote

If you set CMIF flag and the interrupt routine is called, it's because the comparator interrupt is enabled indeed. There is nothing else to be configured related to that. I ask you then: do you have input signals in the comparator input pins that really should cause an interrupt? Have you watched them with an oscilloscope or a multimeter?

Adriano.
Salenko



Joined: 08 Sep 2008
Posts: 84

View user's profile Send private message

PostPosted: Wed May 27, 2009 3:43 pm     Reply with quote

apcaye wrote:
If you set CMIF flag and the interrupt routine is called, it's because the comparator interrupt is enabled indeed. There is nothing else to be configured related to that. I ask you then: do you have input signals in the comparator input pins that really should cause an interrupt? Have you watched them with an oscilloscope or a multimeter?

Adriano.


thank you for your quick answer,

Yes, I have input signals in the comparator input pins that really should cause an interrupt. it's an input of a virtual Pulse generator (I'm simulating with isis), I have the circuit on the breadboard, but I prefer to see my code working as I expect before programming the PICmicro.
apcaye



Joined: 22 May 2009
Posts: 29
Location: Brazil

View user's profile Send private message

PostPosted: Thu May 28, 2009 9:06 am     Reply with quote

You're right, you should see your code working in the simulation before flashing it to the micro controller. And what about the TRIS register, have you checked if the comparator input pins are really configured as input (logic 1) and the comparator output as output (logic 0)?

Adriano.
Ttelmah
Guest







PostPosted: Thu May 28, 2009 9:13 am     Reply with quote

There does come a point, where it is worth trying a simple test in the real hardware. If you search here, you will find that emulators are not perfect. There have been a number of issues in the past, with the Proteus simulator, and I wonder if this is another. At the least, try with another simulator. The MPLAB simulator, is free, and is one of the best. So though I'd agree 'in general', testing in the simulator first is the way to go, there is also a point, where 'beating your head against a wall', is silly, and it is worth trying 'for real', as part of the isolation process.
Given that modern chips are generally not OTP devices. It is not as if this is expensive to do...

Best Wishes
Salenko



Joined: 08 Sep 2008
Posts: 84

View user's profile Send private message

PostPosted: Thu May 28, 2009 10:30 am     Reply with quote

Hi apcaye & Ttelmah,


apcaye wrote:
You're right, you should see your code working in the simulation before flashing it to the micro controller. And what about the TRIS register, have you checked if the comparator input pins are really configured as input (logic 1) and the comparator output as output (logic 0)?

Adriano.


Yes, the TRISA is set, by the compiler, to 47 (0b00101111) which means that the inputs of the comparator are configured as inputs, and the its output is configured as output.


Ttelmah wrote:
There does come a point, where it is worth trying a simple test in the real hardware. If you search here, you will find that emulators are not perfect. There have been a number of issues in the past, with the Proteus simulator, and I wonder if this is another. At the least, try with another simulator. The MPLAB simulator, is free, and is one of the best. So though I'd agree 'in general', testing in the simulator first is the way to go, there is also a point, where 'beating your head against a wall', is silly, and it is worth trying 'for real', as part of the isolation process.
Given that modern chips are generally not OTP devices. It is not as if this is expensive to do...

Best Wishes


thank you for your advice Ttelmah, I also use MPLAB SIM (didn't you see the screen captures on the first page of this thread ?),

but now I'm going to do the test for real.
Ttelmah
Guest







PostPosted: Thu May 28, 2009 1:20 pm     Reply with quote

I thought somewhere you had mentioned the isis/proteus simulator.
I was suggesting that you tried another. Unfortunately, if you are using MPLAB, then there is not another free one, though you should be able to get an eval version of proteus.
Also, just try another version of MPLAB. Get an older one, or a newer one.
The 'fact' that CMIE does not set in your simulation, has all the 'smells' of a simulator problem.

Best Wishes
Salenko



Joined: 08 Sep 2008
Posts: 84

View user's profile Send private message

PostPosted: Thu May 28, 2009 3:19 pm     Reply with quote

Ttelmah wrote:
I thought somewhere you had mentioned the isis/proteus simulator.
I was suggesting that you tried another. Unfortunately, if you are using MPLAB, then there is not another free one, though you should be able to get an eval version of proteus.
Also, just try another version of MPLAB. Get an older one, or a newer one.
The 'fact' that CMIE does not set in your simulation, has all the 'smells' of a simulator problem.

Best Wishes


To make something clear, I used MPLAB SIM (8.3) and isis/proteus (7.1). Wink

Both of them "simulated" fine the same code with 16F628.
Salenko



Joined: 08 Sep 2008
Posts: 84

View user's profile Send private message

PostPosted: Sat May 30, 2009 1:21 am     Reply with quote

Salenko wrote:

but now I'm going to do the test for real.


it worked.


advice: don't trust the simulators ! Wink


thank you Ttelmah & apcaye.
apcaye



Joined: 22 May 2009
Posts: 29
Location: Brazil

View user's profile Send private message

PostPosted: Mon Jun 01, 2009 6:19 am     Reply with quote

You're welcome, Salenko. Agreed, the simulators are not always right, although I have to say that the MPLAB simulator use to work very well, it never disappointed me.

Adriano.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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