How to define OSC for vlaues below 1mhz? so you get the timing correct.


Results 1 to 2 of 2

Threaded View

  1. #1
    Join Date
    Feb 2011
    Posts
    26

    Default How to define OSC for vlaues below 1mhz? so you get the timing correct.

    Code:
    Define OSC ??
    I like to run stuff at the slowest possible speed, to save battery power.
    -- most of the time accuracy is not important.

    32khz is not defined.

    So I use the shift:

    Code:
    running on a 12f683 :D
     
    'low speed osccon 31khz 
    'bit 6-4 IRCF<2:0>: Internal Oscillator Frequency Select bits
    '                               correction 
    '                               by shifting
    '                                   |
    '                                   v
    '       111 =8MHz
    '       110 =4MHz (default)         0
    '       101 =2MHz                   1   2
    '       100 =1MHz                   2   4
    '       011 =500kHz                 3   8
    '       010 =250kHz                 4   16
    '       001 =125kHz                 5   32
    '       000 =31kHz (LFINTOSC)       7   128
     
            OSCCON.6 = 0
            OSCCON.5 = 0
            OSCCON.4 = 0
    speed_shift  con   7   '  use 0-7 : oscillator / delay correction by shifting
     
    ...
     
    Sub-rountines
     
    X = Word, in milliSeconds, 
     
    Be careful of the bits you have leftover is speed_shift =7 then the smallest number is 128 [2^7]
     
    ' Speed affected by the CPU clock speed
    Lamp_ON:
        TRISIO = ALL_INPUTS - led
        GPIO =   led
        Pause X >> speed_shift ' Delay for on time in milliseconds
        TRISIO = ALL_INPUTS    ' Set to all inputs to save power
    Return
     
    OFF_Lamp:
        TRISIO = ALL_INPUTS 
        Pause X >> speed_shift ' Delay for on time in milliseconds
    Return
    Last edited by Acetronics2; - 3rd April 2011 at 10:15. Reason: title modified : it was not a question !!!

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts