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

Pic 16f690 pins shorted

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



Joined: 27 Feb 2008
Posts: 8

View user's profile Send private message

Pic 16f690 pins shorted
PostPosted: Mon Mar 03, 2008 5:37 pm     Reply with quote

I'm having trouble with pins C3 and C4 on my pic. I first noticed it trying to output a byte to port C, and then individually output_high on pins to narrow it down.

output_high(pin_c3); turns on pin c3 and c4 both
output_high(pin_c4); doesn't do anything

I have tried it in a breadboard and on the chip debugger board. I have tried it with several chips, and it always does the same thing.

Anyone else had this happen?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Mar 03, 2008 5:47 pm     Reply with quote

You should always post your compiler version.

This thread may help:
http://www.ccsinfo.com/forum/viewtopic.php?t=29942&highlight=16f690+setupcomparator
jj9867



Joined: 27 Feb 2008
Posts: 8

View user's profile Send private message

PostPosted: Mon Mar 03, 2008 5:50 pm     Reply with quote

Its 4.013.

That thread isn't very helpful, unfortunately. All other pins on port C work, except 3 and 4. In the other thread, they're doing stuff on pins 0 and 1.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Mar 03, 2008 5:53 pm     Reply with quote

Did you try disabling the comparators ?
jj9867



Joined: 27 Feb 2008
Posts: 8

View user's profile Send private message

still no luck
PostPosted: Tue Mar 04, 2008 11:52 am     Reply with quote

ok I tried disabling them using

setup_comparator(NC_NC_NC_NC);

still no luck.

I am using simple code just

set_tris_c(0);
output_c(0b00010111);

this just turn on bits 0,1, and 2. Bit 4 stays off.

If I go:
output_c(0b00001111);

then bits 0-4 all turn on.

It seems as though bit 4 is linked with the output of bit 3.

Any help would be great,
JJ
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Mar 04, 2008 11:59 am     Reply with quote

Post a complete test program, using that code, but show all the #include,
#fuses, and #use statements. Show variable declarations, if any.
Show the main(), the braces, etc. It should be a compilable program.
Run the test program in a PIC to prove that it shows the problem,
before you post the code.

If you can do that, I can compile the program for both 4.013 and 4.069,
and compare the .LST files.
jj9867



Joined: 27 Feb 2008
Posts: 8

View user's profile Send private message

code
PostPosted: Tue Mar 04, 2008 1:14 pm     Reply with quote

no problem I probably should have posted the code in the first place...

here is the header file:

#include <16F690.h>
#device adc=8

#FUSES NOWDT //No Watch Dog Timer
#FUSES RC //Resistor/Capacitor Osc with CLKOUT
#FUSES NOPROTECT //Code not protected from reading
#FUSES BROWNOUT //Reset when brownout detected
#FUSES MCLR //Master Clear pin enabled
#FUSES NOCPD //No EE protection
#FUSES NOPUT //No Power Up Timer
#FUSES IESO //Internal External Switch Over mode enabled
#FUSES FCMEN //Fail-safe clock monitor enabled

#use delay(clock=20000000)

..................................................

and here is the C file

#include "G:\projects\lights\lighta.h"


void main()
{
setup_comparator(NC_NC_NC_NC);
setup_ccp1(CCP_OFF);


setup_adc(ADC_OFF);


while (1 == 1)
{

set_tris_c(0);
output_c(0b00010111);
}
}


......................................
It is pretty much as simple as I can make it

Thanks for the help
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Mar 04, 2008 1:21 pm     Reply with quote

Quote:
#FUSES RC //Resistor/Capacitor Osc with CLKOUT
#use delay(clock=20000000)

This can't be working. The fuses are set for an external RC oscillator
circuit, and your #use delay() statement is set for 20 MHz. The external
RC oscillator isn't rated to run at more than 4 MHz. I doubt that you
even have the external resistor and capacitor circuit installed.
jj9867



Joined: 27 Feb 2008
Posts: 8

View user's profile Send private message

it seems to work with the other lights
PostPosted: Tue Mar 04, 2008 2:04 pm     Reply with quote

it seems to work with the other lights.

Yes you are right. I left the default that was generated by the wizard. I have played with a few of the settings but it does not seem to help. What should the fuses be set for to simply run with the internal oscillator of the pic?
In other words, if I simply turn on the power to the pic what should the fuses be set at and what should the delay be?

Thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Mar 04, 2008 2:26 pm     Reply with quote

It turns out that I don't have vs. 4.013. But I have 4.014, and I tested
the following program with that version. It works OK. Pin C3 toggles
high and low, and pin C4 stays at a low level.

You don't have to set the TRIS with the set_tris_c() statement.
The compiler will automatically set it for you, when it does the output_c()
statement.

The program below uses the internal RC oscillator, and it runs at 8 MHz.
Notice the fuse is set for INTRC_IO. The highest speed available is
8 MHz. I've set it for that frequency.

Code:

#include <16F690.h>
#fuses INTRC_IO, NOWDT, BROWNOUT, PUT, MCLR
#use delay(clock=8000000)

//===============================
void main()
{
setup_comparator(NC_NC_NC_NC);

output_c(0);   

while(1)
  {
   output_c(0x08);  // Set pin C3 = 1
   delay_ms(100);
   
   output_c(0x00);  // All pins low
   delay_ms(100);
  }

}


If this program doesn't work, then post a description of the external
components that you have connected to pins C3 and C4. Include the
values of the components.
brianm



Joined: 08 Mar 2008
Posts: 17

View user's profile Send private message

NEW to ccs compiler
PostPosted: Sat Mar 08, 2008 9:10 pm     Reply with quote

My setup;

MPLAB
CCS PCM COMPILER (4.062)

PROGRAMMING DEVICE = PICKIT 2
and low count demo board

--------------------------------------------------

I picked the code above to try out the setup.

I 'made' the project with one small warning

I was expecting the led on the low count demo board to turn on and off

but I see nothing.

I used mplab, programmer PICKIT2...erase and write.

I am new to the CCS world but I have worked with assembler for a while (2 months).

Thanks all.
-----------------------------------------
New information


Now I closed MPLAB and opened PICKIT2 software and loaded the hex file created and wrote it to the low count demo board and it worked fine.

What am I doing wrong in the MPLAB environment?



code



Code:

#include <16F690.h>
#fuses INTRC_IO, NOWDT, BROWNOUT, PUT, MCLR
#use delay(clock=8000000)

//===============================
void main()
{
setup_comparator(NC_NC_NC_NC);

output_c(0);   

while(1)
  {
   output_c(0x08);  // Set pin C3 = 1
   delay_ms(100);
   
   output_c(0x00);  // All pins low
   delay_ms(100);
  }

}



make listing

    Executing: "C:\software\PICC\CCSC.EXE" +FM "first c program.c" +DF +LN +T -A +M +Z +Y=9 +EA
    >>> Warning 203 "first c program.c" Line 13(1,1): Condition always TRUE
    Memory usage: ROM=2% RAM=2% - 3%
    0 Errors, 1 Warnings.
    Loaded D:\microchip\projects in c\first c program.cof.
    BUILD SUCCEEDED: Sat Mar 08 21:01:42 2008

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