cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC Creator & Designer Software

Esteemed Contributor II

I want to create a component with a non-fixed number of output pins (eg: 1 to 10 pins).

For instance: In the component dialog I want to specify 3 pins and the component needs to generate MyPin_0, MyPin_1 and MyPin_2.

I have done that before using pins on a single port, but this time I have to assign the pins freely to any available port.

One of the gurus can help me?

Bob

0 Likes
Reply
1 Solution
Honored Contributor II

Hi Bob,

Attached is a demo component with variable number of buried pins (1 to 10).

Have a nice weekend

/odissey1

View solution in original post

0 Likes
Reply
9 Replies
Honored Contributor II

Hi Bob,

Attached is a demo component with variable number of buried pins (1 to 10).

Have a nice weekend

/odissey1

View solution in original post

0 Likes
Reply
Esteemed Contributor II

Thank you odissey1! That will do the trick.

Bob

0 Likes
Reply
Honored Contributor II

Bob,

there is another solution available (project attached).

I have a question though. In such arrangement, pins can be accessed like

CyPins_SetPin(myPins_1_REG_0_0);

which is not very convenient.

Is there any way to access pins through their index? like

CyPins_SetPin(myPins_1_REG_0[0]);  // this won't work

odissey1

Pin number_Congigure_1a.png

0 Likes
Reply
Esteemed Contributor II

As a standard there is not an option as you want.

My workaround is to define an array of pointers to functions and assign the wanted Pin_Write() APIs.

typedef void (*PinWrite)(uint8);

PinWrite const WritePins[] = {

   {
   &Servo_0_Write,
   &Servo_1_Write,
   &Servo_2_Write,
   &Servo_3_Write,
   &Servo_4_Write,
   &Servo_5_Write,
   };

Bob

Honored Contributor II

Bob,

I managed to itemize pins in non-contiguous (spanning) mode. It is not quite the same as you mentioned above, but it works. Demo Project attached. The pointer array declaration came out way ugly, but it was the only way I managed it to work. Problem was due to the fact that the number of pins is variable, so its impossible to make pointers to non-existing pins.

Appreciate if you can point to a better solution.

/odissey1

0 Likes
Reply
Esteemed Contributor II

As you could see in my attached project regarding the text-field expansion. My solution does not differ much from your approach.

Bob

0 Likes
Reply
New Contributor II

It is matter of taste of-course: you could use one control register of PSOC3/5 and wire connect the bits to the pins you want. Then you may need to modify the specific bit of the control register or can modify several bits at once.

0 Likes
Reply
Esteemed Contributor II

Thank you for the hint, but here I am working to create a component where the user will specify how many pins the component is actually using. The control register does not help in this case.

Bob

0 Likes
Reply
New Contributor II

It will get much more difficult as needed indeed but SHOULD still be possible for up to 32 IO-s. Some more hints: combining UDB-s and preprogrammed muxes which can be configured according to the selection from user. Never mind if no help from it.

0 Likes
Reply