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

question regarding fuses

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



Joined: 25 Mar 2007
Posts: 19

View user's profile Send private message

question regarding fuses
PostPosted: Sun Mar 25, 2007 10:30 pm     Reply with quote

I'm using this *code to implement a project, however this is my first in C and not assembly, In assembly a directive for the programmer (PICSTART Plus) has to be included, but this code doesn't have one

Code:
#include <SLED4C_1620a.h>          // header file & function prototypes

void Main(void)
{
   int announce=0;                 // holds # of time/temp announcements

   init();                         // initialize I/O & peripherals

   while(1)                        // loop forever
   {
     read_time();                  // read & display DS1307 time
     read_temp();                  // read & display DS1620 temp

     // announce time/temp on roll-over from 59 to 00 minutes
     if(ds1307_regs[MINUTES_REG]==0x00)
     {
       if(!announce)               // say time & temp only if announce=0
       {
         say_time();               // say the current time
         delay_ms(3000);           // delay 3 seconds
         say_temp();               // say the current temperature
         announce +=1;             // increment announcement counts
       }
     }

     if(!ds1307_regs[MINUTES_REG]==0x00)
        announce=0;                // clear announcements until it's time
   }
}


and the header file
Code:
/*
File name: SLED4C_1620a.h
Header file for SLED4C_1620a.c

*/

#include <16f876A.h>
#use delay(clock=20000000)
#use rs232(baud=2400, xmit=PIN_C0)
#use i2c(Master, SDA=PIN_B0, SCL=PIN_B1)



I've always used MPLAB and am integrating C with it now, so does the IDE automatically set the fuses? Looking at the CCS configuration window inside MPLAB, it seems it does, I'm not sure. Do I have to even put the fuses in or has my assembly learning been all wrong? Thank you.

*note code is from www.rentron.com
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Mar 25, 2007 11:09 pm     Reply with quote

No, it doesn't automatically do it. You need to add a #fuses statement,
as shown in bold below.
Quote:

#include <16F876A.h>
#fuses HS, NOWDT, BROWNOUT, PUT, NOLVP
#use delay(clock=20000000)
#use rs232(baud=2400, xmit=PIN_C0)
#use i2c(Master, SDA=PIN_B0, SCL=PIN_B1)


Also, your #use rs232() statement will create a software UART.
If you want a hardware UART (much better), than use this line instead:
Code:
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
mcnscott2



Joined: 25 Mar 2007
Posts: 19

View user's profile Send private message

PostPosted: Mon Mar 26, 2007 1:31 am     Reply with quote

Great, thank you! I'll implement the changes tomorrow.
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