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


Closed Thread
Results 1 to 2 of 2
  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 !!!

  2. #2
    Join Date
    Jun 2006
    Location
    Bangalore, India
    Posts
    136


    Did you find this post helpful? Yes | No

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

    Not possible.
    Just define OSC as 4 or something and use 32Khz crystal with LP OSC fuse (internal RC osc can also be used).
    Everything will run much S-L-O-W. Like 122.0703125 times slower if OSC is defined as 4Mhz and 32Khz crystal is used.
    But this way all the time related statements like PAUSE will be thrown off.
    Last edited by shahidali55; - 3rd May 2011 at 16:27.

Members who have read this thread : 1

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