A problem concerning EasyPIC7

Thread Starter

R!f@@

Joined Apr 2, 2009
9,918
Hey guy, Do you recall about an issue I had concerning the LCD slowing down when I changed to internal osc.

Guess what I found.

I needed two more pins for the VA meter project and that is why I went for internal osc. Since it slowed and you guys said it WILL wotk, I thought of starting fresh coding.
I selected the 16F88 int osc with I/O on RA6 and 7.
wrote the code for first display point scrolling and programmed.

To my surprise it was still slow. The easypic jumpers were properly set, that is the crystal jumpers were set as I/O.

This thing was like turtle. Checked everything and still slow.
So put back the HS XTAL (8MHz) changed the setting to HS and programed and it was fast as it can be. :eek:

I thought what gives ?
So changed to int osc at 8Mhz and and tried and it was crawling again.
changed the PIC and still the same.

And it hit me after checking the F88 data.

I added to first line of my code the following;

OSCCON = 0x7E;

Hit program and Viola it was fast.

Why is this happening.? I do not understand. May be one of you could.

Still I need some advice for the OSCON regsitor bits.
************************
REGISTER 4-2: OSCCON: OSCILLATOR CONTROL REGISTER (ADDRESS 8Fh)
Note: The OST is only used when switching to
XT, HS, and LP Oscillator modes.


bit 7 bit 0
bit 7 Unimplemented: Read as ‘0’

bit 6-4 IRCF<2:0>: 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 MHz

bit 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 stable

bit 1-0 SCS<1:0>: Oscillator Mode Select bits
00 = Oscillator mode defined by FOSC<2:0>
01 = T1OSC is used for system clock
10 = Internal RC is used for system clock
11 = Reserved
******************
Above is the 16F88 Osccon register.

I understand form bit7 to bit4.
The rest I need some explanation.
I wanna use the 8Mhz internal osc with OSC pins both as I/O.

Is the 0x7E, which is binary "01111110" OK for my app.
 

THE_RB

Joined Feb 11, 2008
5,438
Looks like you got it right for 8MHz internal RC system clock.

Keep in mind that bit2 is a read-only bit, so it didn't matter how you set bit2. :)
 

BobTPH

Joined Jun 5, 2013
8,816
If you look at the datasheet, the default for OSCCON is all 0's which will be 31.5KHz.

And why are you using a 16F88? That is a dinosaur of a PIC (2 generations back). A PIC16F1847 has twice the program memory, 3 times the RAM, more peripherals, runs faster, and costs less.

Bob
 

Thread Starter

R!f@@

Joined Apr 2, 2009
9,918
I dunno why I am using 16F88

I am don't have the luxury to buy pics with in a day. If I buy I have to wait for a month to get them here.
But I will look around F1847 to buy. If I cannot get the LCD character jumbling issue fixed in the F88 I will get em.
 

t06afre

Joined May 11, 2009
5,934
The default value of the OSCON register is 0x00 after reset/power on So the PIC will by default use a 31.25 kHz system clock the internal osc is select. And that it will do until you set the IRCF<2:0>: Internal RC Oscillator Frequency Select bits to some other value. The rest of bit in the OSCON register should have by default a proper value by default. I do not know your compiler. But a safe approach should be to or the OSCON register with 0b01110000 very early in your program to set 8 MHz speed with the internal oscillator
 
Last edited:

Thread Starter

R!f@@

Joined Apr 2, 2009
9,918
Why won't the compiler set them when I start fresh using the internal osc at initial project settings
 

t06afre

Joined May 11, 2009
5,934
Microcontroller compilers (as far as I know)do not meddle with that kind of settings. Then you set the 8MHz clock for your project. So is that only information to the compiler. It is your job to ensure that the system really use a 8 MHz clock speed
 

THE_RB

Joined Feb 11, 2008
5,438
Once I have a project working with the project CONFIGs the way I like them etc, and I start a new project I just copy the project file to a new folder and edit a couple of filenames within it (to the new name).

It's a bit "old school" but it saves having to re-set all the configs again which can be annoying on some of the new PICs which have so many features.

Another benefit is copying over the .C file too, instead of starting that from scratch. That has the TRIS and ANSEL stuff in it, and timer setups etc. Easier to copy and modify from the last project than to code from scratch.

In the old days when I was more anal I used to save a "blanky" project, which had the configs and a .C file template with all the set ups. Then I would just copy the "blanky" (which was probably a 1second LED flash) and start adding code.
 
Top