A problem concerning EasyPIC7

Discussion in 'General Electronics Chat' started by R!f@@, Apr 27, 2014.

  1. R!f@@

    Thread Starter AAC Fanatic!

    Apr 2, 2009
    8,754
    760
    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.
     
  2. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    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. :)
     
  3. R!f@@

    Thread Starter AAC Fanatic!

    Apr 2, 2009
    8,754
    760
    Sweeeet!

    So any why the it is not programing the initial settings
     
  4. BobTPH

    Active Member

    Jun 5, 2013
    782
    114
    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
     
    SgtWookie likes this.
  5. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    And it's compatible with MikroC 6.0 as well!
    MikroC 6.0 supports lots of PIC16F18xx and PIC16F19xx MCUs; if you're going to use it be sure to check for compatibility on their website: http://www.mikroe.com/mikroc/pic/specification/
     
  6. R!f@@

    Thread Starter AAC Fanatic!

    Apr 2, 2009
    8,754
    760
    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.
     
  7. BobTPH

    Active Member

    Jun 5, 2013
    782
    114
    That is likely a software problem that will not be fixed by using a different PIC.

    Bob
     
  8. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    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: Apr 28, 2014
    R!f@@ likes this.
  9. R!f@@

    Thread Starter AAC Fanatic!

    Apr 2, 2009
    8,754
    760
    Why won't the compiler set them when I start fresh using the internal osc at initial project settings
     
  10. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    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
     
    R!f@@ likes this.
  11. R!f@@

    Thread Starter AAC Fanatic!

    Apr 2, 2009
    8,754
    760
    Gotcha....!
     
  12. BobTPH

    Active Member

    Jun 5, 2013
    782
    114
    Yes, you really don't want the compiler modifying random settings for you.

    Bob
     
  13. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    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.
     
Loading...