How to test for number of Ports?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi,

   

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 */
#endif

   

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?

   

thanks,

   

Tom Moxon

0 Likes
3 Replies
Anonymous
Not applicable

Tom,

   

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.

   

Robert

0 Likes
Anonymous
Not applicable

Robert,

   

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...

   

 

   

regards,

   

Tom Moxon

0 Likes
Anonymous
Not applicable

 Tom,

   

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.

   

-Mark

0 Likes