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

setup_oscillator, OSC_INTRC, OSC_31Khz, too high current

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



Joined: 29 Sep 2006
Posts: 120

View user's profile Send private message

setup_oscillator, OSC_INTRC, OSC_31Khz, too high current
PostPosted: Sun Jan 06, 2008 6:02 am     Reply with quote

Hi,

I found out that setting up the oscillator with setup_oscillator(OSC_INTRC | OSC_31KHZ) does not select the 31Khz output from the internal oscillator block.
The cause of this lays in not clearing the INTSRC bit when calling this function. CCS set this bit as default as entry of the Main() function. You will find
...
00562: CLRF FD3 //clear osccon
00564: MOVLW 80 //load 0x80 in W
00566: MOVWF F9B //mov W to Osctune;
>> BIT INTSRC is SET, this enables the divide-by-256 and selects the 31.250 source (or one of the others depending on the bits in OscCon)
..

then setup_oscillator(OSC_INTRC | OSC_31KHZ) is only compiled to:
00580: MOVLW 02
00582: MOVWF FD3
00584: MOVF FD3,W

Thus NOT clearing the INTSRC bit anymore.

I found this issue because I want to run the PIC(LF4620) in it's lowest power; 31Khz RC-mode. This should, according to the datasheet, draw max 60uA at Vdd=3v. Before finding this issue the current was ~230uA. Almost 4 times too high, so something had to be wrong. After clearing the INTRC bit, it now runs at ~40uA

My conclusion, besides the CCS bug, is that the enabling the postscaler draws about 190uA ! That is relatively lot off current for a little faster ;-) Laughing

Kind regards,
Edwin
CCS version 4.064
Ttelmah
Guest







PostPosted: Sun Jan 06, 2008 8:06 am     Reply with quote

What _fuse_ setting are you putting for the oscillator?.
If you select _LP_, then the compiler assumes you want the low power 31KHz mode. If you select any other mode, then it assumes you want the high power mode, and behaves as you describe.

Best Wishes
Torello



Joined: 29 Sep 2006
Posts: 120

View user's profile Send private message

PostPosted: Sun Jan 06, 2008 8:47 am     Reply with quote

I'm using INTRC_IO. According to the datasheet the LP fuse should be used when an external crystal/resonator is used. I want to use the internal oscillator block.

Quote:

In XT, LP, HS or HSPLL Oscillator modes, a crystal or
ceramic resonator is connected to the OSC1 and
OSC2 pins to establish oscillation. Figure 2-1 shows
the pin connections.


regards,
Edwin
Ttelmah
Guest







PostPosted: Sun Jan 06, 2008 8:56 am     Reply with quote

You'll find if you select LP, it'll default to the low power operation. It is perhaps not following the data sheet, but it is the way that CCS does it...
What is silly, is that they have a separate 'OSC_31250' setup, which enables the high current mde, but the OSC_31KHz, doesn't turn it off. Report it as a bug, since it is wrong.

Best Wishes
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