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

Program not working when NOFCMEN

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








Program not working when NOFCMEN
PostPosted: Sat Jan 03, 2009 10:02 pm     Reply with quote

Im new to PICs and CCS and I have some quick questions. Im using a PICKit2 and Low Pin count demo board with a 16F690. I just wanted to blink a few LEDs but I had setup problems when I wrote the program with CCS project wizard setup help. MPLAB would download the program to the PIC but the lights wouldnt turn on. After I commented out the NOFCMEN line everything worked fine. So my question is why and is it better to set all projects up manually? Thanks for your help.

Curt

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

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES LP                       //Low power osc < 200 khz
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOMCLR                   //Master Clear pin used for I/O
#FUSES NOCPD                    //No EE protection
#FUSES NOPUT                    //No Power Up Timer
#FUSES NOIESO                   //Internal External Switch Over mode disabled
//#FUSES NOFCMEN                  //Fail-safe clock monitor disabled

#use delay(clock=4000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jan 04, 2009 3:04 am     Reply with quote

The 16F690 data sheet says:
Quote:
3.8 Fail-Safe Clock Monitor
The Fail-Safe Clock Monitor (FSCM) allows the device
to continue operating should the external oscillator fail.
The FSCM can detect oscillator failure any time after
the Oscillator Start-up Timer (OST) has expired. The
FSCM is enabled by setting the FCMEN bit in the
Configuration Word register (CONFIG).

The Low Pin Count User's Guide doesn't show any crystal or resonator
or R-C circuit on the board.
http://ww1.microchip.com/downloads/en/DeviceDoc/Low%20Pin%20Count%20User%20Guide%2051556a.pdf

You have the main oscillator fuse set for "LP" mode. That's for a 32 KHz
watch crystal. Again, I don't have the board but I doubt that a watch
crystal is connected to the main oscillator pins on the 16F690.

Therefore, when the PIC is powered-up with FCMEN enabled, it detects
that the external oscillator is not running and it switches to the internal
oscillator, and your program works. With NOFCMEN, it can't switch,
so there's no internal clock and it won't work.

A better solution would be to specify the internal oscillator in your #fuses
statement with the INTRC_IO fuse instead of LP.
Guest








PostPosted: Sun Jan 04, 2009 7:20 am     Reply with quote

OK that makes sense! What is the best way to set up a PIC? Like I said before using the project wizard in ccs seems straight forward but if it does what it did this time I may not catch the problem then pull my hair out? I think I just may manually set things up next time.
Does anyone know if there is any sites or good books that expain how to set a PIC up and why certain fuses are set? Thanks again.

Curt
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jan 04, 2009 12:02 pm     Reply with quote

Try this program. It should blink LED "DS1". (Make sure jumpers JP1
and JP5 are installed on the Low Pin Count board). These fuse settings
should work with that board.
Code:

#include <16F690.H>
#fuses INTRC_IO, NOWDT, NOPROTECT, NOBROWNOUT, PUT
#use delay(clock=4000000)
   
//====================================
void main()
{

while(1)
  {
   output_high(PIN_C0);   // Blink LED "DS1"
   delay_ms(500);
   output_low(PIN_C0);
   delay_ms(500);
  }

}


There is a file called "Fuses.txt" that explains the fuses, but you only get
it with the CCS IDE (PCW, PCWH, etc). However, someone has posted
it at the end of this thread on another forum:
http://www.todopic.com.ar/foros/index.php?topic=16947.0
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