|
|
View previous topic :: View next topic |
Author |
Message |
John676 Guest
|
PIC16F676 Won't Run |
Posted: Mon Dec 11, 2006 5:27 am |
|
|
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
|
|
Posted: Mon Dec 11, 2006 5:56 am |
|
|
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 |
Posted: Tue Dec 12, 2006 5:20 am |
|
|
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
|
|
Posted: Tue Dec 12, 2006 8:21 am |
|
|
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
|
|
Posted: Tue Dec 12, 2006 9:59 am |
|
|
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 |
|
|
|
|
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
|