Hardware I2C on STM32
Moderator: Benj
-
- Posts: 73
- Joined: Fri Jan 24, 2020 10:38 am
- Has thanked: 4 times
- Been thanked: 2 times
- Contact:
Hardware I2C on STM32
Hi,
I have recently purchased flowcode and there doesnt seem to be an option for hardware I2C on the STM32.
Software I2C isnt fast enough for my application.
Is this something you will be adding soon or is it just being left out indefinitely?
I have recently purchased flowcode and there doesnt seem to be an option for hardware I2C on the STM32.
Software I2C isnt fast enough for my application.
Is this something you will be adding soon or is it just being left out indefinitely?
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: Hardware I2C on STM32
Hi,
We are working our way through supporting this for the various devices, prioritising requested parts, what processor are you looking at?
We are working our way through supporting this for the various devices, prioritising requested parts, what processor are you looking at?
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: Hardware I2C on STM32
Hi,
Attached are two updated files to give you hardware I2C support on 32F411CC
STARM_CAL_I2C.c
to replace the file found in ...
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\STARM
32F411CC.fcdx
to replace the file found in ...
C:\ProgramData\MatrixTSL\FlowcodeV8\FCD\ARM
Your Flowcode update feature will flag these as non-genuine until we get these changes into the update system, which can take a while in the current circumstances.
Please note that the hardware I2C on these devices is only supported in transaction mode of the Flowcode I2C CAL component.
This component can be found under the Creation toolbar icon.
Use Transaction_Initialise, Transaction_Read and Transaction_Write functions.
Hope that gets you started.
Regards,
Attached are two updated files to give you hardware I2C support on 32F411CC
STARM_CAL_I2C.c
to replace the file found in ...
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\STARM
32F411CC.fcdx
to replace the file found in ...
C:\ProgramData\MatrixTSL\FlowcodeV8\FCD\ARM
Your Flowcode update feature will flag these as non-genuine until we get these changes into the update system, which can take a while in the current circumstances.
Please note that the hardware I2C on these devices is only supported in transaction mode of the Flowcode I2C CAL component.
This component can be found under the Creation toolbar icon.
Use Transaction_Initialise, Transaction_Read and Transaction_Write functions.
Hope that gets you started.
Regards,
- Attachments
-
- 32F411CC.fcdx
- (45.88 KiB) Downloaded 124 times
-
- STARM_CAL_I2C.c
- (22.08 KiB) Downloaded 124 times
-
- Posts: 73
- Joined: Fri Jan 24, 2020 10:38 am
- Has thanked: 4 times
- Been thanked: 2 times
- Contact:
Re: Hardware I2C on STM32
Thanks Leigh,
I will try these out and come back to you if i have any issues.
I will try these out and come back to you if i have any issues.
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: Hardware I2C on STM32
Thanks.
Ben has now transferred these into the auto update system, so you can now use that to update
Leigh
Ben has now transferred these into the auto update system, so you can now use that to update
Leigh
-
- Posts: 73
- Joined: Fri Jan 24, 2020 10:38 am
- Has thanked: 4 times
- Been thanked: 2 times
- Contact:
Re: Hardware I2C on STM32
Can you tell me the purpose of the transaction initialise macro please.
I am unsure if this is a START command or an Initialisation for the I2C bus. Why do i need to put an address in??
I am unsure if this is a START command or an Initialisation for the I2C bus. Why do i need to put an address in??
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: Hardware I2C on STM32
It is an Initialisation of the I2C bus and driver.
The entered address is then used for all subsequent read and write transactions on that component. The read and write functions just take a data buffer.
Hope that helps.
The entered address is then used for all subsequent read and write transactions on that component. The read and write functions just take a data buffer.
Hope that helps.
-
- Posts: 73
- Joined: Fri Jan 24, 2020 10:38 am
- Has thanked: 4 times
- Been thanked: 2 times
- Contact:
Re: Hardware I2C on STM32
Thanks Leigh.
Makes sense, well kind of.
So i do init with what address? The base address?
Then when doing a transaction how should i specify read and writes?
As i understand an I2C read for say.....2 bytes.
START,
SEND ADDRESS WRITE ADDRESS
SEND REGISTER TO READ FROM
SEND READ ADDRESS
READ DATA
READ DATA
STOP
The way i understand it with these transactions is
INIT - USING ADDRESS (BASE??)
SEND ADDRESS WRITE AND DATA IN A BUFFER (buffer, nbytes)
READ ADDRESS AND GET DATA INTO BUFFER (buffer, nbytes)
DEINIT TO CLOSE THE BUS.
Is this correct?
I have 1 device that specifically requires a RESTART. Will a "DEINIT" - "INIT" have the desired effect?
Makes sense, well kind of.
So i do init with what address? The base address?
Then when doing a transaction how should i specify read and writes?
As i understand an I2C read for say.....2 bytes.
START,
SEND ADDRESS WRITE ADDRESS
SEND REGISTER TO READ FROM
SEND READ ADDRESS
READ DATA
READ DATA
STOP
The way i understand it with these transactions is
INIT - USING ADDRESS (BASE??)
SEND ADDRESS WRITE AND DATA IN A BUFFER (buffer, nbytes)
READ ADDRESS AND GET DATA INTO BUFFER (buffer, nbytes)
DEINIT TO CLOSE THE BUS.
Is this correct?
I have 1 device that specifically requires a RESTART. Will a "DEINIT" - "INIT" have the desired effect?
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: Hardware I2C on STM32
Could you post the datasheet for the device, or a link to it?
Thanks
The usual sequence is:
Initialise communications driver, this is done once at the start of the application
device address can usually be configured with hardware address inputs
Setup data buffer with data that needs to be written to the device, e.g. an internal read start address
buffer[0] = internal register address
Read the required number of data bytes (n) from the device
Thanks
The usual sequence is:
Initialise communications driver, this is done once at the start of the application
device address can usually be configured with hardware address inputs
Code: Select all
Transaction_Initialise (device address)
buffer[0] = internal register address
Code: Select all
Transaction_Write(buffer, 1)
Code: Select all
Transaction_Read(buffer, n)
-
- Posts: 73
- Joined: Fri Jan 24, 2020 10:38 am
- Has thanked: 4 times
- Been thanked: 2 times
- Contact:
Re: Hardware I2C on STM32
Thanks for that Leigh,
Im still getting a bit hung up on the INIT at the beginning of the application.
My hardware has 7 I2C devices on it. So putting an address into the INIT to activate the bus is difficult, especially since you said previously that this address is then used for subsequent read/writes.
Im still getting a bit hung up on the INIT at the beginning of the application.
My hardware has 7 I2C devices on it. So putting an address into the INIT to activate the bus is difficult, especially since you said previously that this address is then used for subsequent read/writes.
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: Hardware I2C on STM32
Ah, right.
You will need 7 instances of the CAL I2C component, one for each device.
Then initialise all 7, then call the read/write functions of each one depending upon which device you want to access.
You will need 7 instances of the CAL I2C component, one for each device.
Then initialise all 7, then call the read/write functions of each one depending upon which device you want to access.
-
- Posts: 73
- Joined: Fri Jan 24, 2020 10:38 am
- Has thanked: 4 times
- Been thanked: 2 times
- Contact:
Re: Hardware I2C on STM32
Not what i was expecting, but OK. I can do that.
I cant see an answer as to what address i should enter for the address.
Is it the base address, read address or write address?
I cant see an answer as to what address i should enter for the address.
Is it the base address, read address or write address?
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: Hardware I2C on STM32
you need the 7 bit I2C device address, it will be unique to each device on the bus
i.e. ignore the read/write bit
i.e. ignore the read/write bit
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: Hardware I2C on STM32
btw:
You do also have the option of using one I2C CAL component,
Initialise to one address, write, read etc., then UnInit,
then repeat for a different device address.
You do also have the option of using one I2C CAL component,
Initialise to one address, write, read etc., then UnInit,
then repeat for a different device address.