How to define OSC for vlaues below 1mhz? so you get the timing correct.
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
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.