3 Replies Latest reply on Feb 22, 2020 9:03 AM by AH_96

    How do I assign a pin to a specific port and number from a component definition?

    LePo_1062026

      Hi,

       

      I realize what I'm trying to do is fairly sophisticated.  I'm hoping someone on the forum has done something similar.

       

      I'm new at creating my own components and have been moderately successful so far.

       

      What I'm trying to do is to create a component with one or more pins.  Based on the "Kit" enum selected by the user during configuration, the pins with be hard assigned to a specific port and number.  For example: Kit=CY8CKIT-059 then Pin_Rx=>Port(12,6) and Pin_Tx=>Port(12,7).   I realize that the user can assign the port and number in the DWR after the component is dropped it on the schematic.  I'm trying to make it more seamless for the user by auto-assigning (or auto-defaulting) the pin port assignments.

       

      The following components appear to do this in their definitions but I've had no luck reverse-engineering how they do it:

      • USBUART
      • ADC_SAR
      • ADC_DelSig
      • USBMIDI macro
      • Can Controller Macro

       

      Len

        • 1. Re: How do I assign a pin to a specific port and number from a component definition?
          AH_96

          Hi LePo_1062026

           

          This is possible if you define control files for the component. I'm taking an example of SW_Tx_UART in this case.

          Let's keep the UART Tx pin to P1[3] for the 4000S kit (CY8CKIT-145) and P4[2] for 4100S Plus kit (CY8CKIT-149). Once the component is imported and all modifications are done, right-click on the component and choose "Add component Item"

          Scroll down and choose Control File. Uncheck the Target generic device option and choose the family and the device that is needed. Then, click Create new.

          In the control file, you can specify the pin that needs to be connected to the hardware block. For example, in my case, the Tx pin needs to be connected to P1[3] and hence, my control file would be

           

          -- === SW_Tx_UART ===

          attribute port_location of \`$INSTANCE_NAME`:tx(0)\ : label is "PORT(1,3)";

           

          This can be repeated to include the required devices. I've attached the project for your reference. You can read more about control files under Help -> PSoC creator help topics -> Control files.

           

          Hope this helps.

           

          Thanks,

          Hari

          • 2. Re: How do I assign a pin to a specific port and number from a component definition?
            LePo_1062026

            Hari,

             

            Thank you for your suggestion.  I am fully aware of the Control File.   However (as posted on another discussion thread) it is tied to the Family, Series and/or Device not to the implementation of the Kit or Eval board.

             

            The components I listed in the first posting, seem to not need the Control file to auto-assign or auto-default to specific pins or port assignments.

             

            Len

            • 3. Re: How do I assign a pin to a specific port and number from a component definition?
              AH_96

              Hi LePo_1062026

               

              I believe even these components the pins need to be assigned manually, by specifying them in the DWR. Just dragging and dropping the component does not automatically configure the pins. Can you please explain an example of what you are trying to achieve?

              In case of USB, since the D+ and D- are fixed, these pins can be mapped only to those pins.

               

              In any case, since most of the kits have different chips anyway, a ctl file maybe worth a try. But yes, the ctl files do not have a direct kit dependency.

               

              Thanks,
              Hari