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

16f628a comparator configuration

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



Joined: 20 Sep 2018
Posts: 4

View user's profile Send private message

16f628a comparator configuration
PostPosted: Fri May 03, 2019 11:20 pm     Reply with quote

I have one input changing in logic. When 5v input i want an interrupt to fire so that to reset a two seven segments with 4 bit decoders counter in port b.
Can anyone help me on configuring the comparator interrupt when input change to reset a counter and in the interrupt how to clear the flag so that it won't block on isr ?
I don't know how to match this code with the comparator mode. If anyone can give me comments on what each line does?
Code:

#define A0_A3_A1_A2  0xfff04
#define A0_A2_A1_A2  0x7ff03
#define NC_NC_A1_A2  0x6ff05
#define NC_NC_NC_NC  0x0ff07
#define A0_VR_A1_VR  0x3ff02
#define A3_VR_A2_VR  0xcff0A
#define A0_A2_A1_A2_OUT_ON_A3_A4 0x7e706
#define A3_A2_A1_A2  0xeff09
#define CP1_INVERT   0x00010
#define CP2_INVERT   0x00020

Using ccs code and thanks.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri May 03, 2019 11:56 pm     Reply with quote

Quote:
#define A0_A2_A1_A2_OUT_ON_A3_A4 0x7e706

The constant consists of three bytes: 07 E7 06

1. CMCON is loaded with 0x06.

2. TRISA is bitwise OR'ed with 0x07.
This sets bits 0,1,2 = 1, which makes pins A0, A1, A2 into inputs.

3. TRISA is bitwise AND'ed with 0xE7.
This sets bits 3 and 4 = 0, which makes pins A3 and A4 into outputs.
el-3aba6i



Joined: 20 Sep 2018
Posts: 4

View user's profile Send private message

PostPosted: Sat May 04, 2019 12:01 am     Reply with quote

Thanks for good explaning.
I'm not using asm code but pic c compiler code.
The code i pasted was from .h pic file. I didn't find any reference explaining it in pic c compiler code directly, all i find is mplab codes.
What i need is the code to put in setup comparator() function and thanks. ;)
el-3aba6i



Joined: 20 Sep 2018
Posts: 4

View user's profile Send private message

PostPosted: Sat May 04, 2019 12:09 am     Reply with quote

This is the setup i have done after your reply but int won't fire.
Code:
setup_comparator(A0_A2_A1_A2_OUT_ON_A3_A4); 
enable_interrupts(GLOBAL);
enable_interrupts(INT_COMP);
temtronic



Joined: 01 Jul 2010
Posts: 9081
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat May 04, 2019 5:18 am     Reply with quote

You need to show us your complete program !
Jay
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: 16f628a comparator configuration
PostPosted: Sat May 04, 2019 4:08 pm     Reply with quote

el-3aba6i wrote:
I have one input changing in logic.
Is this a push-button to ground, with a pull-up resistor on it ?

el-3aba6i wrote:

When 5v input i want an interrupt to fire so that to reset a two seven
segments with 4 bit decoders counter in port b.

Why use the comparator to detect the input change ?
Why not make it easy and use the External Interrupt on Pin B0 ?
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