| View previous topic :: View next topic |
| Author |
Message |
mayur.k.vadukul
Joined: 07 Jul 2022 Posts: 48
|
| I2C Set up for PIC18F66K22. |
Posted: Mon Oct 19, 2026 4:39 am |
|
|
I am trying to set up the I2C mode on PIC18F66K22.
I have used the following to define the parameters:-
#use i2c (I2C2, MASTER, FAST = 100000, RESTART_WDT, NOINIT, STREAM = FM_2)
in my code I have initialised the I2C with following function:-
i2c_init(FM_2, TRUE);
in my mains loop, i am constantly doing the following at the rate of 10msec and I am monitoring the clock - SCL2 (50) & SDA2 (51) pins on scope.
i2c_start (FM_2);
i2c_write(FM_2,0x55);
i2c_stop (FM_2);
However, I do not see any response on the osciloscope. I am expecting the clock to be 100Khz and data pin to be high and low.
I am using external 16MHz crystal with PLL and my program is running properly as I have some LEDs which work. I am also running in Debug mode and confirmed that the code is working properly.
Any suggestions? _________________ MVadukul |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 20148
|
|
Posted: Mon Oct 19, 2026 11:53 am |
|
|
Lot's of questions:
What pins are you looking at?.
What pull-ups have you got on the lines?.
Show your clock setup.
Show your fuses. The ECCP's on this chip can be relocated in the fuses.
Why don't you initialise the CCP at boot?.
What compiler version?. |
|
 |
mayur.k.vadukul
Joined: 07 Jul 2022 Posts: 48
|
| I2C Set up for PIC18F66K22. |
Posted: Tue Oct 20, 2026 2:12 am |
|
|
It was the pull up resistors which was the issue.
It is all under control now.
Thank you for your help. _________________ MVadukul |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 20148
|
|
Posted: Tue Oct 20, 2026 5:01 am |
|
|
As you saw, near the top of the list.....
Wrong pins, or no pull-ups are amongst the most common problems. |
|
 |
|