Page 1 of 1

MCP23017 - One I2C transaction for stepper motor control

Posted: Wed May 20, 2026 10:16 am
by Zhmil1789
Hi,
I am using Flowcode with MCP23017 I2C expander to control a stepper motor.
I have two pins on PORTA:

Pin 0 = direction
Pin 1 = step

Currently I use WritePortPin macro in a loop with delays between steps. This creates separate I2C transaction for each step.
According to MCP23017 datasheet, Byte mode (IOCON.SEQOP) allows continuous writing to the same register without sending address each time.
My question: Is it possible in Flowcode to keep I2C transaction open between WritePort/WritePortPin calls, so I can send multiple step pulses with delays inside one transaction? Or is there a way to access raw I2C bus directly while using MCP23017 component?

Thank you

Re: MCP23017 - One I2C transaction for stepper motor control

Posted: Wed May 20, 2026 10:26 am
by BenR
Hello,

Both are possible yes.

The straightforward way is to look at the generated C code, specifically the MCP23017 component macros and then copy and paste this C code into your own function using the C code icon. You can then edit the C code as required.

The more customised way would be to take the MCP23017 component source from the wiki and add the functionality you need directly into the component creating your own customised version of the component.

Re: MCP23017 - One I2C transaction for stepper motor control

Posted: Wed May 20, 2026 10:51 am
by Zhmil1789
Thank you for your reply! Could you tell me exactly what you mean by custom version? In flowcode, can I download the components myself and customize them?


With respect
Zhmil1789

Re: MCP23017 - One I2C transaction for stepper motor control

Posted: Thu May 21, 2026 10:12 am
by BenR
Hello,

Yes all of the component source files are on the wiki, if you right click on the component in flowcode and goto help it should take you right to the correct page. The source for the component is usually at the bottom of the page though can sometimes be near the top.

If you take a component source and edit it then you can goto "File -> Export -> Export this project as a component" to export as a component for your version of Flowcode. Be careful though as doing library updates will overwrite your customisations. If you want to put your version into a different place so that library updates won't overwrite it then you can save wherever you like and then add this directory via "File -> Global Settings -> Locations -> Look for components in..."