- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Solved! Go to Solution.
- Labels:
-
PSoC Creator Software
- Tags:
- component
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bob,
Attached is a demo component with variable number of buried pins (1 to 10).
Have a nice weekend
/odissey1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you odissey1! That will do the trick.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As you could see in my attached project regarding the text-field expansion. My solution does not differ much from your approach.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.