Skip to content

PIC Configuration Bits (part 2)

LDmicroGitHub edited this page Mar 2, 2018 · 9 revisions

See part 1

Example 3
Select PIC16F88 internal oscillator 8 MHz
RA5 - Input pin.
RA6, RA7 - Bidirectional I/O pin.

image
image
Note: First PLC cycle will wrong, but next will right 1ms.
pic16f88intosc8mhz
PIC16F88intOsc8MHz.ZIP
Q: What is 0X72 in your example?
image

Example 4
Q: How to set internal oscillator frequency to 8MHz or 4 MHz or 32kHz for PIC16F886? (by Mukesh Pandey) Sat Nov 25 2017

LDmicro defines PIC16F886 configuration words in mcutable.h as 0x3EFF23E2:
(0x38 << (8+16)) | // Unimplemented: Read as 1
(3 << (9+16)) | // flash write protection off
(0 << (8+16)) | // BOR at 2.1 V
(0xff << 16) | // Unimplemented: Read as 1
(1 << 13) | // ICD disabled
(0 << 12) | // LVP disabled
(0 << 11) | // fail-safe clock monitor disabled
(0 << 10) | // internal/external switchover disabled
(3 << 8) | // brown-out detect enabled
(1 << 7) | // data code protection disabled
(1 << 6) | // code protection disabled
(1 << 5) | // nMCLR enabled
(0 << 4) | // PWRTE enabled
(0 << 3) | // WDTE disabled
(2 << 0), // HS oscillator
default
default

First, you need to change "FOSC: Oscillator Selactin bits" to "INTOSCIO oscillator: I/O function on RA6, I/O function on RA7"
default
and set configuration words to 0x3EFF23E4
default

After compile LD file you get default internal oscillator frequency 4 MHz
default

Second, to set internal oscillator frequency to 32 kHz you need to change OSCCON: OSCILLATOR CONTROL REGISTER to 0x08
default

To set internal oscillator frequency to 8 MHz you need to change OSCCON: OSCILLATOR CONTROL REGISTER to 0x78
default

PIC Configuration Bits (part 3)

Any questions to LDmicro.GitHub@gmail.com

Clone this wiki locally