Building Components - Step by Step Guide

A forum where Flowcode v7 user created components can be shared, discussed and reviewed.

Moderator: Benj

kersing
Valued Contributor
Valued Contributor
Posts: 1894
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 541 times
Been thanked: 1058 times
Contact:

Re: Building Components - Step by Step Guide

Postby kersing » Wed Aug 30, 2017 5:15 pm

Igor,

Multiple components accessing the same MCU pin is not a good idea at all. (In my opinion it is a disaster waiting to happen) I doubt very much that would be a supported use of components. Keep in mind component code might change to fix bugs or because of a Flowcode update and things may behave completely different. So my advice is not to go there.

Flowcode at the moment only sets the TRIS registers for the required operation (input or output), if you need pull up or anything like it you will need to use a C code block and add the required code yourself.
If you need open collector pins you first need to check the data sheet of the MCU to see if it is supported. If it is supported you will need to add C code to set the pin for this.

Best regards,

Jac
These users thanked the author kersing for the post:
LeighM (Thu Aug 31, 2017 8:41 am)
Rating: 5.26%
 
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

johnsondav
Posts: 186
Joined: Thu Jun 28, 2012 7:29 pm
Location: Durham
Has thanked: 92 times
Been thanked: 181 times
Contact:

Re: Building Components - Step by Step Guide

Postby johnsondav » Wed Aug 30, 2017 8:23 pm

Hi Igor

I am curious as to how you are connecting your device to the MCU. Looking at the data sheet, it shows these connections - four:
TCA6408A2.jpg
TCA6408A2.jpg (54.51 KiB) Viewed 1772 times
. On the MCU side, there are four required connection for this device (TCA6408A).

Therefore, I would design my component to have just three connections:
- SDA
- SCL
- Reset

As shown above, the reset pin would be missing from the standard FC7 I2C component. This would need to be included in the design of the new component for the TCA6408A to allow power-up function to work correctly. This would leave only the interrupt connection to by added be the user of the component in their project. The standard FC7 I2C component does not have a reset connection available. Therefore, during the building of your component, a 'Digital I/O pin would be added to handle the reset function for the component. When the component is placed into a project, FC7 will allow the user to select an available pin to perform this 'Reset' function, following the functionality designed into the component.

TCA6408A1.jpg
TCA6408A1.jpg (96.72 KiB) Viewed 1772 times


The interrupt I would leave this off your component design and allow the user to connect the interrupt directly using one of the available interrupt pins on the MCU. The user of your component, when writing their code will place an interrupt icon to allow the MCU to begin dealing with the connected device (An interrupt handling routine), as shown here:
TCA6408A3.jpg
TCA6408A3.jpg (87.86 KiB) Viewed 1772 times


Designing a FC7 component for the above device in this way may not suit everyone, but will give you an opportunity to review its performance before getting bogged down in detail. Therefore, get communication to work first, then review.

If I understand the devices start-up function correctly, all port pins of the TCA6408A are set as 'Inputs', may be wrong on that, its how I have read it. Once power-up is complete, programing of the device can begin to set which are input and which are output. From this, the component will have an 'Initialisation' macro which allows the power up function to be performed in a timely manner, then the user can program the I/P's accordingly afterwards by calling further macro calls to the component you will have added during the design of the component.

Hope this helps.

Regards
Dave
These users thanked the author johnsondav for the post (total 2):
LeighM (Thu Aug 31, 2017 8:41 am) • medelec35 (Wed Jun 06, 2018 1:25 pm)
Rating: 10.53%