MCP23017 INPUT POLARITY

For general Flowcode discussion that does not belong in the other sections.
Post Reply
max.tisc
Posts: 113
http://meble-kuchenne.info.pl
Joined: Thu Dec 10, 2020 5:40 pm
Been thanked: 10 times

Flowcode v10 MCP23017 INPUT POLARITY

Post by max.tisc »

HI, I'm trying an MCP23017 to expand the inputs, I noticed that when I use the ConfigureInversion function only A0 inverts the logical state from HIGH to LOW, to do some tests I only connected the first 4 inputs, as Hardware everything seems fine the inputs are all HIGH and when I close the contacts corresponding to the inputs on the display I see the change of state. Is it a problem with the FC component or do I have to look for something in my HW?
Attachments
IMG_20250423_124515_DRO.jpg
IMG_20250423_124515_DRO.jpg (59.64 KiB) Viewed 4003 times

medelec35
Matrix Staff
Posts: 1966
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 629 times
Been thanked: 659 times

Re: MCP23017 INPUT POLARITY

Post by medelec35 »

Hello .
The tooltip shows you will need to set an 8 bit value.
What happens if you set the port to 255, that should enable all pins to invert.
Likewise a value of 1 should only set pin 0 to invert, a value of 2 should only set pin 1 to invert.
If that does not work, can you upload your project.
Martin

max.tisc
Posts: 113
Joined: Thu Dec 10, 2020 5:40 pm
Been thanked: 10 times

Flowcode v10 Re: MCP23017 INPUT POLARITY

Post by max.tisc »

Ok thanks Martin it works I was misled by the description of the parameter that indicates 0 or 1, I take this opportunity to ask you another question about the component and precisely about the use of INTA and INTB that in the idle state are in the HIGH state to switch to the LOW state when the 23017 detects a change in the input of the pins, what I saw with an analyzer is that this change of state is very short and is not detected by the interrupt pin of the micro that I use (stm32f411) is there a setting to set?
thanks
Attachments
Screenshot 2025-04-23 172444.png
Screenshot 2025-04-23 172444.png (89.4 KiB) Viewed 3923 times
Screenshot 2025-04-23 173221.png
Screenshot 2025-04-23 173221.png (40.33 KiB) Viewed 3923 times

medelec35
Matrix Staff
Posts: 1966
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 629 times
Been thanked: 659 times

Re: MCP23017 INPUT POLARITY

Post by medelec35 »

The interrupts are level based and not pulse based since reading the port should then clear the interrupt.
There is not a register that can slow down the interrupt function.
Have you tried timer based interrupt captures?
I'm not sure if I can help much further as I don't have a stm32f411 to test with
Martin

max.tisc
Posts: 113
Joined: Thu Dec 10, 2020 5:40 pm
Been thanked: 10 times

Re: MCP23017 INPUT POLARITY

Post by max.tisc »

HI, if it can be useful to someone I managed to activate the INTA interrupt by modifying the GPINTENA register at address 0x04, inserting 255 modifies all 8 inputs of portA, (verified and it works) if you also need it on portB you have to modify GPINTENB at address 0x05 (I haven't tried this yet), I set the interrupt input of the micro as descending, now the amplitude of the interrupt exceeds 200uS and is sufficient to be detected
I ask Martin if he can take a look at the code to see if it is configured correctly and for improvements
thanks
Attachments
Screenshot 2025-04-24 232158.png
Screenshot 2025-04-24 232158.png (149.48 KiB) Viewed 3782 times
STM32F411_DIGITAL_FC10.fcfx
(33.87 KiB) Downloaded 44 times
Screenshot 2025-04-24 231906.png
Screenshot 2025-04-24 231906.png (80.1 KiB) Viewed 3782 times

medelec35
Matrix Staff
Posts: 1966
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 629 times
Been thanked: 659 times

Re: MCP23017 INPUT POLARITY

Post by medelec35 »

Thank you for that, I believe I know what going on.
0x04 is the interrupt enable for portA
If you write to 0x05 is the interrupt enable for portB

What I have done is modified the component.
I have added two extra functions.
ConfigureIOC()
& ReadINTFlag()

With the latter you can read the interrupt port A or port B to deturming with pin/s triggered the interrupt.
I have added masking , so you don't need to.
I have also modified the tool tips to make it clearer what values are required.
Before adding to the component database, can you please test the component and see if it behaves as expected?


Browse to this location using file explorer , it's hidden by default so just paste the link into your address bar.

Code: Select all

%ProgramData%\MatrixTSL\FlowcodeV10\Components
Place the attached component.
If Flowcode is already open, then you will need to reload your project for the new component to work
If you run any component updates, then the component you added will be overwritten, so it will stop working again (unless the component update has been pushed).
Attachments
MCP23017.fcpx
(5.48 KiB) Downloaded 43 times
Martin

max.tisc
Posts: 113
Joined: Thu Dec 10, 2020 5:40 pm
Been thanked: 10 times

Re: MCP23017 INPUT POLARITY

Post by max.tisc »

thanks for the component modification, the ConfigureIOC and ReadINTFlag functions work on portA, on portB I couldn't test them because I don't have a ready HW, but if you want I'll set up something quick to try

medelec35
Matrix Staff
Posts: 1966
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 629 times
Been thanked: 659 times

Re: MCP23017 INPUT POLARITY

Post by medelec35 »

You're welcome and thank you very much for testing.
I'm confident that if additional functions work on port A, they should also work for potb.
Any other functions you think could be great having?
Also is the read INT flag a useful and practical addition?
Martin

max.tisc
Posts: 113
Joined: Thu Dec 10, 2020 5:40 pm
Been thanked: 10 times

Re: MCP23017 INPUT POLARITY

Post by max.tisc »

I thought about it and I don't know if it can have a practical effect in some application, from the datasheet I saw that INTA and INTB can be combined, so maybe you can use a single micro pin for the interrupt

medelec35
Matrix Staff
Posts: 1966
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 629 times
Been thanked: 659 times

Re: MCP23017 INPUT POLARITY

Post by medelec35 »

Thanks for your reply.
My logic is that if any interrupt has occurred, by reading the interrupt flag value, the pin/s which caused the interrupt can be determined.
THe same as if you use the standard IOC for multiple pins, you need to determine which pin/s as caused the interrupt to trigger.
Martin

Post Reply