hi, i'm going to use 16F88 with internal oscillator. I can't figure how can i select the 8 Mhz frequence with osctune register...
Do you know it ?
thanks
hi, i'm going to use 16F88 with internal oscillator. I can't figure how can i select the 8 Mhz frequence with osctune register...
Do you know it ?
thanks
In the PIC16F87.88 datasheet on page 39, it states:
"The clock source frequency (INTOSC direct, INTRC direct or INTOSC postscaler) is selected by configuring the IRCF bits of the OSCCON register (page 40)."
It also states: "The main output (INTOSC) is an 8 MHz clock source which can be used to directly drive the system clock. It also drives the INTOSC postscaler which can provide a range of six clock frequencies from 125 kHz to 4 MHz."
So when we go to page 40....
we see:
000000 = Center frequency. Oscillator module is running at the calibrated frequency.Then when we move forward a little, to page 42 (clearly a typo in the datasheet, but by reading everything we can find it)
We see: REGISTER 4-2: OSCCON: OSCILLATOR CONTROL REGISTER (ADDRESS 8Fh) Aha!! The register named above
So looking at the IRFC bits (as named above also) we see: bit 7 Unimplemented: Read as '0'
bit 6-4 IRCF: Internal RC Oscillator Frequency Select bits
000 = 31.25 kHz 001 = 125 kHz 010 = 250 kHz 011 = 500 kHz 100 = 1 MHz 101 = 2 MHz 110 = 4 MHz 111 = 8 MHzbit 3 OSTS: Oscillator Start-up Time-out Status bit(1)
1 = Device is running from the primary system clock 0 = Device is running from T1OSC or INTRC as a secondary system clock Note 1: Bit resets to '0' with Two-Speed Start-up mode and LP, XT or HS selected as the oscillator mode.bit 2 IOFS: INTOSC Frequency Stable bit
1 = Frequency is stable 0 = Frequency is not stablebit 1-0 SCS: Oscillator Mode Select bits
00 = Oscillator mode defined by FOSC 01 = T1OSC is used for system clock 10 = Internal RC is used for system clock 11 = ReservedDatasheet at
Read the fascinating datasheet.
Cheers
PeteS
I don't know of any way to do it with osctune, but you can load OSCCON as documented in the datasheet. You may need to specify something like _INTRC with your __CONFIG directive to make it work. I've had success using the following code.
If you need ultra low power sleep current, then you should set the oscillator to 32kHz. The datasheet doesn't say that, but I found it was necessary to get the sleep current way down. The errata specifies other problems with low sleep current, but didn't exactly seem to cover my circumstances.
bsf STATUS, RP0 ; BANK 1
movlw b'01110000' ; Set internal osc to 8Mhz movwf OSCCON & 0x7F
bcf STATUS, RP0 ; BANK 0
thanks to all, ...i've lost my mind in the datasheet !
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.