FOSC2:FOSC0 Settings for PIC16F819

Thread Starter

ronbowalker

Joined Jun 26, 2009
23
Below is a ticket I processed with Microchip on this issue. As well as the response I got. I am not familiar with the info (FOSC2:FOSC0) they gave me and need assistance in writing this in PBP. I have found that 31.25kHz is defined as "100" on the datasheet. I am also using INTIO2 on the programming configuration, making pins 6 & 7 as I/O ports.

Description:Using Pic Basic Pro as programming tool:

I am trying to initialize the 16F819 for:

Pins A.0, A.1, A.3, B.0, B.1, B.2, B.3, B.4, B.5 to be OUTPUT/LOW (Digital).

Pins A.7 and B.0 to be OUTPUT/HIGH (Digital).

Pins A.6, B.6, A.2, A.4 to be input pins.

I am also wanting to configure the OSC to be 31.25kHz internal. What configuration settings do I use for this?

Resolution:I'm not familiar with Pic Basic Pro but the registers that need to be configured for the I/O are below.

TRISA
TRISB
PORTA
PORTB
OSCCON
ADCON1

The MCLR pin configuration will depend on how you want to use the Pin. If you want to use it as an input you need to clear the MCLRE bit in the configuration bits register. Otherwise if it is to be used as a reset the MCLRE bit must be set to a 1.

If you want to use the Internal Oscillator as your primary clock you need to have the Fosc2:Fosc0 bits in the configuration bits register programmed as 100.

Here is the program I am using, and I get no HIGH outputs. Assistance would be greatly appreciated.


DEFINE OSC 3
OSCCON = %00001000
ADCON1=7
TRISA = %01110100
TRISB = %10100000
PORTA.0 = 0
PORTA.1 = 0
PORTA.3 = 0
PORTA.7 = 1
PORTB.0 = 1
 

eng1

Joined Oct 25, 2009
13
I can't help with basic, but you must tell the compiler that you want to use the internal oscillator. As suggested, you have to configure bits Fosc2:0 bits of the configuration word.
You can probably do that manually in the programming enviroment (not recommneded) or do it in code through @device at the beginning of your program, I guess. Google can find more information on this topic.
 
Last edited:

Thread Starter

ronbowalker

Joined Jun 26, 2009
23
I have been trying to find the answer on a lot of different forums, but still nothing. Thanks for the assistance.

A lot of people are viewing this call for help, but none are responding!
 

AlexR

Joined Jan 16, 2008
732
As eng1 stated to use PIC's the internal oscillator you have to set the configuration word (also sometimes referred to as the fuse settings). This is not one of the normal SFR's and it requires its own special command.

Unfortunately the command to set the configuration word does not exist in PBP so the work-around is to issue the command as a line of embedded assembler code. The issue is further complicated by the fact that PBP can be set up to either use its native assembler (PM) or Microchip's MPASM assembler and the commands are not the same in the two assemblers.

In PM the command to use the internal oscillator would be:
@ DEVICE pic16f819, INTRC_OSC
The "@" signifies assembler code, "DEVICE" tells the assembler to load the config word, pic type indicates where and INTRC_OSC is the value. The actual values are in the pic16f81X.inc file. If you want to set several paramaters at the same time just seperate them with commas, eg @ DEVICE pic16f819, INTRC_OSC, WDT_OFF sets oscillator to internal and turns off the watchdog timer.

If you are set up to use MPASM then the command would be
@ __config INTRC_OSC
Or for muliple statments just and them as: @ __config INTRC_OSC & WDT_OFF
Note the double underscore at the beginning of the config command!
 

Thread Starter

ronbowalker

Joined Jun 26, 2009
23
Thanks for the help and sorry for the slow reply....I went on holiday and just got back. I followed your suggestions and here is what I found to apply to my PBP assembly.

The following compiles correctly:

@__Config_INTIO2_OSC
@__Config_WDT_ON

This gives error message "Error[108]:Illegal Character (&)" :
@__Config_INTIO2_OSC & WDT_OFF
 

Thread Starter

ronbowalker

Joined Jun 26, 2009
23
I replied and gave you the settings in another thread,(http://forum.allaboutcircuits.com/showthread.php?t=30378) did you try those settings?
FOSC settings in PBP is what I do not know correctly.

OSCCON $00000000 works fine and the chip is running @ 85uA.

I have config settings (INTRC INTRIO2) and the pins 6&7 seem to be outputs now.

But LED does not blink:

DEFINE OSC 3
OSCCON = %00000000
ADCON1=7
TRISA = %00000000 'Outputs
TRISB = %00000000 'Outputs
PORTB.4 = 0 'Pin 10 Low


LOOP:
PULSOUT PORTB.4,20 'pin 10 Pulse LED
Pause 20

Goto LOOP
 
Last edited:
Top