5 Replies Latest reply on Feb 22, 2019 1:22 PM by ScottA_91

    Can the compiler get access to the user assigned XTAL or DSI Frequencies?

    user_119654

      Hi,

       

      I'm using Creator's "Configure System Clocks" editor.  I assign the XTAL or Digital Signal (DSI) frequencies.  When I perform a "Generate Application"  I cannot find any of these assigned frequencies in the .h or .c files created.

       

      Can the compiler get access to the user assigned XTAL or DSI Frequencies?  Or am I missing something?

       

      Len

        • 1. Re: Can the compiler get access to the user assigned XTAL or DSI Frequencies?
          ScottA_91

          The external crystal (XTAL) or DSI frequencies are not in the c code.  They are used to calculate timing while generating your application and for setting dividers to get desired frequencies on clocks derived from these signals.

           

          That's not to say it isn't possible.  You could create a software component that could query the clock speed and create a constant, but it isn't built in.

          • 2. Re: Can the compiler get access to the user assigned XTAL or DSI Frequencies?
            user_119654

            Scott,

             

            Thank you for your response.

             

            When you say "create a software component", do you mean a PSoC Creator component or a PSoC application?

             

            My goal is to prevent duplication.  If I enter the value in the DWR clock configuration, I'd prefer not to have to state it again in a #define values in a header file.  This is to avoid the possibility that I alter the DSI or XTAL frequencies later in the DWR and forget to update the #define values.

             

            My final goal is to create a PSoC app that changes clock domain parameters such as BusClk and/or MasterClk dividers, PPL fractional values and/or sources (etc) and be able to programmatically determine functional end result frequencies for components used in the app.

             

            I've attached a PSoC app project that displays the current clock domain parameters if you're interested.

             

            Len

             

            PS:  I just located some documentation in PSoC Creator about "PSoC Creator Extensions API Reference".  This may be useful.  Does anyone know of example code that uses these API references?  It appears to be in C# which is no problem for me.

            • 3. Re: Can the compiler get access to the user assigned XTAL or DSI Frequencies?
              ScottA_91

              I meant a PSoC Creator component.

               

              See page 120 of the component author guide, Rev *U.

               

              Basically, you can make a component that has a clock terminal, and then use C# during code generation for that component which would be able to query the clock speed and write a header.

               

              It isn't for the faint of heart.

               

              That said, if you want an example of how to do this, you can import any Creator component into your current design and look at the customizer code (c#).  You'll need to find a component that's doing code generation.  The UDB uart might be a good place to start.

               

              To import, go to a schematic and find the component you wish to import/change.  In the work space explorer click on the components tab.  Drag the component from the component catalog to your design in the workspace explorer and it should bring up the import dialog with the details filled in.

               

              You'll need to read through the component author guide to understand all the details and gotchas I've glossed over.

              • 4. Re: Can the compiler get access to the user assigned XTAL or DSI Frequencies?
                user_119654

                Scott,

                 

                I've been doing some reading on component authoring and trying some experiments.  Not "for the faint of heart": No joke!

                 

                I'm curious how a person can create component configuration forms visually.  I've worked with C# in Visual Studio with great success.

                Is it possible to develop the Component configuration forms within Visual Studio and have them available for PSoC Creator component compiles?

                 

                Len

                • 5. Re: Can the compiler get access to the user assigned XTAL or DSI Frequencies?
                  ScottA_91

                  You can, you just need to import all the code into your component.  (Generally the .design.cs file.)

                   

                  That said, generally you don't need to make a new UI, it is better to just give standard parameters with reasonable values.  The UI is only really needed for things like PWMs where you need a graph.