i2C slave problems

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Post Reply
davidkilshaw
Posts: 18
Joined: Thu Dec 20, 2012 12:31 pm
Has thanked: 2 times
Contact:

i2C slave problems

Post by davidkilshaw »

I have a recurring issue that i cannot solve. I am writing a piece of code to convert a byte of data received on i2c to set the mark space ratio of a PWM.
This is simple enough and i have written and proven all the code appart from the I2C slave part.

I have taken snippets of code from other projects on the Wiki (the LED slave sample code) and modified it to test what i am doing.

I attach the flowcode program i have written

The flashing LED's just show the status in various modes of the software.

I cannot get the software to jump to the point where it is accepting the address and loading the Byte of data

Any help greatly received

Regards

Dave Kilshaw

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 slave problems

Post by LeighM »

Hi,
You could try taking the delays out of the loop in the No branch.
However, it could be that we currently have problems with I2C on some PIC devices, currently being looked into.

davidkilshaw
Posts: 18
Joined: Thu Dec 20, 2012 12:31 pm
Has thanked: 2 times
Contact:

Re: i2C slave problems

Post by davidkilshaw »

The delays have been removed on previous versions

The LED has been set to off and then turned on if a valid byte is found but this also failed

The reason for the delays was purely to give visual indication (by speed of flashing) where the program was in execution

If this is a Bug in flowcode is there a time scale for a fix ?

Regards

Dave Kilshaw

davidkilshaw
Posts: 18
Joined: Thu Dec 20, 2012 12:31 pm
Has thanked: 2 times
Contact:

Re: i2C slave problems

Post by davidkilshaw »

Further testing on this project would indicate the the I2C interface with the 16F18325 isnt working properly

Setting the pic as a slave a master device sends a request to send data to the address of the micro i see the pulses on a scope as expected but i get no ack from the slave and by master reports no ack.

Swapping round and making the pic the master i see no pulses on the scope in any scenario.

This would indicate to me that the code has a bug (possibly indicated by Matrix as a bug in flowcode ?)

Has anyone managed to get this working not using Flowcode and writing in C ?

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 slave problems

Post by Benj »

Hi Dave,
If this is a Bug in flowcode is there a time scale for a fix ?
We are looking into the problem, hopefully the answer will reveal itself this week if not today. As soon as we have a solution we will let you know.

I spent some time on it yesterday and have found the problem but so far the fix is eluding me.

davidkilshaw
Posts: 18
Joined: Thu Dec 20, 2012 12:31 pm
Has thanked: 2 times
Contact:

Re: i2C slave problems

Post by davidkilshaw »

morning Benj

is there any update on this fix ?

regards

Dave Kilshaw

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 slave problems

Post by Benj »

Hi Dave,

I've spent the morning looking into this problem and think I have now got a bit further. The remappable I2C had a minor bug where the remap pins were not being defined 100% correctly. This should now be fixed in the I2C CAL component via the v8 Help -> Check For Updates menu.

Let me know how you get on.

davidkilshaw
Posts: 18
Joined: Thu Dec 20, 2012 12:31 pm
Has thanked: 2 times
Contact:

Re: i2C slave problems

Post by davidkilshaw »

Thanks for this. this has solved the I2C issue but i have found another issue which i wonder is if it is a mapping issue also

Reading port A4 into the micro and sending its digital level (0 or 1) to port C2 does not work

Reading port C0 into the micro and sending its digital level (0 or 1) to port C2 does work

It would appear that the micro isnt able to read port A4

could you have a look if that is an issue

Thanks

Dave Kilshaw

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 slave problems

Post by Benj »

Hi Dave,
this has solved the I2C issue
Brilliant thanks for letting me know.
Reading port A4 into the micro and sending its digital level (0 or 1) to port C2 does not work
Reading port C0 into the micro and sending its digital level (0 or 1) to port C2 does work
It would appear that the micro isnt able to read port A4
Please can you send me a simple program that shows this.

