Menu

problem with a 18F4455 chip

Help
2016-04-22
2016-04-23
  • Edward LaBudde

    Edward LaBudde - 2016-04-22

    Hi, I have a very interesting problem I have never seen before. Am am using a 16 MHz resonator and the timing on the chip is exactly 2 time slower than it should be. Is it possible this is due to an error in the chip data? This condition is true for all the chip family. Thanks, In advanced Ed.

     
  • Edward LaBudde

    Edward LaBudde - 2016-04-22

    More info. Tried the hardware port with the same result. So now I am totally confused!! HELP!!!

     
  • Hugh Considine

    Hugh Considine - 2016-04-23

    Sounds like something isn't quite right in the #config. These chips are a bit tricky to set up, I found some settings that work for me on the 18F4550 a few years ago and now just copy and paste them into any new programs! There are a few different multipliers and dividers in the oscillator.

    Can you post the #chip and #config lines from your program?

    I normally use this on an 18F4550 with a 20 MHz crystal, running the CPU at 48 MHz:

    #chip 18F4550, 48
    #config FOSC=HSPLL_HS, PLLDIV=5, CPUDIV=OSC1_PLL2,
    

    Have a look at the datasheet, figure 2-1, to see a block diagram of the system. PLLDIV=5 divides the 20 MHz from the crystal down to 4 MHz. This then goes into the PLL block, which produces 96 MHz. CPUDIV then causes this to be divided by 2, giving 48 MHz, and using FOSC=HSPLL_HS sends this through to the CPU.

     
  • Edward LaBudde

    Edward LaBudde - 2016-04-23

    Hugh, Here is the #conig from the .asm file:
    Program compiled by Great Cow BASIC (0.95 2015-12-27)
    ;Need help? See the GCBASIC forums at http://sourceforge.net/projects/gcbasic/forums,
    ;check the documentation or email w_cholmondeley at users dot sourceforge dot net.

    ;**************

    ;Set up the assembler options (Chip type, clock source, other bits and pieces)
    LIST p=18F2455, r=DEC

    include <p18f2455.inc></p18f2455.inc>

    CONFIG LVP = OFF, MCLRE = OFF, WDT = OFF, FOSC = HS

     
  • Edward LaBudde

    Edward LaBudde - 2016-04-23

    Hugh, can you post your code for your config that worked for you. Thanks, Ed.

     
  • Hugh Considine

    Hugh Considine - 2016-04-23

    Ed, those two lines I posted above are all that is needed to get the speed right when running an 18F4550 at 48 MHz from a 20 MHz crystal. To run the 18F2455 at 16 MHz from a 16 MHz resonator, try something like this:

    #chip 18F2455, 16
    #config OSC=HS, CPUDIV=OSC1_PLL2
    

    Another option might be to multiply and divide the frequency back:

    #chip 18F2455, 16
    #config OSC=HSPLL_HS, PLLDIV=3, CPUDIV=OSC4_PLL6
    

    Try that #chip line and one of the two #config lines, and see if either of them gets the chip running at the right speed. I haven't tried either of those configurations in hardware, but they both look like they should work from the datasheet.

     
  • Edward LaBudde

    Edward LaBudde - 2016-04-23

    Hugh, The first config works ok but I still have to make the init rate of 19,200 to get 9600 baud rate. It is a little unstable in the first line of the LCD. Printing out "hello world" First line some times shows ello or Vell0. The second did not work at all!. It think I will try a different chip. Thanks, Ed.

     

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.