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

PIC16F676 Won't Run

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







PIC16F676 Won't Run
PostPosted: Mon Dec 11, 2006 5:27 am     Reply with quote

Hi. I have tried a simple program with CCS PIC C that is supposed to turn on some LEDs, but it wont run. I know the pic works because I compiled the program in both Pic BASIC and in MPLAB and there were no problems there.

I think its got something to do with the configuration bits (or fuses as they are called in Pic C). I am setting the exact same fuses in MPLAB, so not sure what the problem is.

Here is the code:


#include <16F676.h>


#fuses INTRC_IO // Internal RC osc, no clock out




void main()
{


set_tris_a(0); // Make all outputs
set_tris_c(0);


OUTPUT_A(0xff); // Set all pins - turn on LED's
output_c(0xff);


}

I have also tried using the FAST_IO to set the data direction registers, but that didn't make any difference.

Thanks in advance for the help.

Regards,

John
PhilWinder



Joined: 16 Apr 2005
Posts: 23

View user's profile Send private message

PostPosted: Mon Dec 11, 2006 5:56 am     Reply with quote

I know how you feel, I hate these stupid, "why wont it start" problems. Could be a number of things,
Put in all the fuses in PICC, because every time you re-import your file in MPLAB, the HEX file will overwrite them. Better to just make sure there right by checking once, then forget about it.
I dont know about the chip you are useing, but the Comparator, A/d etc. have not been disabled.

So for an example, your file should have something like:
Code:

#FUSES NOWDT                      //Watch Dog Timer
#FUSES INTRC_IO                 //Internal RC Osc, no CLKOUT
#FUSES NOPUT                    //No Power Up Timer
#FUSES MCLR                     //Master Clear pin enabled
#FUSES BROWNOUT                 //Reset when brownout detected
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD                    //No EE protection
#FUSES NOWRT                    //Program memory not write protected
#FUSES NODEBUG                    //Debug mode for use with ICD
#FUSES NOPROTECT                //Code not protected from reading
#FUSES FCMEN                    //Fail-safe clock monitor enabled
#FUSES IESO                     //Internal External Switch Over mode enabled

   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   setup_oscillator(OSC_8MHZ|OSC_NORMAL);


Obviously, this is just a example and actual configuration may be different for your chip. Refer to the header file for your configurations (in the devices folder of PICC).

Cheers,
Phil
John676
Guest







Hi Phil
PostPosted: Tue Dec 12, 2006 5:20 am     Reply with quote

Hi Phil.
Thanks for the suggestions, I tried them but alas, no joy. I've tried just about everything I can think of, even different clock speed settings.

Nothing seems to work. I wonder if there is not some problem with CCS's pin assignments for this pic.

Thanks,

John
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Dec 12, 2006 8:21 am     Reply with quote

Quote:

I have tried a simple program with CSS PIC C that is supposed to
turn on some LEDs, but it wont run.

Post your compiler version. This will be a number such as 3.191,
3.236, 3.249, or 4.017, etc. Look at the top of the .LST file to find it.
The .LST file is in your project directory.
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Tue Dec 12, 2006 9:59 am     Reply with quote

Make sure you have a while(1) in your main so the program doesn't fall off the end and make the PIC fall asleep.

Ronald
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