davidkilshaw
Posts: 18
Joined: Thu Dec 20, 2012 12:31 pm
Has thanked: 2 times
Contact:

Re: i2C slave problems

Post by davidkilshaw »

further investigation to whether physical ports on the micro can be programmed

So far i have tried to pulse on / off each port.

I can make ports A0,A1,A2,A3 (unknown as there is a pull up on my board) , C0, C1, C2,C3,C4 work correctly

Ports A4,A5,C5 do not work. And as stated i am usnsure about port A3 as there is a pull up external to the micro that i cannot remove.

This is for driving the ports with a high or low command in flowcode

I have not tried reading ports as this is more complex.

give me a shout if you can see the issue your end


thanks

Dave Kilshaw

davidkilshaw
Posts: 18
Joined: Thu Dec 20, 2012 12:31 pm
Has thanked: 2 times
Contact:

Re: i2C slave problems

Post by davidkilshaw »

benj

Here is the code that i used for the turning on / off each port. I initially did it to all ports at the same time (so had 12 output high macros macros and then 12 output low macros all set to different ports. The version uploaded is only doing one port as i was trying to see if there was cross mapping going on but there isnt.

davidkilshaw
Posts: 18
Joined: Thu Dec 20, 2012 12:31 pm
Has thanked: 2 times
Contact:

Re: i2C slave problems

Post by davidkilshaw »

the code for the read to write as mentioned in the first email is here
testing port a4 to led port c2.fcfx
(8.98 KiB) Downloaded 246 times

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 slave problems

Post by Benj »

Hello,

I think your config settings look a bit off.

You have the Clock Out Enable bit set to disabled, this actually enables the clock out bit so I have been through and changed the wording for this as it was a bit misleading.

You have the SOSC enabled as the main oscillator and this is on A4 and A5.

You also have low voltage programming enabled - this will likely also eat an I/O pin though not sure which one.

I'll get the new device definitions pushed out this afternoon.

davidkilshaw
Posts: 18
Joined: Thu Dec 20, 2012 12:31 pm
Has thanked: 2 times
Contact:

Re: i2C slave problems

Post by davidkilshaw »

Could you confirm what the clock settings insoftware oscillator mode mean specifically

i think i understand HFintosc 32Mhz is an internal osc at 32Mhz but does it tie up any pins ?
Extosc with 4* PLL i assume this requires a crystal connected to pins so will use up some of the pins
SOSC 32.768kHz not really sure what this is
LFintosc what frequency is this at
HDintosc 1Mhz i assume is a slower version of HFintosc. Does it tie up any pins
ExtOSC how many pins has this used.

On the general options page where you select the clock speed. Does this override any of the above setting for speed ?

Regards

Dave Kilshaw

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 slave problems

Post by Benj »

Hi Dave,

I'm basing the following on a 16F18325.
i think i understand HFintosc 32Mhz is an internal osc at 32Mhz but does it tie up any pins ?
No, But frequency will fluctuate slightly with temperature and pressure.
Extosc with 4* PLL i assume this requires a crystal connected to pins so will use up some of the pins
Yes OSC1 and OSC2 associated pins
SOSC 32.768kHz not really sure what this is
Secondary Oscillator, again uses 2 pins SOSC1 and SOSC2 and often used to drive internal RTCC module.
LFintosc what frequency is this at
On your device it's 31KHz. Another option to drive the RTCC or super low power applications. Again will fluctuate.
HDintosc 1Mhz i assume is a slower version of HFintosc. Does it tie up any pins
No
ExtOSC how many pins has this used.
I beleive this uses OSC1, you can optionally have clock out on OSC2 depending on an additional config setting which is 1/4 of the rate of OSCIN.

davidkilshaw
Posts: 18
Joined: Thu Dec 20, 2012 12:31 pm
Has thanked: 2 times
Contact:

Re: i2C slave problems

Post by davidkilshaw »

great thanks for the update

Post Reply