Arduino Wire on STM32 Nucleo

STM32F103 Nucleo boards e.g. STM Nucleo F103RB
Post Reply
IOTrav
Posts: 11
Joined: Mon Apr 27, 2015 6:26 pm

Re: Arduino Wire on STM32 Nucleo

Post by IOTrav » Tue Apr 28, 2015 3:17 pm

Hey @madias,

Had to add a hardware folder at username/Documents/Arduino/ I placed the Arduino_STM32-master folder there with your latest nucleo_f103rb in the variants folder there.

Here is the exact file path:
/Users/travis/Documents/Arduino/hardware/Arduino_STM32-master/STM32F1/variants/nucleo_f103rb

Same error when compiling.

madias
Posts: 813
Joined: Mon Apr 27, 2015 11:26 am
Location: Vienna, Austria

Re: Arduino Wire on STM32 Nucleo

Post by madias » Tue Apr 28, 2015 3:51 pm

BTW: Does the maple mini compile ok?

IOTrav
Posts: 11
Joined: Mon Apr 27, 2015 6:26 pm

Re: Arduino Wire on STM32 Nucleo

Post by IOTrav » Tue Apr 28, 2015 4:13 pm

@all

Disclaimer I have not worked in pin muxing/compile configuration much in the past with ARM processors.

Looking in the board.cpp file under nucleo_f103rb i found PB9 and PB8 which are the pins mapped to the ports on the Nucleo board labeled SDA(PB9) and SCL(PB8). This is what I see in the board.cpp for those pins:

PMAP_ROW(GPIOB, 9, NULL, 0, NULL, ADCx), /* D14/PB9 */
PMAP_ROW(GPIOB, 8, NULL, 0, NULL, ADCx), /* D15/PB8 */

Looks like those pins are set for ADC. Will the wire library have access to those pins if you call functions on the library or should they be set to something else? I am not sure how or if this needs to change to allow I2C connection.

madias
Posts: 813
Joined: Mon Apr 27, 2015 11:26 am
Location: Vienna, Austria

Re: Arduino Wire on STM32 Nucleo

Post by madias » Tue Apr 28, 2015 5:59 pm

Travis:
I've tested it out again:
downloaded the newest repo (which includes the new nucleo files, so you have nothing to install further)
installed it into: user/myname/documents/Arduino/hardware
Started IDE 1.63 and it complies without errors.

So please: complete wipe the whole arduino stuff (app, user/myname/documents/Arduino/hardware folder) and try it again.
Have you selected the "nucleo" from the board menu?

PMAP_ROW(GPIOB, 9, NULL, 0, NULL, ADCx), /* D14/PB9 */
ADCx = not an ADC pin (no channel). But you have taken the old board.cpp file!
The new one is like this:
{GPIOB, TIMER4, NULL, 9, 4, ADCx}, /* D14/PB9 */
gpioX, TIMER/NULL, ADC1/NULL, PINbit, timerch/0, adcsub/0
so for the line above:
GPIOB = Port B
on Timer4 (for PWM)
NULL = no ADC
PINbit = 9 (PB9)
timer ch = 4
ADCx = no ADC channel
regards
Matthias

edit: I've done some timer/pin remappings, my wish was to get close to the "real" arduino headers as possible. But this isn't 100% possible (the arduino header is only a marketing gag).
This are the remapping lines:
afio_cfg_debug_ports(AFIO_DEBUG_SW_ONLY); // relase PC3 and PC5 on nucleo
afio_remap(AFIO_REMAP_USART3_PARTIAL); // remap Serial2(USART3)PB10/PB11
// to PC10/PC11 -> don't forget to insert into gpio.h:
// AFIO_REMAP_USART3_PARTIAL = AFIO_MAPR_USART3_REMAP_PARTIAL
afio_remap(AFIO_REMAP_TIM2_FULL); // better PWM compatibility
afio_remap(AFIO_REMAP_TIM3_PARTIAL);// better PWM compatibility
Most of the stuff is about timer remap for PWM pins, so I get the maximum out.

IOTrav
Posts: 11
Joined: Mon Apr 27, 2015 6:26 pm

Re: Arduino Wire on STM32 Nucleo

Post by IOTrav » Tue Apr 28, 2015 10:09 pm

Hey @madias,

I did like you said. Deleted the directory out of the hardware folder and got the latest one from the github repo. It's working now after I changed the install location for my gcc compiler in the platform.txt file Mine is at usr/local/gcc_arm/gcc-arm-none-eabi-4_8-2014q3/bin/

Everything is compiling correctly now and flashing to the board.

Still nothing of course on I2C but at least we are working off the same board files now.

madias
Posts: 813
Joined: Mon Apr 27, 2015 11:26 am
Location: Vienna, Austria

Re: Arduino Wire on STM32 Nucleo

Post by madias » Wed Apr 29, 2015 5:55 am

Glad to hear, that it's now working. Have you tried all Serials (1-3)?
Getting I2c working should not be a big problem.
Maybe this is new to you:
There are two different versions of I2c in the library/wire folder:
"Hardwire.h" this is the hardware version of I2c, I got it successfully running on the maple.
"Wire.h" is only a ugly software implementation (with a lot of digitalWrites and /Reads) it's set as "standard". Only advantage: You can set every pin you want. I didn't play with it and I'm not going to use it. As in wire.h there are following defaults:
#define SDA 19
#define SCL 20

#define SOFT_STANDARD 16
#define SOFT_FAST 0
(don't know what the last two entries are... maybe you only need to change SDA and SCL or just try them out)
I'll try to get my I2C OLED working with "hardwire.h" this week.

User avatar
RogerClark
Posts: 5970
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Arduino Wire on STM32 Nucleo

Post by RogerClark » Wed Apr 29, 2015 6:11 am

@IOTrav

Did you resolve your problem?

I wonder if we should move this to the Libraries or to the STM32 Nucleo section instead of here ?

madias
Posts: 813
Joined: Mon Apr 27, 2015 11:26 am
Location: Vienna, Austria

Re: Arduino Wire on STM32 Nucleo

Post by madias » Wed Apr 29, 2015 7:34 am

Roger: Travis solved his problem. I've splitted up the thread, everything about I2c and Nucleo is here:
http://www.stm32duino.com/viewtopic.php?f=29&t=30
Please do not reply on this thread anymore.

IOTrav
Posts: 11
Joined: Mon Apr 27, 2015 6:26 pm

Re: Arduino Wire on STM32 Nucleo

Post by IOTrav » Fri May 01, 2015 5:04 pm

Hi @all,

Yes the problem is resolved and I have tested communication on Serial, Serial1, and Serial2 I am getting reliable communication over all 3 ports and am able to flash the controller from Arduino IDE. I would say this is solved. Please see I2C on Nucleo forum, it appears to be solved as well(pretty much): http://www.stm32duino.com/viewtopic.php?f=29&t=30.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest