You are here

How to test for number of Ports? | Cypress Semiconductor

How to test for number of Ports?

Summary: 3 Replies, Latest post by Mark-CY on 18 Sep 2011 04:49 PM PDT
Verified Answers: 0
Last post
Log in to post new comments.
user_7880656's picture
49 posts


I'd like to be able to test for the number of GPIO/Ports supported.

However, you can't do this :

#ifdef PRT5DR
  /* do something with Port5 */

because PRT5DR is declare as a BYTE variable and not a "#define".

Is there any way to determine dynamically (during compile time) what Pins/Ports are supported?


Tom Moxon


rtcy's picture
Cypress Employee
112 posts


just wanted to let you know that your question has been noted and we are looking what kind of solution we can provide for this.

What is the background of your question? Do you want to write code that should do some kind of self configuration depnding what device it runs on? Is the code supossed to find out what chip it is running on? Always curios what our customer's applications are.


user_7880656's picture
49 posts


Yes, it is desireable to be able to configure software based on what resources are available.

Many microprocessor vendors provide this capability based on the part number used.

(i.e. a "partnumber.h" include file).

Aside from the obvious, how many ports and pins are available,

another example would be the existance of a sleep timer or watchdog timer or not.

For example Cortex-M3 provides a hardware Systick Timer, where this function needs to

be created from a generic timer in M8C or i8051. 

I'm just trying to find out if this exists or not,

so I don't need to reinvent the "timewheel" - so to speak...



Tom Moxon



Mark-CY's picture
Cypress Employee
1 post


Currently there is no way to specifically test for which ports are supported. The closest to that would be defines that are created for each pin, identifying the port. You can find these in cyfitter.h. For example:

#define Test_Pin__0__PORT 0

Assigns Test_Pin to port 0. If you know what all pins you want, you could determine what all ports are being used. 

The information should be present in the report file that is generated, but this probably isn't enough for what you want to do. We'll keep this in mind for future releases.


Log in to post new comments.