3 Replies Latest reply on Sep 18, 2011 4:49 PM by markk_76

    How to test for number of Ports?




      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

        • 1. Re: How to test for number of Ports?



          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.



          • 2. Re: How to test for number of Ports?



            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

            • 3. Re: How to test for number of Ports?



              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.