I2C comms between an 18F452 and 16F877 using the MSSP in both chips

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View


Someone HELP!!!!

For the last month or so I have been trying to get a 18F452 PIC to
transmit several bytes of information every .5 of a second to a
16F877. The 18F452 is set up as a master and the 16F877 is setup as a
slave. I have used an osciliscope on the outputs of the 18F452 and I
am certain that I am getting the correct start bit and address
programmed into the 16F877. For some reason the 16f877 never seems to
want to recognise the start bits. I have gone through my programming
numerous times now and connot see the problem. All my interrupts are
set, I2C is configured correctly and my ports are configured. I have
no idea what the problem could be, I thought it might be the bus but I
am sure that is not the case. I do pull-up both SDA and SCK with +5v.
It is really starting to bug me, as i have never had so much trouble
with microcontrollers before that i haven''t been able to figure out.
If anyone out there can give me some pointers it would be of great
help. Even some sites that i haven't been able to find yet would be
nice to, or maybe even some code that works. Well hope someone has had
the same trouble as myself.

Robert

Re: I2C comms between an 18F452 and 16F877 using the MSSP in both chips


Quoted text here. Click to load it

What is the speed of the I2C and what resistors are you using to pull up the
SDA SCK?

Quoted text here. Click to load it

Cheers
Rune



Re: I2C comms between an 18F452 and 16F877 using the MSSP in both chips


Can you post the code so that I can have a look at it.

Quoted text here. Click to load it



Re: I2C comms between an 18F452 and 16F877 using the MSSP in both chips


Hopkins

Well I have changed it all again. Haven''t testted what I am using,
but I decided to download the Microchip Application Maestro. It seems
to be build well enough, but as I said I haven''t tested it, but I
hope I will soon. Do you want to look at my 18F code instead???

Quoted text here. Click to load it

Re: I2C comms between an 18F452 and 16F877 using the MSSP in both chips


Quoted text here. Click to load it

Rune

I am using 12K resistors to pull up the I2C bus line.

I am pretty sure that is an alright value to use. maybe you know better.

Rob

Re: I2C comms between an 18F452 and 16F877 using the MSSP in both chips


Quoted text here. Click to load it

If I remember correctly the pull up should be 10k when using 100kbps and 4k7
when using 400kbps.

When the speed is increased the pull up resistors should be smaller because
the faster the transmission line is the more current does it need to change
the voltage.

Cheers
Rune



Re: I2C comms between an 18F452 and 16F877 using the MSSP in both chips


Rune

Cheers for that, I will give it a go. But I am still having trouble
with my 16F877 chip not seeming to pick up any start bits let alone
address or data bytes. Well back to trying I spose.

Rob

Quoted text here. Click to load it

Re: I2C comms between an 18F452 and 16F877 using the MSSP in both chips



Quoted text here. Click to load it

FYI

Re: I2C comms between an 18F452 and 16F877 using the MSSP in both chips



Quoted text here. Click to load it

I have had problems getting the bus to work and have gotten it to work
correctly just by changing the size of the pull-up resistors.  If you look
at the spec for the pull-up resistors, it specifies a value based on total
on total system line capacitance.  4.7K for a 400K bus is a good
rule-of-thumb, though.  You may have to vary the value a bit for better
(more reliable) performance.

One thing you might want to try is to set up an interrupt based on receive
data on the I2C interface.  You could also try just looking at the input pin
and confirming what you see is what you think you should see.

Good luck.

Dave



Site Timeline