Wire now uses Hardware I2C by default

Information on the latest releases
victor_pv
Posts: 1648
Joined: Mon Apr 27, 2015 12:12 pm

Re: Wire now uses Hardware I2C by default

Post by victor_pv » Tue Aug 15, 2017 3:39 pm

Manny wrote:
Tue Aug 15, 2017 3:11 pm
Where are the default pins for Hardwire defined? Having some problems running the samples.
It will use the default i2c1 pins:
https://github.com/rogerclarkmelbourne/ ... c_f1.c#L39
There is a function to remap to alternate pins right next, but i have never used it so can't say how to use.

zmemw16
Posts: 1414
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: Wire now uses Hardware I2C by default

Post by zmemw16 » Tue Aug 15, 2017 3:45 pm

as a starter searched 'afio_i2c', would have a lot more with 'afio_' [54 v 5]
http://www.stm32duino.com/viewtopic.php ... i2c#p21014

if you're using a hal core or even if not, cubemx generates the appropriate calls for you and that would at least highlight what needs changing.

stephen

User avatar
Manny
Posts: 40
Joined: Wed Dec 09, 2015 3:15 pm

Re: Wire now uses Hardware I2C by default

Post by Manny » Tue Aug 15, 2017 4:24 pm

victor_pv wrote:
Tue Aug 15, 2017 3:39 pm
It will use the default i2c1 pins:
https://github.com/rogerclarkmelbourne/ ... c_f1.c#L39
zmemw16 wrote:
Tue Aug 15, 2017 3:45 pm
as a starter searched 'afio_i2c', would have a lot more with 'afio_' [54 v 5]
http://www.stm32duino.com/viewtopic.php ... i2c#p21014

if you're using a hal core or even if not, cubemx generates the appropriate calls for you and that would at least highlight what needs changing.
stephen
Thanks for the answers, got it working by a temporary hack on i2c_f1.c, I should have made myself clearer. I have a DS3231 and two VL53L0X on pins PB9 PB8, Blue Pill using the STM32Arduino core.

victor_pv
Posts: 1648
Joined: Mon Apr 27, 2015 12:12 pm

Re: Wire now uses Hardware I2C by default

Post by victor_pv » Wed Aug 16, 2017 1:37 am

Manny wrote:
Tue Aug 15, 2017 4:24 pm
Thanks for the answers, got it working by a temporary hack on i2c_f1.c, I should have made myself clearer. I have a DS3231 and two VL53L0X on pins PB9 PB8, Blue Pill using the STM32Arduino core.
Would be good if you post exactly what "hack" you did in case someone else needs the same and finds this post. ;)

zmemw16
Posts: 1414
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: Wire now uses Hardware I2C by default

Post by zmemw16 » Wed Aug 16, 2017 2:37 am

whilst i appreciate the 'temporary' label, i was taught that if you can then you program it at the user level of access using the library interfaces.
if you can't without changing the library, then you add it to the library with appropriate interfaces.
if it's a bug, then send a bug report, a bug report with a corrective patch is even better.

doesn't really matter if it's libmaple or ha basedl, there are 'library interface' functions for doing the remap of i2c1 to its alternate pins.

iirc there's a nicely laid out 103 board with nrf24 and esp8266 headers that had i2c1 wired on the alternates of PB8/PB9, baffled me at the time, but awhile later i pounced on a snippet someone posted that showed how to do it.
pretty sure it was libmaple though, also pretty sure i posted as much saying i;d been waiting for it to pop up.
i've funny idea spi1 remap has also popped up as well.

strange,in the reply compose window, it seems i2c, i2c1and spi1are now accepted as a valid spellings,
whilst spi isn't :D
stephen

User avatar
Manny
Posts: 40
Joined: Wed Dec 09, 2015 3:15 pm

Re: Wire now uses Hardware I2C by default

Post by Manny » Wed Aug 16, 2017 5:41 pm

My 'hack' was to hardcore the default i2c pin definition with the ones my devices were connected to, nothing fancy. I wanted to quickly evaluate the switch to using HardWire for any performance gain. My GPS speedo, datalogger is maxing out the Blue Pill ..probably due to bad coding :lol:

Its running a 2.8" TFT, touchscreen menu, DS3231 RTC, two VL53L0x time of flight sensors, SD card, K-Type MAX31855 temp sensor for EGT, Bluetooth , GPS and I have yet to add a flow meter to measure fuel consumption...its 500cc two stroke 8-)

The GPS is supposed to be logging at 10Hz but its already skipping writes as seen here https://fusiontables.google.com/DataSou ... #rows:id=1

Back on subject...the DS3231 and VL53LoX will all work together quite happily on Wire/HardWire at 400Hz but it crashes my gps speedo sketch..I have no debugging capability, so its back to bit banging for the time being.

Post Reply