[SOLVED] i2c slave receiver: nucleo 64 F401

STM32F103 Nucleo boards e.g. STM Nucleo F103RB
flussoincrociato
Posts: 11
Joined: Thu Feb 08, 2018 7:13 pm

Re: i2c slave receiver: nucleo 64 F401

Post by flussoincrociato » Fri Feb 09, 2018 9:45 pm

ok now I'm using the last release 2018.1.18, running the two examples master writer and slave receiver on two nucleo F401RE,
this is what returns on my serial port monitor:

Code: Select all

.€. ñ9

.€. ñ9

.€. ñ9

.€. ñ9
...
then, with this changes propesd by larsstenberg
It seems to be a problem in the Wire.c when running as a slave the allocateRxBuffer never gets called. So first fix seems to be to add:
// copy twi rx buffer into local read buffer
// this enables new reads to happen in parallel
+ if(rxBuffer == nullptr){
+ allocateRxBuffer(BUFFER_LENGTH);
+ }
memcpy(rxBuffer, inBytes, numBytes);
and changing allocateRxBuffer to static.

Now the freeze stopped.

It also seems to be an error with the numBytes received from master.
Changing line 541 in twi.c
from: nbData = I2C_TXRX_BUFFER_SIZE - obj->handle.XferCount;
to: nbData = I2C_TXRX_BUFFER_SIZE - obj->handle.XferSize;
Seems to correct the problem.
the void receiveEvent is never called again.
I don't know if it's the same bug or not, but it seems that these changes proposed to fix the problem on F091RC, get worse on F401RE.

User avatar
zoomx
Posts: 567
Joined: Mon Apr 27, 2015 2:28 pm
Location: Mt.Etna, Italy

Re: i2c slave receiver: nucleo 64 F401

Post by zoomx » Fri Feb 09, 2018 10:07 pm

Maybe you can use a portable version.

Instead of downloading the exe IDE installer, download the zip and... unzip it in a folder without spaces.
Then iside create a folder named portable. Launch the IDE and the other folders and files will be created.
Download the core and install it in the portable/sketchbook/hardware folder.

flussoincrociato
Posts: 11
Joined: Thu Feb 08, 2018 7:13 pm

Re: i2c slave receiver: nucleo 64 F401

Post by flussoincrociato » Fri Feb 09, 2018 10:21 pm

zoomx wrote:
Fri Feb 09, 2018 10:07 pm
Maybe you can use a portable version.

Instead of downloading the exe IDE installer, download the zip and... unzip it in a folder without spaces.
Then iside create a folder named portable. Launch the IDE and the other folders and files will be created.
Download the core and install it in the portable/sketchbook/hardware folder.
oh yes thank you even if the patch in platform.txt works well I will try it asap so I could also install board even under proxy

fpiSTM
Posts: 316
Joined: Fri Sep 16, 2016 12:33 pm
Location: Le Mans, France

Re: i2c slave receiver: nucleo 64 F401

Post by fpiSTM » Fri Feb 09, 2018 11:04 pm

Space in the path will be fixed in the next release.
I think your install is ok, I will do the test next week with F401.
I have tested the patch for I2C slave with F091 and F303 with success. As I've mentioned, there is an issue with the I2C complete transfer callback which need to be reviewed. I will keep you informed.

flussoincrociato
Posts: 11
Joined: Thu Feb 08, 2018 7:13 pm

Re: i2c slave receiver: nucleo 64 F401

Post by flussoincrociato » Sat Feb 10, 2018 12:06 am

many thanks!

fpiSTM
Posts: 316
Joined: Fri Sep 16, 2016 12:33 pm
Location: Le Mans, France

Re: i2c slave receiver: nucleo 64 F401

Post by fpiSTM » Mon Feb 12, 2018 5:22 pm

I've made some tests with F401 and it works if you do not change line 541 in twi.c
from: nbData = I2C_TXRX_BUFFER_SIZE - obj->handle.XferCount;
to: nbData = I2C_TXRX_BUFFER_SIZE - obj->handle.XferSize;

As mentioned I2C slave required some review since the mode to IT mode. An issue is already open for this.

flussoincrociato
Posts: 11
Joined: Thu Feb 08, 2018 7:13 pm

Re: i2c slave receiver: nucleo 64 F401

Post by flussoincrociato » Tue Feb 13, 2018 3:44 pm

Great!
Thank you fpiSTM

Post Reply