Menu

Oscillator trouble with 18F45K20 on 44 pin Evaluation Board

2015-02-05
2015-02-18
  • James Leavy

    James Leavy - 2015-02-05

    Just getting started with a 18F45K20 on a 44 pin eval bd. No matter what clock speed I try after declaring the chip, my wait timer is half what it should be. If I 'wait 10sec' the LED is lit for just 5 seconds.

    I have tried adding various forms of:

    config osc=int

    without any luck. Can someone give me some help? Thanks!

     
  • David Stephenson

    I think on these type of chips (18F) the config needs to be
    OSC=INTIO67

    Whatever that is supposed to mean.
    You can find these values in the GCBasic chipdata file.

     
  • Chuck Hellebuyck

    INTIO67 means internal oscillator and B6, B7 are I/O pins.

     
  • Peter Stone

    Peter Stone - 2015-02-06

    I use the 18F26K22 (I believe from the same family) and can confirm that INTIO67 works fine when using the internal oscillator block.

    Peter.

     
  • James Leavy

    James Leavy - 2015-02-07

    I have the following header code:

    chip 18F45K20,8

    config OSC = INTIO67

    Everything compiles fine, but my 'wait 10 sec' are still just 5 seconds long!
    I have tried 1,2,4,10,16,32 instead of 8 after the #chip 18F45k20. All variations compile, but my LED only blinks on and off for 5 seconds for the 1,2,4,or 8 values. Above 8 it compiles but doesn't run at all.

    Thanks for any and all suggestions.

     
  • Anobium

    Anobium - 2015-02-07

    Please send me a personal message and I will provide a release that has some fixes for your chip.

     
  • Hugh Considine

    Hugh Considine - 2015-02-07

    There was an issue with the some of the automatic initialisation code for the internal oscillators on some PIC chips. They were fixed just the other day, try replacing your copy of system.h (in include\lowlevel) with the one from https://sourceforge.net/p/gcbasic/code/HEAD/tree/GCBASIC/trunk/include/lowlevel/system.h?format=raw and see if that helps!

     
  • James Leavy

    James Leavy - 2015-02-08

    Hugh,
    I replaced the old system.h with the new one in your link. There were no changes in the PIC timimg, so I rebooted my PC and tried again, but still no changes.
    Can I try something else/or other config setting?
    Thanks for all your help and effort.

     
  • kent_twt4

    kent_twt4 - 2015-02-08

    Here is my config for a 18f26k20 way back in 2009. Had problems with INTIO67 back then too it would appear?

    'Chip model  
    #chip 18F26K20,16
    #config OSC = HSPLL
    '#config OSC = INTIO67
    '#config MCLR = On
    
     
  • Hugh Considine

    Hugh Considine - 2015-02-08

    I've just made another change to the system.h file, which hopefully will do something. Please try again (same link as above) and see if it is any better!

    I think this issue is particular to the 18FxxK20 family, which have some slightly different bit names to most other chips.

    (Shouldn't need to restart your PC, GCBASIC should pick up the new file as long as it's in the right place!)

     
  • James Leavy

    James Leavy - 2015-02-08

    Kent,
    I tried your #config OSC= HSPLL but no changes. Thanks for your post, though.

    Hugh, tried the latest system.h, again no changes.

    Heading out for a few hours, will try the code you sent via email then.

    Thanks!

     
  • James Leavy

    James Leavy - 2015-02-08

    Hugh, Should I replace my existing demos with the new?

    I got the timer working, went back to the 18F45K20 datasheet and saw where the OSCCON register is used to determine a bunch of oscillator settings.

     #chip 18F45K20,16
    OSCCON = 118    
    

    seems to clear up my timing issue. Thanks for all your help with this.

    My next issue is that my standard 2 x 16 LCD that was working fine on my 28 pin demo board doesnt work with my 44 pin demo board. I have the following LCD config code:

    #define LCD_IO 4
    #define LCD_Enable PORTA.2
    #define LCD_RS PORTA.0
    #define LCD_DB4 PORTA.3
    #define LCD_DB5 PORTA.4
    #define LCD_DB6 PORTA.5
    #define LCD_DB7 PORTA.6
    #define LCD_RW PORTA.1
    

    One thing I need to check is that the 28 pin demo bd and LCD was running off 5 v. This new 44 pin demo bd is 3.3 volt. Perhaps my (Hitachi HD44780)LCD bd is 5v only? Will need to dig out the specs if I can find them.

    Any suggestions for a 2 x 16 LCD that works well on 3.3V?

    Thanks again to all for your help.

     

    Last edit: Anobium 2015-02-08
    • Anobium

      Anobium - 2015-02-08

      We need to get this sorted in the compiler. I know Hugh is looking into this issue.

       
    • Anobium

      Anobium - 2015-02-08

      Regarding the LCD. It depends. You would have to check the datasheet for the operating voltages - there are many, many different LCD on the market.

      For you current LCD try setting the following, it may work.

      #define LCD_SPEED SLOW   
      

      And, what is the release date for your GCBASIC.EXE compiler?

      Re: 'Should I replace my existing demos with the new?' - no sure what you mean. Do you mean the new demo's?

       
  • James Leavy

    James Leavy - 2015-02-08

    I appear to be running version 0.8.3697.40784 created June 13, 2013.

    Adding #define LCD_SPEED SLOW helped with the writing to the LCD - Thanks

    The LCD still has almost no contrast at 3.3v. I found and ordered a couple new LCDs that are claimed to be 3V compatible.

    Thanks again for everyone's help. This is a great site with quick, knowledgeable contributors.

    Hopefully the OSCCON =118 info will help others getting started with the 18F45K20 44 pin demo bd oscillator issue.

     
  • viscomjim

    viscomjim - 2015-02-09

    Hello James,

    I have used the LCD with the Hitachi HD44780 controller with a 3.3v pic. The way this worked for me was that the power to the lcd (pin2) and the contrast control (using 10k variable resistor to pin 3), were at 5v and the 6 data lines (RS, EN, D4, D5, D6, D7) were connected to the 3.3v pic. Worked just fine!

     

    Last edit: viscomjim 2015-02-09
  • James Leavy

    James Leavy - 2015-02-18

    visco,
    I tried the same thing (lcd tied to 5v, all interface lines tied to 3.3 v pic chip). It locked up the chip and wouldnt run. I purchased a 3.3 backlit 2 x 16 from sparkfun and it worked fine. Thanks for all the suggestions!

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.