[SOLVED] i2c slave receiver: nucleo 64 F401

flussoincrociato
Thu Feb 08, 2018 9:05 pm
Hi,
i’m trying to do board to board communication with two nucleo 64 F401 and the two examples installed in Ide with board manager, i2c slave receiver example doesn’t work, serial monitor shows unreadable characters.
if you comment char stuffs and send only an integer, receiver reads always zero.
where is the problem?
Thanks

fpiSTM
Fri Feb 09, 2018 6:02 am
I guess you use the Arduino_Core_STM32?
Issue is known and a fix exists:
https://github.com/stm32duino/Arduino_C … issues/212

flussoincrociato
Fri Feb 09, 2018 12:20 pm
Hi fpiSTM, thank you for the reply,
i’m not sure it’s the same problem, that thread talks about freeze, my code does not freeze, it just returns bad data,
anyway i did not understand how to fix it:
-I added sugested lines in wire.cpp, and changed allocateRxBuffer to static
-changed handle.XferCount to handle.XferSize in twi.c
before modifying code receiver showed bad data, after these code changes serial com shows anything.
were am i wrong?
Please can you tell me were can i download a fixed code version of arduino core stm32? Did someone upload it?
If i now reinstall the package through board manager it should work?
many thanks.

fpiSTM
Fri Feb 09, 2018 2:18 pm
Even if the issue mentioned under github is a freeze, the main issue is the use of a buffer not allocated. So, this could be a random issue (freeze or not)…
Even if I think it should freeze as the buffer should be initialized with null.

Anyway, If you applied properly the fix this should work, it seems you met another issue.
We have raised an issue on github following this fix as we found that IT mode (Rx/Tx callback) is not well managed. Maybe you met this case.

Just one question about your hardware setup. I2C lines (SDA/SCL) must have a pull up resistor on each line else this will not work.


flussoincrociato
Fri Feb 09, 2018 4:00 pm
Yes for sure, there are external 1k pull-up resistors tied to 3.3V and it works good if i use Arduino UNO as a receiver.

To make sure doing all right I removed Arduino IDE and all the related folders, including Arduino15.
Then reinstalled Arduino IDE 1.8.4 and the last arduino core version 2018.1.18 in board manager.
Now compiling sketches for nucleo 64 returns exit code 1:

Arduino:1.8.4 (Windows 7), Scheda:"Nucleo-64, Nucleo F401RE, STLink, Generic Serial, None, Smallest (-Os default)"
...
...
Using board 'Nucleo_64' from platform in folder: C:\Users\stefano corona\AppData\Local\Arduino15\packages\STM32\hardware\stm32\2018.1.18
Using core 'arduino' from platform in folder: C:\Users\stefano corona\AppData\Local\Arduino15\packages\STM32\hardware\stm32\2018.1.18
cmd /c "if not exist C:\Users\stefano corona\AppData\Local\Arduino15\packages\STM32\hardware\stm32\2018.1.18\libraries\Wire\examples\master_writer/build_opt.h mkdir C:\Windows\TEMP\arduino_build_12413\sketch & type NUL > C:\Windows\TEMP\arduino_build_12413/sketch/build_opt.h"
Impossibile trovare il percorso specificato.

Impossibile trovare il percorso specificato.

exit status 1
Errore durante la compilazione per la scheda Nucleo-64.


mrburnette
Fri Feb 09, 2018 4:08 pm
Windows OS will accept a “/” or “\” in the Arduino code (sketch.)
Linux will only accept the “/”

On this forum, everyone is encouraged to use the “/” forward slash because some Linux users get annoyed when they have to use search and replace… don’t ask me how I know this :lol:

Ray


flussoincrociato
Fri Feb 09, 2018 4:28 pm
Hi mrbrunette,
thanks for the explanation, then maybe my assumption is wrong.
Do you have any suggestion to solve the problem?
It does not compile without manually adding those files and folder, and when it compiles returns errors.

fpiSTM
Fri Feb 09, 2018 5:12 pm
This error is due to space in the path. I solved this issue and the fix will be in the next release.
https://github.com/stm32duino/Arduino_C … 2/pull/204

flussoincrociato
Fri Feb 09, 2018 7:42 pm
thank you i used your instructions in related thread, and it seems to work, but i’m not sure if i did it well, in the environment variable i typed %PATH% in name field and system32 path in value field, is that right?

fpiSTM
Fri Feb 09, 2018 7:53 pm
Yes, you could add the system32 path in %PATH% env variable if cmd is not known when called by Arduino IDE.
But the main correction is also to double quote path in the platform.txt

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:
.€. ñ9

.€. ñ9

.€. ñ9

.€. ñ9
...


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
Fri Feb 09, 2018 10:21 pm
[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.

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
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
Sat Feb 10, 2018 12:06 am
many thanks!

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
Tue Feb 13, 2018 3:44 pm
Great!
Thank you fpiSTM

Leave a Reply

Your email address will not be published. Required fields are marked *