If I comment out the HI2C setup (not the PPS bit), the LED flashes then stays on. The GLCD is blank.
If I use software I2C, the LED works and the GLCD works.
Any ideas?
Currently using the 0.97.01 2017-02-20 compiler.
Last edit: Peter 2017-08-12
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Please talk me through how the PPSTool came up with those settings. What editing did you do? You have the latest PPSTool and the latest XML dataset (I can see this from the code) but the actual code in your program for PPS is not correct.
So, rather than have me just tell you the answer - can you recreate using PPSTool and then compare the PPS code generated.
Anobium
P.S. Are you using MPLAB-IPE to program?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
However the problem is with this line: #define HI2C_DATA PORTC.4
If I comment it out the LED flashes etc., if it's uncommented nothing happens.
Changing the pin doesn't make a difference either.
Another way to get the code to run, is to comment out everything to do with the GLCD (GLCDInit, GLCDCLS and GLCDPrint).
And yes, I'm using IPE to program,
Last edit: Peter 2017-08-13
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This code works. I have just logged into my home remotely and this is a test program that could be in the next release. I know this works - I just adapted to ensure the code is your code.
#chip 16F18326, 32#Config WRT_OFF, CPD_ON, MCLRE_ON, FEXTOSC_OFF, CLKOUTEN_OFF 'These configs = User non-votatile protection off (WRT), Data non-votatile protection off (CPD), MCLR pin function enablesd, External oscillator not enabled and clockout function is disables ( enable portc.5 to I/O port).#include<glcd.h>'GeneratedbyPICPPSToolforGreatCowBasic'PPSToolversion:0.0.5.9'PinManagerdata:v1.36.1''Templatecommentatthestartoftheconfigfile'#startup InitPPS, 85SubInitPPS'Module:MSSP1RC3PPS=0x0018'SCL1>RC3SSP1CLKPPS=0x0013'RC3>SCL1(bi-directional)RC4PPS=0x0019'SDA1>RC4SSP1DATPPS=0x0014'RC4>SDA1(bi-directional)EndSub'Templatecommentattheendoftheconfigfile'FlashLEDtoshowchipisrunningDIRPORTC.1OUTRepeat5PulseoutPORTC.1,250msWait500msEndRepeat'SetupHardwareI2C#define HI2C_DATA PORTC.4#define HI2C_CLOCK PORTC.3'I2CpinsneedtobeinputforSSPmodulewhenusedonMicrochipPICdeviceDirHI2C_DATAinDirHI2C_CLOCKin'MASTERMODEHI2CModeMaster'DefineGLCDHardwaresettings#define GLCD_TYPE GLCD_TYPE_SSD1306#define GLCD_I2C_Address 0x78GLCDCLSGLCDPrint(0,0,"Hello")'TurnLEDontoshowitiscompleteDOPORTC.1=!PORTC.1wait50msLOOP
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've tried your New14.gcb with and without the latest hwi2c.h - neither work!
I had several versions of GCB installed which may/may not have been messed with, so I deleted them all and downloaded a fresh version of 0.97-01 but that didn't help.
It's not an electrical problem with the board, otherwise the software I2C wouldn't work. There are resistors on the SDA and SCL lines.
Having looked through previous projects, I can't find any occasions where I've used HWI2C so I guess I've never had any luck with it.
This can wait until you're back off your holidays.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I spotted the fix in the release note for the next release.
371 Fix SDD1306 Added delay to allow display to power up fully befor initalization
Clear display before DisplayON to hide garbage at POR / initalization
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
That fixed the problem and HI2C is working now! I can write to/refresh the SSD1306 at speeds never seen before using #define HI2C_BAUD_RATE 400
I'm not sure why adding the delay and clearing the display would stop code executing any further but it works so I'll just accept it :)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have the code below, and it doesn't do anything. No flashing LEDs, nothing on the GLCD.
If I comment out the HI2C setup (not the PPS bit), the LED flashes then stays on. The GLCD is blank.
If I use software I2C, the LED works and the GLCD works.
Any ideas?
Currently using the 0.97.01 2017-02-20 compiler.
Last edit: Peter 2017-08-12
Please talk me through how the PPSTool came up with those settings. What editing did you do? You have the latest PPSTool and the latest XML dataset (I can see this from the code) but the actual code in your program for PPS is not correct.
So, rather than have me just tell you the answer - can you recreate using PPSTool and then compare the PPS code generated.
Anobium
P.S. Are you using MPLAB-IPE to program?
I'd aready tried the exact code from PPSTool without any luck:
However the problem is with this line:
#define HI2C_DATA PORTC.4
If I comment it out the LED flashes etc., if it's uncommented nothing happens.
Changing the pin doesn't make a difference either.
Another way to get the code to run, is to comment out everything to do with the GLCD (GLCDInit, GLCDCLS and GLCDPrint).
And yes, I'm using IPE to program,
Last edit: Peter 2017-08-13
You need to use the complete PPSTool (all four entries as these pins are bi-directional).
Please try the very latest library, see https://sourceforge.net/p/gcbasic/code/HEAD/tree/GCBASIC/trunk/include/lowlevel/hwi2c.h
This code works. I have just logged into my home remotely and this is a test program that could be in the next release. I know this works - I just adapted to ensure the code is your code.
Working solution. See attached.
I would have 2.2k pullsup on the i2c bus on SDA and SCL
I've tried your New14.gcb with and without the latest hwi2c.h - neither work!
I had several versions of GCB installed which may/may not have been messed with, so I deleted them all and downloaded a fresh version of 0.97-01 but that didn't help.
It's not an electrical problem with the board, otherwise the software I2C wouldn't work. There are resistors on the SDA and SCL lines.
Having looked through previous projects, I can't find any occasions where I've used HWI2C so I guess I've never had any luck with it.
This can wait until you're back off your holidays.
I will send you a hex file. I can access remotely. Normal email address?
Yes, normal email is fine.
Please try https://sourceforge.net/p/gcbasic/code/HEAD/tree/GCBASIC/trunk/include/glcd_SSD1306.h
I spotted the fix in the release note for the next release.
That fixed the problem and HI2C is working now! I can write to/refresh the SSD1306 at speeds never seen before using
#define HI2C_BAUD_RATE 400
I'm not sure why adding the delay and clearing the display would stop code executing any further but it works so I'll just accept it :)