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

16F689 Comparator2 turned on by itself?

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



Joined: 29 Jun 2006
Posts: 8

View user's profile Send private message

16F689 Comparator2 turned on by itself?
PostPosted: Sat Apr 28, 2007 6:35 pm     Reply with quote

This is sortof in follow-up to a post I made earlier this week about my 16f689 not working with my LCD. (http://www.ccsinfo.com/forum/viewtopic.php?t=30570&start=0&postdays=0&postorder=asc&highlight=16f689)

I tracked the problem to my C4 pin not toggling...

Then I finally tracked the reason to be this: the comparator 2 had turned itself on, and was comparing two of my digital inputs.

This was a very simple program so I'm not sure why the comparator was turned on but I had to manually clear the C2OE and C2ON bits before my program worked like it's supposed to.

compiler bug?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Apr 28, 2007 11:43 pm     Reply with quote

On a question about a possible compiler bug, you should post the
compiler version.
sandrewww



Joined: 29 Jun 2006
Posts: 8

View user's profile Send private message

PostPosted: Sun Apr 29, 2007 9:20 pm     Reply with quote

right-click properties -> version

says 4.0.0.207
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Apr 29, 2007 9:53 pm     Reply with quote

That's not the compiler version. See this post:
http://www.ccsinfo.com/forum/viewtopic.php?t=21811&highlight=property+box&start=9
sandrewww



Joined: 29 Jun 2006
Posts: 8

View user's profile Send private message

PostPosted: Mon Apr 30, 2007 5:03 pm     Reply with quote

ah ok thanks..

from the .lst:
CCS PCM C Compiler, Version 4.018
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Apr 30, 2007 5:21 pm     Reply with quote

I installed PCM vs. 3.214 and got this error message upon trying to
compile a test program:
Quote:
Unknown device type "PIC16F689"


You probably used the Device Editor to add this PIC to your version.
If so, it's likely that the start-up code inserted by the compiler is at
least partially incorrect.

Here's the startup code generated by vs. 4.032. You may have to
add some C code to the start of your main() to duplicate these settings
if the existing startup code is doing it incorrectly.
In your post, you said that you have already done this.
Code:
.................... void main()
.................... {
0004:  CLRF   04
0005:  BCF    03.7
0006:  MOVLW  1F
0007:  ANDWF  03,F
0008:  BSF    03.6
0009:  BCF    1F.0
000A:  BCF    1F.1
000B:  BCF    1F.2
000C:  BCF    1F.3
000D:  BCF    03.6
000E:  BCF    1F.6
000F:  MOVLW  00
0010:  BSF    03.6
0011:  MOVWF  1E      // ANSEL = 0
0012:  CLRF   19      // CM1CON0 = 0
0013:  CLRF   1A      // CM2CON0 = 0
0014:  BSF    03.5
0015:  CLRF   1E      // SRCON = 0
0016:  BCF    03.5
0017:  CLRF   1B      // CM2CON1 = 0
0018:  BCF    03.6
0019:  BCF    0D.5
sandrewww



Joined: 29 Jun 2006
Posts: 8

View user's profile Send private message

PostPosted: Mon Apr 30, 2007 8:11 pm     Reply with quote

hey, thanks for the quick responses :-)

i made a mistake in my response with my correct version number -- you must've caught me before i fixed it..

i've got PCH and PCM, and accidentally gave my pch version first.

PCM, which should be compiling this 16F code, is version 4.018 according to the top of my .lst file.

I had to upgrade mplab to 7.5 before it allowed me to program the thing with my ICD2, but it compiles/works with no hacking on my part.

here's the beginning of my program from the .lst:


Code:
.................... void main()
.................... {
*
0462:  CLRF   04
0463:  BCF    03.7
0464:  MOVLW  1F
0465:  ANDWF  03,F
0466:  MOVLW  71
0467:  BSF    03.5
0468:  MOVWF  0F
0469:  BCF    03.5
046A:  BSF    03.6
046B:  BCF    1F.0
046C:  BCF    1F.1
046D:  BCF    1F.2
046E:  BCF    1F.3
046F:  BCF    03.6
0470:  BCF    1F.6
0471:  MOVLW  00
0472:  BSF    03.6
0473:  MOVWF  1E
0474:  MOVLW  07
0475:  MOVWF  19
0476:  MOVLW  FF
0477:  MOVWF  1A
0478:  BSF    03.5
0479:  CLRF   1E
047A:  BCF    03.5
047B:  CLRF   1B
047C:  BCF    03.6
047D:  BCF    0D.5
....................    short onoff = 0;
*
0495:  BCF    74.0
....................    char temp = 0;
0496:  CLRF   75
....................    char tmpStr[8];
....................    int8 i = 0;
0497:  CLRF   7E
.................... 
....................    char c;
.................... 
....................    C2ON = 0;
0498:  BSF    03.6
0499:  BCF    1A.7
....................    C2OE = 0;
049A:  BCF    1A.5
.................... 
....................    setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
049B:  MOVLW  85
049C:  BCF    03.6
049D:  MOVWF  10


where i earlier defined:
Code:
.................... #bit C2ON = 0x11A.7
.................... #bit C2OE = 0x11A.5
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