Menu

changing from 16F1789 to 18f25k80

Help
2016-11-07
2016-12-27
1 2 > >> (Page 1 of 2)
  • David Stephenson

    As I have a quite a few 18f25k80 chips I was trying to make a direct substitiution for a 16f1789 (which I have run out of).
    It is not working - can anybody think of anything obvious that needs to be changed.
    It is driving a ILI9340 display ,but the screen just comes on blank (white).

    #chip 18f25k80,16
    #config MCLRE=off, WDTEN=Off, boren=off, XINST = OFF
    dir portc.7 out 'ttf logic on
    set portc.7 off 'pnp
    wait 100 ms
    #include <glcd.h>
    'cs/ss possible conflicts!
    'Defines for ILI9341
    #define GLCD_TYPE GLCD_TYPE_ILI9340
    'Pin mappings for ILI9340
    #define GLCD_DC portc.2
    #define GLCD_CS portc.6 ' should this be ra5?
    #define GLCD_RESET portc.1
    #define GLCD_DI portc.4
    #define GLCD_DO portc.5
    #define GLCD_SCK portc.3
    #define ILI9340_hardwarespi
    
     
  • Anobium

    Anobium - 2016-11-07

    Version etc? See https://sourceforge.net/p/gcbasic/discussion/579126/thread/b1d3c9ee/#e1c8

    The GLCD driver may never have been tested on an 18f. I know it has not been tested by me. Easily adaptable.

    Up for the challenge? As I can point you at the section what would be need to be updated. It would be a good capability to add.

    And, my guess. This software version of SPI worked? If you have not try please do.

     
  • David Stephenson

    I'm on version 95.009.
    I just "rem out" the hardwarespi line to go to software spi ? (the help file is not very detailed for SPI mode). If I do that I get the same result.

    I'm a bit clueless, but if you point me to the section I will have a try.
    The other questions I have is should I have hooked up GLCD_CS to porta.5 when running hardwarespi? That would make it difficult to connect more than one device though.

    I'm also at a loss what I should put in the #config line for the oscillator mode

     
    • Anobium

      Anobium - 2016-11-07

      I see. Get an LED running first. Look at the LED demos as should sort config out.

      When you have the config sorted retry this glcd code.

      I am sure other are better than I to advise on the correct configuration.

       
  • David Stephenson

    All the posts above I should have put 16f1788 (the 1789 is the 40 pin version) .

     
    • Anobium

      Anobium - 2016-11-07

      That's ok. Get something simple running first then return the GLCD driver.

      GLCD is easily fixable.

      18f config.... probably harder. :-)

       
  • Anobium

    Anobium - 2016-11-07

    I just checked the demos. Config looks not to be an issue.

    Let me spin up a chip here and I can check out the 18f.

     
    • Anobium

      Anobium - 2016-11-08

      I checked out the basic LED functionality. 18f45k80 (same family) works OK with LED demos. So, oscillator is being set.

      Can you check connectivity etc? This should work without changes as I can see nothing odd in the ASM.

       
  • David Stephenson

    What are you putting on the #config line?
    I was thinking I should put OSC=EC3 ,but if I do that the lcd backlight does not even come on.
    If I leave out the OSC the backlight comes on but the clear screen followed by text does not execute.
    If I use the same program with a 16F1788 it all works.
    I will attach the program (sorry its so messy).

     
  • Anobium

    Anobium - 2016-11-08

    The config is automatic on this chip. So, we should not need to change.

    Can you me a piece of code with just the minumum to get the glcd working. Nothing but a working solition say 'GCB' on the screen - so, just the back working on your 1788.

    Thanks

     
  • David Stephenson

    Here a small piece of the code that works for 16f1788 but not for 18f25k80.
    The only complication is that portc.7 and porta.3 have to be set to off as they control power to the logic and backlight.

     
    • Anobium

      Anobium - 2016-11-08

      Try the ILI9340 driver.

      What are the results?

      I am getting a working result here - but, I want to know you results.

       
  • David Stephenson

    Isn't it using the ILI9340 driver already?
    I just get a blank screen (white).

     
    • Anobium

      Anobium - 2016-11-08

      No the two drivers are very different in terms of the init etc. but then they are the same drivers.

      So, I have found a condition that may be the issue.

      I am testing 16f1789 and 18f45k80 so this should represent the same chips you have. Luckily, I have the TBL+ bootloader on the 16f so I do not have to use IPE!!! Yipee.

      Give me 10 mins testing.

       
      • Anobium

        Anobium - 2016-11-08

        Send me an email. I will send you two new drivers.

        The 18f is not correctly handling the SPI commands and one wait could be very marginal.

        I have tested on 9341 but these issues will be the same on the 9340.

        I do not think you need to call the init code either - look at my attachments.

         
      • kent_twt4

        kent_twt4 - 2016-11-08

        PK2 GUI still lives thanks to Wiliams work https://sourceforge.net/p/gcbasic/discussion/629990/thread/d59cd035/#c207. Supposedly 16f1789 has been tested. Been using the 1_150_GCB.dat version for awhile now even though I don't anticipate using the 16 or 32 bit devices.

         
  • David Stephenson

    Thanks for the help. What is the purpose of the #option explicit you put in your programs?

    I'm not sure if my display has an ILI9340 or 9341 driver the 9340 works better (the 9341 does not always completely clear the screen with a glcdcls), but it was sold to me as having a ILI9341 driver.

     
    • Anobium

      Anobium - 2016-11-08

      Re #option explict.... check the Help. I added to ensure your program when ported from one chip to another was not using incrorrect registers and bits.

      Mine was sold as an ili9340. It is a ili9341. Ho hum.

       
  • David Stephenson

    I'm back on this problem. I still can't get the ILI9340 display to initialize with a 18f25k80. Is there anything I could try in the glcd_ili9340.h file.
    Of course it may really be a problem with the SPI communication.

     
  • Anobium

    Anobium - 2016-12-15

    Try the new build. I did include a fix for 18f and this display.

     
  • David Stephenson

    I downloaded the lastest version today. Same problem the backlight comes on so it gets to that line, but the initialization does not work (not even with a MCLR reset).

     
  • Anobium

    Anobium - 2016-12-16

    Do you have a protocol analyser?
    Are you running the 18f at 3.3v?

     

    Last edit: Anobium 2016-12-16
  • David Stephenson

    I'm running at 3V (using 2xAA batteries). I do not have a protocol analyzer.

     
  • Anobium

    Anobium - 2016-12-17

    Please check these operating voltages. The 18f25k80 should operate down to 1.8v but I suspect issues with respect to power or power stability (got caps etc.?)

    I will stand up a test here but I know this works from the last set of tests.

     
  • David Stephenson

    I've finally got it to work.
    I was using the PK3CMD (with a pickit3) to program the 18f25k80 (and it reported that everything was fine).
    Then I tried MPLAB IPE (v3.40) and the chip will now control the display.
    Any ideas what was going wrong?
    I perfer to use command line programming as its quicker than opening up the IPE then stetting the chip and voltages (which it never remembers from last time).

     
1 2 > >> (Page 1 of 2)

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.