Menu

PIC18F46J50 and SSD1306 OLED :(

Trev
2018-09-17
2018-11-23
  • Trev

    Trev - 2018-09-17
    ; ----- Configuration
    #chip 18F46J50,12
    #config OSC = HS          'external 12Mhz crystal
    
    #define LED1 PORTE.0      'RE0/AN5/PMRD
    Set ANCON0.PCFG5 = 1      'configure as digital
    Dir LED1 Out              'configure as output
    
    'Configure I2C
    #define HI2C_CLOCK PORTB.4 'Pin14/RB4/PMA1/KBIO/SCK1/SCL1/RP7 I2C clock
    Dir HI2C_CLOCK in
    
    #define HI2C_DATA PORTB.5  'Pin15/RB5/PMA0/KBI1/SDI1/SDA1/RP8 I2C data input
    Dir HI2C_DATA in
    
    HI2CMode Master
    
    'GLCD routines header
    #include <glcd.h>
    #define GLCD_TYPE GLCD_TYPE_SSD1306
    #define GLCD_I2C_Address 0x3C
    
    Do Forever
    
        LED1 = On
        wait 3 s
        GLCDPrint 0,0, "Great Cow BASIC"
        LED1 = Off
        wait 3 s
        GLCDCLS
    
    Loop
    

    Compiling the above basic GLCD code gives this warning:

    /home/trev/GreatCowBasic/include//glcd_ssd1289.h (460): Warning: Variable 
    name P1 is used for a system bit on the current chip
    

    I doubt it's fatal as I'm not using the SSD1289 (I also tried commenting out the include of glcd_ssd1289.h in glcd.h which silences the warning).

    However, the above code does not display anything on my OLED display. I know the display is working and that the connections are all present and correct because if I load my MikroC version of the program it actually works.

    Any ideas?

     
    • Trev

      Trev - 2018-11-22

      /home/trev/GreatCowBasic-v0.98.03/include//glcd_ssd1289.h (460): Warning: Variable name P1 is used for a system bit on the current chip

      This still occurs with v0.98.03 due to the superceded code in that header.

       
      • Anobium

        Anobium - 2018-11-23

        :-) Odd. 550 Fix GLCD GLCD_SDD1289.h Updated to remove deprecated method [791] So, at commot 791 the change was made... But, I will resolve.

         
  • Anobium

    Anobium - 2018-09-17

    Try this. Edit the file glcd_SSd1289 and remove the method. SuperCededLine() Start at line 459. This has been superceded.... :-)

    If this fails, then, please use I2C Discovery to confirm the I2C setup and the device address. If this I2C Discovery is failing then the GLCD will not work. I always confirm withg I2C Discovery before trying to add the libraries. Because, you may be using a 7bit address... we use 8 bit addressing.

     

    Last edit: Anobium 2018-09-17
  • Trev

    Trev - 2018-09-18
    1. Edited glcd_ssd1289 and removed SuperCededLine() at line 459 and following.
    2. Recompiled - no warnings
    3. No change - no display

    4. Re-Configured i2cHardwareDiscovery to Terminal_18f14k22.gcb for 18F46J50

    5. Compiled
    6. Ran
    7. Result:
    0000000000000000
    0
    1
    2
    3
    4
    5
    6
    77
    8
    9
    A
    B
    C
    D
    E
    F
    
    1. Not helpful.
    2. So I changed the serial output to flash a LED. 1 sec flash = not detected; 3 sec flash = detected. And I counted... decimal 120 and 121 gave 3 sec flashes, so 0x78 and 0x79.

    3. I edited the originally posted program to subsitute the 8 bit address 0x78 for the 7 bit address 0x3C.

    4. Re-Compiled
    5. Ran - still no display :(
     
  • Anobium

    Anobium - 2018-09-18

    You must confirm your config with I2C discovery. Look in your demo folder for a similar device as your starting point. I2C discovery will confirm the address etc.

    The serial display was good. :-)

    Do you have pullup resistors? When you adapted the code did you change the baud rate ? if so, revert to slower speed.

    I have compiled your program and I an see nothing in the ASM that look odd.

     
  • Trev

    Trev - 2018-09-18

    You must confirm your config with I2C discovery.

    I have - using the LED flash method rather than HSer, it detects 0x78 (120), 0x79 (121).

    The serial display was good. :-)

    Perhaps suggestive of other issues...

    Do you have pullup resistors?

    Yes - 4K7. As mentioned, the same setup works fine with MikroC and 7 bit I2C address 0x3C (60).

    When you adapted the code did you change the baud rate ?

    No - I kept it at 9600. I have however also tried 4800 through 115200.

     
  • Anobium

    Anobium - 2018-09-18

    Let me get a part here. And, test as you to far away to send me a device. :-) It will only take a few days. But, without a part this is tough to resolve.

    But, meanwhile do try the below as 12mhz may look slow.

    #chip 18F46J50,32
    #config OSC = INTOSC          
    
     
    • Trev

      Trev - 2018-09-18
      #chip 18F46J50,32
      #config OSC = INTOSC
      

      With the above, a 3s LED delay turned into about 60s, and no display. Perhaps:

      #chip 18F46J50,32
      #config OSC = INTOSCPLL
      

      With the above, a 3 s LED delay was 1.5s, but no display.

      #chip 18F46J50,48
      #config OSC = INTOSCPLL
      

      With the above, a 3s LED delay was 3s :) but no display :(

       
  • Chris Roper

    Chris Roper - 2018-09-18

    I don't have that part nor do I know much about the GLCD Libraries so I may be off the mark here.

    Is this not a PPS device?
    If so you need to use the PPS tool to assign I2C to the Pins you have chosen to use for your application.

    .

     
    • Trev

      Trev - 2018-09-18

      Yes, the device has remappable pins, but RB4 and RB5 are native SCK1 and SDA1, so do not need remapping. Good thought though :)

       
  • Anobium

    Anobium - 2018-09-18

    Device is on way to me. Should only take a few days.

    Please post, as a ZIP, the source and all the compiler files. Hex, asm etc.

     
  • Trev

    Trev - 2018-09-23

    SOLVED

    There were some chip data file issues (now fixed) and an embarrassing typo in my compiler command line which escaped the compiler's notice but did interesting things to the output but only sometimes.

    Thanks to Evan for the hours he spent troubleshooting this.

     

Log in to post a comment.