i2C slave problems
Moderator: Benj
-
- Posts: 18
- Joined: Thu Dec 20, 2012 12:31 pm
- Has thanked: 2 times
- Contact:
i2C slave problems
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
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
- 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
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.
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.
-
- Posts: 18
- Joined: Thu Dec 20, 2012 12:31 pm
- Has thanked: 2 times
- Contact:
Re: i2C slave problems
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
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
-
- Posts: 18
- Joined: Thu Dec 20, 2012 12:31 pm
- Has thanked: 2 times
- Contact:
Re: i2C slave problems
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 ?
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 ?
- 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
Hi Dave,
I spent some time on it yesterday and have found the problem but so far the fix is eluding me.
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.If this is a Bug in flowcode is there a time scale for a fix ?
I spent some time on it yesterday and have found the problem but so far the fix is eluding me.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 18
- Joined: Thu Dec 20, 2012 12:31 pm
- Has thanked: 2 times
- Contact:
- 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
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 18
- Joined: Thu Dec 20, 2012 12:31 pm
- Has thanked: 2 times
- Contact:
Re: i2C slave problems
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
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
- 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
Hi Dave,
Brilliant thanks for letting me know.this has solved the I2C issue
Please can you send me a simple program that shows this.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
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 18
- Joined: Thu Dec 20, 2012 12:31 pm
- Has thanked: 2 times
- Contact:
Re: i2C slave problems
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
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
-
- Posts: 18
- Joined: Thu Dec 20, 2012 12:31 pm
- Has thanked: 2 times
- Contact:
Re: i2C slave problems
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.
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.
-
- Posts: 18
- Joined: Thu Dec 20, 2012 12:31 pm
- Has thanked: 2 times
- Contact:
- 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
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 18
- Joined: Thu Dec 20, 2012 12:31 pm
- Has thanked: 2 times
- Contact:
Re: i2C slave problems
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
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
- 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
Hi Dave,
I'm basing the following on a 16F18325.
I'm basing the following on a 16F18325.
No, But frequency will fluctuate slightly with temperature and pressure.i think i understand HFintosc 32Mhz is an internal osc at 32Mhz but does it tie up any pins ?
Yes OSC1 and OSC2 associated pinsExtosc with 4* PLL i assume this requires a crystal connected to pins so will use up some of the pins
Secondary Oscillator, again uses 2 pins SOSC1 and SOSC2 and often used to drive internal RTCC module.SOSC 32.768kHz not really sure what this is
On your device it's 31KHz. Another option to drive the RTCC or super low power applications. Again will fluctuate.LFintosc what frequency is this at
NoHDintosc 1Mhz i assume is a slower version of HFintosc. Does it tie up any pins
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.ExtOSC how many pins has this used.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 18
- Joined: Thu Dec 20, 2012 12:31 pm
- Has thanked: 2 times
- Contact: