PIC-18F2525 Interface to RPi on I2C

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Giv
 
Posts: 34
Joined: Sat Aug 06, 2016 1:52 pm

PIC-18F2525 Interface to RPi on I2C

Post by Giv »

Hi,

Has anyone had luck with getting I2C working between RPi and a Microchip PIC, in my case '18F2525'? I am using wiringPi compiler on RPi and Mikroelektronika compiler for the PIC. I am able to see the address of my PIC when I run 'i2cdetect -y 1', which is "34", see below, but I have not had any luck with sending or receiving any data across. I am also using the QuicktoWire board, which is showing up as address "20" below. Between RPI and the PIC I am using the "Bi-directional Logic Level Converter ". I have attached both codes for your information. Please let me know if anyone has any ideas or improvement to get this working.


# i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- --
20: 20 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- 34 -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
Attachments
wiringPi-write-to-PIC.c
(2.08 KiB) Downloaded 161 times
PIC18F2525-Slave.c.txt
(5.32 KiB) Downloaded 160 times

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: PIC-18F2525 Interface to RPi on I2C

Post by adafruit_support_mike »

I'm afraid we have more experience with the Atmel family of microcontrollers than PICs (though we'll see how the product families change now that Microchip has bought Atmel).

Maybe someone from the community will have experience using PICs as I2C slaves.

User avatar
zener
 
Posts: 4567
Joined: Sat Feb 21, 2009 2:38 am

Re: PIC-18F2525 Interface to RPi on I2C

Post by zener »

It seems like you are trying to test 3 things at once, two pieces of code and all the hardware including the level shifter. Do you have a scope so that you can at least verify the logic levels and clock speeds are correct? Do you have a known good device for either end to try to narrow down where the problem might be? In the mean time you might post on a Microchip forum and see if there is any help from that end. Good luck.

User avatar
Giv
 
Posts: 34
Joined: Sat Aug 06, 2016 1:52 pm

Re: PIC-18F2525 Interface to RPi on I2C

Post by Giv »

Hi zener,
Thank you for your input.
zener wrote:It seems like you are trying to test 3 things at once,
The wiringPi software has three functions, but I commented out two each time I ran it and test with them.
zener wrote: Do you have a scope so that you can at least verify the logic levels and clock speeds are correct?
I see the data on SCL and SDA lines and on both end everything is setup for 100K. Do you have any other software or compiler that I can use on the RPi to work with I2C?
zener wrote: you might post on a Microchip forum and see if there is any help from that end.
Believe me I have posted this on a few site. There has to be a way and I2C is I2C. Any device that supports that protocol should be able to communicate with it to any other device, which supports I2C or something fundamentally is wrong.

Thanks again.

Givi

Locked
Please be positive and constructive with your questions and comments.

Return to “Microcontrollers”