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 support@ccsinfo.com

PIC18F4620 + 32kHz and sleep

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



Joined: 26 Feb 2014
Posts: 24

View user's profile Send private message

PIC18F4620 + 32kHz and sleep
PostPosted: Fri May 06, 2016 6:29 am     Reply with quote

Hi All

I am looking to rewrite the firmware of a battery powered data logger. It runs a PIC18F4620 using the internal osc at 8MHz - it also has a 32kHz watch crystal used to track time for wake and sample.

Compiler 5.048

I have been reading around and have the following understanding:
1. usual setup and fuses
2. timer1 setup as secondary oscillator at @ 32 kHz
3. I need to enter SEC_IDLE mode
4. At each timer1 overflow the interrupt adds a tick or commences Run mode.

Do I need to add fuse NOLPT1OSC for no low power t1 osc?
How do you transition between different run modes in CCS -bit set or is there a function?
As the sample rate can vary from 60 sec to days is the interrupt method the only way?

As this is just outside my current realm I am looking for some good pointers to get me on the way.

Cheers
Al
_________________
I type therefore I press buttons
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri May 06, 2016 8:22 am     Reply with quote

alyeomans wrote:
3. I need to enter SEC_IDLE mode

How do you transition between different run modes in CCS -bit set or is there a function?

The 18F4620 data sheet says:
Quote:
3.4.2 SEC_IDLE MODE
This mode is entered from SEC_RUN by setting
the IDLEN bit and executing a SLEEP instruction.

Compiling the test program show below with CCS vs. 5.056 gives the
following .LST file code:
Code:
.................... sleep(SLEEP_IDLE);
0002C:  MOVFF  OSCCON,00
00030:  MOVLW  FC
00032:  ANDWF  OSCCON,F
00034:  BSF    OSCCON.IDLEN
00036:  SLEEP
00038:  MOVFF  00,OSCCON

The compiler sets the bit.

Test program:
Quote:
#include <18F4620.h>
#fuses INTRC_IO, NOWDT
#use delay(clock=4M)
#use rs232(baud=9600, UART1, ERRORS)

//=====================================
void main()
{
sleep(SLEEP_IDLE);

while(TRUE);
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: PIC18F4620 + 32kHz and sleep
PostPosted: Fri May 06, 2016 4:04 pm     Reply with quote

alyeomans wrote:

Do I need to add fuse NOLPT1OSC for no low power t1 osc?

It's optional.

The 18F4620 data sheet says:
Quote:
12.3.2 LOW-POWER TIMER1 OPTION

The Timer1 oscillator can operate at two distinct levels
of power consumption based on device configuration.
When the LPT1OSC Configuration bit is set, the Timer1
oscillator operates in a low-power mode. When
LPT1OSC is not set, Timer1 operates at a higher power
level. Power consumption for a particular mode is
relatively constant, regardless of the device’s operating
mode. The default Timer1 configuration is the higher
power mode.
As the low-power Timer1 mode tends to be more
sensitive to interference
, high noise environments may
cause some oscillator instability. The low-power option is,
therefore, best suited for low noise applications where
power conservation is an important design consideration.


Graph for low power mode:
Quote:
FIGURE 27-4: TYPICAL T1OSC DELTA CURRENT vs. VDD ACROSS TEMP. (DEVICE IN SLEEP, T1OSC IN LOW-POWER MODE)


Graph for high power mode:
Quote:
FIGURE 27-6: TYPICAL T1OSC DELTA CURRENT vs. VDD ACROSS TEMP. (DEVICE IN SLEEP, T1OSC IN HIGH-POWER MODE)
alyeomans



Joined: 26 Feb 2014
Posts: 24

View user's profile Send private message

PostPosted: Fri May 06, 2016 4:57 pm     Reply with quote

Thank you PCMProgrammer. I was a little lost before and your guidance is appreciated. I feel i am ready to start experimenting.

The device will be in a shielded case so I will test for the low power stability first.
_________________
I type therefore I press buttons
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