Bits 0 through 3 of OSCCON are read only?
Bits 0 through 3 of OSCCON are read only?
Last edited by mackrackit; - 16th May 2013 at 14:58.
Dave
Always wear safety glasses while programming.
Actually it compiles , but after careful testing, the frequency is all over the place when using only OSCCON = %01001110..
Hi All. After reading this thread, it made me look at something I now don't understand. I've been using this table for years for 'F819 and 'F88. But when you convert the decimal numbers to binary, the bits don't match the table in the datasheet. When you pick the bits and convert to decimal, they don't match the table. Does anyone know why? Thank you.
'osccon values for 16f818/819:
'OSCCON = $00 'for 31.25 khz
'OSCCON = $10 '125khz
'OSCCON = $20 '250khz
'OSCCON = $30 '500khz
'OSCCON = $40 '1mhz
'OSCCON = $50 '2mhz
OSCCON = $60 '4mhz 'set int osc to 4mhz
'OSCCON = $70 '8mhz
You can change READ-ONLY registers all you want. The PIC will just ignore your requests at best.
Robert
As you can see, the 4MHZ is uncommented. If you convert the number to binary, it doesn't match the osccon bits in the datasheet when you select 4MHZ. Same with the reverse, select the 4MHZ bits in the datasheet, convert to decimal and it doesn't match the table. Yet, the numbers in the table do work.
'osccon values for 16f818/819:
'OSCCON = $00 'for 31.25 khz
'OSCCON = $10 '125khz
'OSCCON = $20 '250khz
'OSCCON = $30 '500khz
'OSCCON = $40 '1mhz
'OSCCON = $50 '2mhz
OSCCON = $60 '4mhz 'set int osc to 4mhz
'OSCCON = $70 '8mhz
These hex values match the 16F818 as expected.
from your code..........................
'osccon values for 16f818/819:
'OSCCON = $00 'for 31.25 khz
'OSCCON = $10 '125khz
'OSCCON = $20 '250khz
'OSCCON = $30 '500khz
'OSCCON = $40 '1mhz
'OSCCON = $50 '2mhz
OSCCON = $60 '4mhz 'set int osc to 4mhz
'OSCCON = $70 '8mhz
from the data sheet.....................
bit 6-4 IRCF2:IRCF0: Internal Oscillator Frequency Select bits
111 = 8 MHz (8 MHz source drives clock directly)
110 = 4 MHz
101 = 2 MHz
100 = 1 MHz
011 = 500 kHz
010 = 250 kHz
001 = 125 kHz
000 = 31.25 kHz (INTRC source drives clock directly)
I don't understand the issue?
Dave Purola,
N8NTA
EN82fn
Never mind
Last edited by Demon; - 17th May 2013 at 14:00.
Sorry Dave. I still don't get it. 60 on the table I use comes out to 0111100 in binary. Are we choosing the bits from left to right (MSB first) instead of right to left (LSB first)?
I think this is the problem
You are reading $60 as decimal when it is a HEX number
60 = 00111100 in binary
$60 = 01100000 in binary
Phil
Bookmarks