Power managmenet modes

Discuss PIC and electronic related things

Moderators: David Barker, Jerry Messina

Post Reply
liak
Registered User
Registered User
Posts: 195
Joined: Fri Oct 05, 2007 12:26 am

Power managmenet modes

Post by liak » Sat Sep 06, 2008 9:01 am

Dear all,
I am trying out some features in my PIC. I understand that the PIC can be put into various power management modes. I have read through the datasheet. It seems a bit confusing for me to choose the proper mode for my use.
From the various CPU and peripheral clocked combination, I want to apply a proper sleep mode. I am trying to put my PIC into sleep mode from a certain time and then re-activates itself after a certain time has passed (counting presumed by watchdog or Timer1). In a way, it is sort of like an alarm clock or auto-timer. Anyone has any idea on which mode to use or any info to offer?

Thanks. BTW, I am using 18F2525.

Regards,
Liak

User avatar
ohararp
Posts: 194
Joined: Tue Oct 03, 2006 11:29 pm
Location: Dayton, OH USA
Contact:

Post by ohararp » Sat Sep 06, 2008 12:30 pm

Here are the declares I use for the 18F4620 and the GPS Logger I am selling. This code was adapted from a PDS example posted by Bruce from Rentron.

Code: Select all

// Device And CLOCK
Device = 18F2620
Clock =  40

//Device FUSE CONFIG
Config
    OSC 	= HSPLL,		// HS Oscillator
    FCMEN	= OFF,		// Failsafe Clock Monitor Disabled
    IESO	= OFF,		// Int/Ext Oscillator Switch Over Disabled
    PWRT	= OFF,		// Power Up Timer Disabled
    BOREN	= OFF,		// Brownout reset Disabled
    WDT     = OFF,		// WATCHDOG Timer Disabled
    MCLRE	= On,		// MCLR Enabled
    WDTPS   = 256,       // 15000 X 4mS  = 60 seconds
    LVP     = OFF,      // Low_Voltage Programming
    PBADEN  = OFF       // PORTB Digital 

Code: Select all

//*****************************************************************************
Sub PIC_SLEEP(pINTERVAL As Word)
    Dim X As Word
    
    If pINTERVAL > 0 Then
        If pINTERVAL > 29 Then 
            GPS_SLEEP()        
        EndIf
        
        X = pINTERVAL
        WDTCON = 1 'Software Enable WDT
        Repeat
            ASM 
                Sleep
                nop 
            End ASM 
            Dec(X)
        Until X = 0 
        WDTCON = 0 'Software Disable WDT
        
        If pINTERVAL > 29 Then 
            GPS_WAKE()        
        EndIf
    EndIf    
End Sub
//*****************************************************************************
Thanks Ryan
$25 SMT Stencils!!!
www.ohararp.com/Stencils.html

liak
Registered User
Registered User
Posts: 195
Joined: Fri Oct 05, 2007 12:26 am

Post by liak » Mon Sep 08, 2008 2:00 pm

Dear Ohararp,
Thanks for your swift reply. Will try to adapt your code. Will tell you if I manage to get anything working.

Regards,
Liak

Post Reply