I2C 18F47K40

Moderator: Benj

Post Reply
medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

I2C 18F47K40

Post by medelec35 »

Software I2C is working as expected.
With channel 1 or channel 2 I2C does not work & no commands after I2C are executed.
The microcontroller is brought to a halt.
Attachments
I2C test.fcfx
(122.38 KiB) Downloaded 185 times
Martin

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: I2C 18F47K40

Post by Benj »

Hi Martin,

Leigh's got one of these device on order so we can investigate for you.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: I2C 18F47K40

Post by medelec35 »

Thanks Ben & Leigh.
When you test the device, can you also test ADC with internal OSC at 64MHz please as it appears to be wandering all over the place.

Thank you.
Martin

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: I2C 18F47K40

Post by LeighM »

Hi Martin,
I think I have the I2C fixed now.
Please try the attached updated CAL file. (C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC)
Thanks
Leigh
Attachments
PIC_CAL_I2C.c
(28.25 KiB) Downloaded 200 times

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: I2C 18F47K40

Post by LeighM »

Hi Martin,
I've just done a quick ADC test with default settings and it looks OK.
Do you want to post an example?
Thanks
Leigh

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: I2C 18F47K40

Post by medelec35 »

LeighM wrote:'ve just done a quick ADC test with default settings and it looks OK.
Hi Leigh,
Was that running the chip with internal osc @ 64 MHz?
Martin

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: I2C 18F47K40

Post by LeighM »

Just checked and that was running with OSCFRQ = 0x07;
as your previous program, so that will be 48MHz, not 64

Edit: Yes you are correct, it's a mess at 64MHz
Although in the datasheet there is note reference (3) against that setting, cannot find the relevant note though!

Edit 2: Just changed the ADC conversion speed to Fosc/16 and all is well again. (@64MHz)

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: I2C 18F47K40

Post by medelec35 »

LeighM wrote:Just checked and that was running with OSCFRQ = 0x07;
Yes I was running osc for I2C at 48MHz.
What to change it to 64MHz when ADC was working.
as your previous program, so that will be 48MHz, not 64
LeighM wrote:Just changed the ADC conversion speed to Fosc/16 and all is well again. (@64MHz)
Brilliant thanks Leigh for your help on both I2C and ADC.
Will do some testing and let you know how I got on.
Martin

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: I2C 18F47K40

Post by medelec35 »

LeighM wrote:Just checked and that was running with OSCFRQ = 0x07;
as your previous program, so that will be 48MHz, not 64
Yes I was running osc for I2C at 48MHz.
What to change it to 64MHz when ADC was working.
LeighM wrote:Just changed the ADC conversion speed to Fosc/16 and all is well again. (@64MHz)
Brilliant thanks Leigh for your help on both I2C and ADC.
Will do some testing and let you know how I got on.
Martin

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: I2C 18F47K40

Post by medelec35 »

Hi Leigh,
Tried I2C with:
channel2 (SDA = RD0, SCL = RD1) - Working.
channel1 (SDA = RC0, SCL = RC1) - Not Working.
Software (SDA = RC0, SCL = RC1) - Working.
Using internal osc @ 48MHz
Martin

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: I2C 18F47K40

Post by LeighM »

Thanks Martin,
Interesting, I used channel 1 and port C OK, but not pins 0 and 1
One thing I did add in code at start of program was a setting of the port to open drain.
ODCONC = 0xff;
I then forgot to remove it to see if it was really needed.
I'm out of the office at the moment so will investigate further tomorrow.
Leigh

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: I2C 18F47K40

Post by LeighM »

Hi Martin,
Update: It does not require setting of the port to open drain.
But, weirdly, I can get it to work OK on every pin on port C except 0 and 1!
Hmm, does it need further investigation or a read of the silicon errata :roll:
I'll be back

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: I2C 18F47K40

Post by LeighM »

I suspect this might be something to do with the secondary oscillator
but haven't got my head round all the relevant datasheet sections yet

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: I2C 18F47K40

Post by Benj »

I've poked my head into the datasheet but I've not spotted anything useful so far.

patrick schoon
Posts: 74
Joined: Mon Aug 23, 2010 7:07 pm
Location: Amsterdam
Has thanked: 7 times
Been thanked: 13 times
Contact:

Re: I2C 18F47K40

Post by patrick schoon »

Hi Guys,

I experiance the same problem with a PIC16F15356.

Software I2C is working but Ch1 and Ch2 are not.
FC8.1.1.11


Regards,

PS

Post Reply