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.
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.
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.
Clk Domains.cyprj.Archive01.zip 592.8 K
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.
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?
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.