I have to use the I2C bus with a PIC16F18857 as master.
I have to read and write on the eeprom 24C32 mounted in the DS3231 module.
To do this I decided to use the SDA1 and SCL1 pins of the micro.
In no way have I been able to talk to these modules, practically the module in question remains inactive.
The hardware is mounted exactly, it is not the first time I use these functions, but it is the first time I use this micro.
I'm probably wrong about something... but what?
I attach a source of tests.
Have you used I2C Discovery to find the I2C devices? Use one of the demos as your basis.
Have you got pullsup on the SDA and SCL lines?
The 16f18857 is a sister part to the 16F18855. And the 16F18855 has been extensively tested by use and Microchip - so, I do not think this library is at fault - I may wrong but I would be check the items mentioned above.
:-)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks of your quick response.
The circuit is OK. The address of the devices is exact and was found via I2cSniffer.
The code is an adapted part of the test code in the demos folder.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I just tried. C:\GCB@Syn\GreatCowBasic\Demos\vendor_boards\mplab_xpress_board_pic16f18855\16_show_i2c_devices_to_serial_terminal.gcb demo. Changed the part to a 16F18877. Works fund the I2C EPPROM device as follows:
The 16F18877 is the same memory part as the 16F18857 - so, this should be valid.
And, as this took me too long figure out. I have updated the EEProm library to show which method is being used. I was too easy not spot the differences between the overloaded methods.
ASM will now generate code as shown below - note the detail with respect to the use of WORDs and BYTEs (code not shown in the code segment below).
EEPROM_RD_ARRAY8
;`eeprom_rd_array - uses a word for eepaddr. intended for larger memory eeproms that require address_h & address (two bytes, therefore passed as a word ) to set addreess`
SysDoLoop_S3
call HI2CRESTART
movlw 160
movwf I2CBYTE
call HI2CSEND
movf hi2cackpollstate,F
btfss STATUS,Z
goto SysDoLoop_S3
...
...
...
...
EEPROM_WR_ARRAY6
;`eeprom_wr_array- uses a word for eepaddr. intended for larger memory eeproms that require address_h & address (two bytes, therefore passed as a word ) to set addreess`
SysDoLoop_S1
call HI2CRESTART
movlw 160
movwf I2CBYTE
...
...
...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have to use the I2C bus with a PIC16F18857 as master.
I have to read and write on the eeprom 24C32 mounted in the DS3231 module.
To do this I decided to use the SDA1 and SCL1 pins of the micro.
In no way have I been able to talk to these modules, practically the module in question remains inactive.
The hardware is mounted exactly, it is not the first time I use these functions, but it is the first time I use this micro.
I'm probably wrong about something... but what?
I attach a source of tests.
Does not look in correct.
Have you used I2C Discovery to find the I2C devices? Use one of the demos as your basis.
Have you got pullsup on the SDA and SCL lines?
The 16f18857 is a sister part to the 16F18855. And the 16F18855 has been extensively tested by use and Microchip - so, I do not think this library is at fault - I may wrong but I would be check the items mentioned above.
:-)
I have spotted something.
Please upload the following (as attachments)
1. 16f18857.dat
2. 16f18855.dat
The FamilyVariant may be incorrect !! Which is correct.....
Thanks of your quick response.
The circuit is OK. The address of the devices is exact and was found via I2cSniffer.
The code is an adapted part of the test code in the demos folder.
Files:
File:
File:
Please remove
FamilyVariant=1
from the .dat file.That may have a side effect but does this resolve your current issue?
Nothing to do, the problem remained.
OK. Revert the dat file. This is not the issue.
I just tried.
C:\GCB@Syn\GreatCowBasic\Demos\vendor_boards\mplab_xpress_board_pic16f18855\16_show_i2c_devices_to_serial_terminal.gcb demo
. Changed the part to a 16F18877. Works fund the I2C EPPROM device as follows:The 16F18877 is the same memory part as the 16F18857 - so, this should be valid.
and again
Same test works with with you?
Last edit: Anobium 2019-08-29
Ok. Right now I can't verify it because I'm on my way to work. As soon as I get there, I try it.
My guess... at the moment. The I2C Discovery will work.
There is an issue in the EEPROM write. Not sure where - yet.
Nothing wrong with EEPROM write.... see below
Last edit: Anobium 2019-08-29
Working code..... a few errors in your source code.
I just verified the Write and Read using PICKitPlus to read the EEPROM when attached directly to a PICkit programmer.
The first 10 bytes in the Program Memory window is the data saved to the EEProm by the Great Cow BASIC program.
:-)
P.S. I use 0x55 as write data, as this is 01010101 binary. As good test I used to ensure we are sync'ed up during transmissions.
Last edit: Anobium 2019-08-29
And, as this took me too long figure out. I have updated the EEProm library to show which method is being used. I was too easy not spot the differences between the overloaded methods.
ASM will now generate code as shown below - note the detail with respect to the use of WORDs and BYTEs (code not shown in the code segment below).