2 Replies Latest reply on Aug 5, 2019 11:38 PM by GeonaP_26

    How do I reference multiple ports with a virtual port?

    DaPu_2346716

      I created a port that uses 16 pins on the processor. These are simply feeding LEDs that I want to update at the same time every time. This spans across multiple ports: P0[0..6], P1[0..3], P1[7], and P2[0..3]. I see that I'm able to map them as spanning but how to I reference the whole port in code?

        • 1. Re: How do I reference multiple ports with a virtual port?
          DaPu_2346716

          I checked with my FAE and he said, "Looks like from this you do not get APIs generated for bus control.

          You will have to write a single function for writing each port data register based on the 16 bits passed to the function."

           

          Contiguous vs Spanning.jpg

          1 of 1 people found this helpful
          • 2. Re: How do I reference multiple ports with a virtual port?
            GeonaP_26

            Adding on to the reply;

             

            There are two ways to access Pins Component, i.e., on a per-pin basis as well as on component-wide basis.

            • If pins are contiguous, component wide API functions (Eg: LED_Read()) will get generated. This will write/read to all pins together.
            • If pins are non-contiguous, you can use per-pin API (Eg: CyPins_ReadPin(LED_0)). Please refer to System Reference Guide (PSoC Creator, Help>System Reference Guide) for more details.

             

            Per-pin API are generated for both cases. You can use this function to update data registers in your application. The aliases (Eg: LED_0 or LED_<AliasName>) for the pin registers are available in the LED_aliases.h file, where "LED" is the instance name of the Pins Component. You can find more details in section 'Per-Pin API' of Pins component datasheet.