View previous topic :: View next topic |
Author |
Message |
ghiamkiii
Joined: 01 Nov 2017 Posts: 3
|
16F628A, constants used in setup_comparator() |
Posted: Wed Nov 01, 2017 3:31 pm |
|
|
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: 21708
|
|
Posted: Wed Nov 01, 2017 4:13 pm |
|
|
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
|
|
Posted: Fri Nov 03, 2017 3:50 pm |
|
|
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: 9245 Location: Greensville,Ontario
|
|
Posted: Fri Nov 03, 2017 4:10 pm |
|
|
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
|
|
Posted: Fri Nov 03, 2017 4:50 pm |
|
|
Solved !
Now it works |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19546
|
|
Posted: Sat Nov 04, 2017 12:29 am |
|
|
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]. |
|
|
|