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

PIC24: How can I setting fuse for both external oscillator

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



Joined: 05 Aug 2009
Posts: 37

View user's profile Send private message MSN Messenger

PIC24: How can I setting fuse for both external oscillator
PostPosted: Wed Sep 15, 2010 9:45 pm     Reply with quote

I use PIC24FJ256GA1006 and my CCS version is PCD 4.105
------------------------------------------------------------------------------------
How can I use the ( OSCO,OSCI ) & (SOSCO,SOSCI) at the same time ?
I want to use 16MHz & 32.768KHz,
16MHz as primary oscillator & 32.768KHz for RTC.
Could someone teach me how to set the fuses? Thanks.

Note:
I use oscilloscope to monitor 16MHz and 32.768KHz.
16Mhz have work but 32.768 do not work.

Now my .h file setting follows:
Code:

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES NOJTAG                   //JTAG disabled
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOWRT                    //Program memory not write protected
#FUSES NODEBUG                  //No Debug mode for ICD
#FUSES ICSP2                    //ICD uses PGC2/PGD2 pins
#FUSES WINDIS                   //Watch Dog Timer in non-Window mode
#FUSES WPRES128                 //Watch Dog Timer PreScalar 1:128
#FUSES WPOSTS16                 //Watch Dog Timer PostScalar 1:32768
#FUSES NOIESO                   //Internal External Switch Over mode disabled
#FUSES PR                       //Primary Oscillator
#FUSES NOCKSFSM                 //Clock Switching is disabled, fail Safe clock monitor is disabled
#FUSES NOOSCIO                  //OSC2 is clock output
#FUSES HS                      //External clock with CLKOUT
#FUSES IOL1WAY                  //Allows only one reconfiguration of peripheral pins
#FUSES WPEND_LOW             
#FUSES NOWPCFG               
#FUSES NOWPDIS               
#FUSES WPFP                 
#FUSES RESERVED                 //Used to set the reserved FUSE bits
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Thu Sep 16, 2010 12:03 am     Reply with quote

The secondary oscillator has to be enabled by the SOSCEN bit in OSCCON.

As far as I experienced, the PCD built-in function setup_rtc() also enables the SOSC, even if you don't want it to.
sindyme



Joined: 05 Aug 2009
Posts: 37

View user's profile Send private message MSN Messenger

PostPosted: Thu Sep 16, 2010 12:23 am     Reply with quote

FvM wrote:
The secondary oscillator has to be enabled by the SOSCEN bit in OSCCON.

As far as I experienced, the PCD built-in function setup_rtc() also enables the SOSC, even if you don't want it to.


Then in main, I am setting these function:
Code:

setup_spi(FALSE);
setup_spi2(FALSE);
setup_wdt(WDT_ON);
setup_rtc(RTC_ENABLE | RTC_OUTPUT_SECONDS, 0x00);
setup_timer1(TMR_EXTERNAL|T1_EXTERNAL_RTC|TMR_DIV_BY_1);

But oscilloscope still can't see 32.768 work.

And question 2:
The "rtc_write(datetime)" and "rtc_read(datetime)" can't compile.
CCS give me error msg for "Undefined identifier".

By the way ~ If RTCC work normal, then How can I read RTCC value to printf ? how is the Syntax?
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Thu Sep 16, 2010 10:02 am     Reply with quote

Quote:
But oscilloscope still can't see 32.768 work.

It's working for me with Explorer16 board and 24F256GB110 PIM. May be a problem with your crystal circuit?

Quote:
The "rtc_write(datetime)" and "rtc_read(datetime)" can't compile. CCS give me error msg for "Undefined identifier".

I guess for the variable datetime, if it's undefined?
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Thu Sep 16, 2010 11:04 pm     Reply with quote

sindyme wrote:

And question 2:
The "rtc_write(datetime)" and "rtc_read(datetime)" can't compile.
CCS give me error msg for "Undefined identifier".

By the way ~ If RTCC work normal, then How can I read RTCC value to printf ? how is the Syntax?


the RTC commands read/write a structure.

The typedef for that structure is listed in the .H file...

You would then define a static struct for that using something like

static rtc_time_t mytime;

And now anytime you read/write to the RTC, you'd use syntax like:

rtc_write(&mytime);


Cheers,

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
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