Page 2 of 2

Re: Building Components - Step by Step Guide

Posted: Wed Aug 30, 2017 5:15 pm
by kersing
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

Re: Building Components - Step by Step Guide

Posted: Wed Aug 30, 2017 8:23 pm
by johnsondav
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 2565 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 2565 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 2565 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