I2C or not I2C

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Post Reply
Sean Banan
Posts: 20
Joined: Wed Jan 22, 2014 9:48 pm

I2C or not I2C

Post by Sean Banan » Tue Feb 11, 2014 7:00 pm

Hello,

I am having problems in Swordfish using I2C.BAS

My first question is what is the difference between I2C.bas and SI2C.bas (given in the Help menu) ?

Next. I am using I2C.bas and am getting nowhere. I have now gone as far as writing your example code out line for line de la parrot fashion. It always hangs indefinitely on the line "value = I2C.Readbyte". I don't know what's going wrong.

I have written numerous other projects in PBP3 and have no problem at all with multiple I2C devices in the same project.

Have you any suggestions please ?
:(

User avatar
David Barker
Swordfish Developer
Posts: 1214
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Re: I2C or not I2C

Post by David Barker » Tue Feb 11, 2014 8:06 pm

> I2C.bas and SI2C.bas

I2C.bas is hardware I2C, SI2C.bas is software based. Have you got pullups on the SDA and SCL lines?

Jerry Messina
Swordfish Developer
Posts: 1473
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: I2C or not I2C

Post by Jerry Messina » Tue Feb 11, 2014 8:12 pm

Sometimes the libs take a bit of tweaking for the proper device/pin setup... it might be easier to post the code you have and we can take it from there instead of playing twenty questions. That way we'll know the device, setup, etc.

Sean Banan
Posts: 20
Joined: Wed Jan 22, 2014 9:48 pm

Re: I2C or not I2C

Post by Sean Banan » Wed Feb 12, 2014 12:44 pm

Yes I have pullups on SDA and SCL.

Thanks for sparing the time to look at the code.
I will post it tonight.
:?

Sean Banan
Posts: 20
Joined: Wed Jan 22, 2014 9:48 pm

Re: I2C or not I2C

Post by Sean Banan » Wed Feb 12, 2014 12:48 pm

By the way, I found something interesting on your Wiki last night that might (?) help
I will give one more go beefore sending the code.

Sean Banan
Posts: 20
Joined: Wed Jan 22, 2014 9:48 pm

Re: I2C or not I2C

Post by Sean Banan » Thu Feb 13, 2014 8:24 pm

Hello,

First a mega sorry for implying there was anything wrong with Swordfish. That is not the case. I just made a big boob and would like to share the following information for others to see.

I was migrating from PBP to Swordfish, and at the same time from a PIC16F to a PIC18F MCU.

A message to all PICAHOLICS is don’t rush in. Read the datasheet a thousand times first. Despite the fact that quite a few MCU’s map PORTS across pin-to-pin, they don’t always map PORT functions across.

I was migrating from a PIC16F1937 to a PIC18F4550 and although RC3 and RC4 map across, Microchip have moved SCL and SDA to RB0 and RB1 on the PIC18F4550. It was that that threw me.

AND if you are using the PICDEM2 platform remember to use jumpers J23 and J23 otherwise you will be cutting and soldering pcb tracks unnecessarily. (In the PICDEM2 Users Guide, the schematic says RB1 and RB4 but in the datasheet for the PIC18F4550 it says RB0 and RB1. There may be an errata somewhere).

Post Reply