Page 1 of 1

Any success to use I2C module with 18FxxK42 on MikroC pro?

Posted: 04 Oct 2021 05:03
by gfaman
Hi,
I'm struggling to make work I2C module (different from other PIC18) on the 18F26K42.
MikroC Pro is using special routine for this PIC and so far, cannot make it work.
Init is done and code block on the first I2C1_Wr operation. On the scope, SDA/SCL jump high and stayed there. No start ever send.
Display SSD1380 is connected to normal RC3 and RC4.
Tried many things, mapping with PPS, open drain, etc...
Anyone succeed to use this integrated module with MikroC pro ?

Thanks,

Laurent

Re: Any success to use I2C module with 18FxxK42 on MikroC pro?

Posted: 05 Oct 2021 10:58
by filip
Hi,

Please find the example for the EEPROM that uses I2C on PIC18F47K42, it is from the same family as PIC18f26K42.

Regards,
Filip.

Re: Any success to use I2C module with 18FxxK42 on MikroC pro?

Posted: 06 Oct 2021 06:22
by gfaman
Thanks, will try. Very simple your code.
Yesterday found a way to make it work:
- Need use PPS to redeclare the I2C RC3 and RC4 despite same value than the default value after POR
- Found that the I2C addr need be in 7 bits (with 0 at b7) as a left shift will be done to add R/W in the I2C_Wr routine
- Found that if the I2C addr is wrong or not device with this address, the I2C_Wr is dead loop

BR,

Laurent