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, constants used in setup_comparator()

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



Joined: 01 Nov 2017
Posts: 3

View user's profile Send private message

16F628A, constants used in setup_comparator()
PostPosted: Wed Nov 01, 2017 3:31 pm     Reply with quote

In header 16F628A.H there are constants for setup_comparator();

Example:

#define A0_VR_A2_VR 0x3ff02
#define A0_A2_A1_A2_OUT_ON_A3_A4 0x7e706

What does the hex code 0x3ff02 mean, etc

I know that the last number "2" means:
two independent comperators with CM2:CM0 = 010 (=2)

Is there some where an explanation for the other 4 bits on document ?
PCM programmer



Joined: 06 Sep 2003
Posts: 20098

View user's profile Send private message

PostPosted: Wed Nov 01, 2017 4:13 pm     Reply with quote

Compile that line, but use the constant that has all fields
filled in with something other than 0xFF. This will help us
to see what the compiler is doing.

Use this constant:
Code:

#define A0_A2_A1_A2_OUT_ON_A3_A4  0x7e706

It consists of three bytes: 07 E7 06

I've added comments below to show how those bytes are
used by the CCS compiler to setup the comparator.
This is part of the .LST file:
Code:

..... setup_comparator(0x7e706); 

000A:  MOVLW  06     // Load CMCON with 0x06
000B:  MOVWF  CMCON   

000C:  BSF    STATUS.RP0
000D:  MOVF   TRISA,W
000E:  IORLW  07     // OR mask (0x07) to set TRISA bits 0,1,2
000F:  ANDLW  E7     // AND mask (0xE7) to clear TRISA bits 3,4
0010:  MOVWF  TRISA

0011:  MOVLW  03     // Short delay
0012:  MOVWF  @77
0013:  DECFSZ @77,F
0014:  GOTO   013

0015:  BCF    STATUS.RP0
0016:  MOVF   CMCON,W
0017:  BCF    PIR1.CMIF
ghiamkiii



Joined: 01 Nov 2017
Posts: 3

View user's profile Send private message

PostPosted: Fri Nov 03, 2017 3:50 pm     Reply with quote

When i use setup_comparator(A0_A3_A1_A2) with A0 and A1 as -input,
on A3 and A2 as +input with an external reference voltage,
and when i vary the voltage of A0 and A1
I get no response on C1OUT and C2OUT.

How come ??
temtronic



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

View user's profile Send private message

PostPosted: Fri Nov 03, 2017 4:10 pm     Reply with quote

You need to post your small program that shows us what you're doing. Without it, we can only guess.
ghiamkiii



Joined: 01 Nov 2017
Posts: 3

View user's profile Send private message

PostPosted: Fri Nov 03, 2017 4:50 pm     Reply with quote

Solved !

Now it works Very Happy
Ttelmah



Joined: 11 Mar 2010
Posts: 12505

View user's profile Send private message

PostPosted: Sat Nov 04, 2017 12:29 am     Reply with quote

So, post what the problem actually was, so that other people can benefit. Even if it was something silly.
Then change the thread title to have [solved].
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