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

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

cross mob
Len_CONSULTRON
Level 9
Level 9
Beta tester 500 solutions authored 1000 replies posted

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

pastedImage_0.png

Len
"Engineering is an Art. The Art of Compromise."
0 Likes
1 Solution
ScottA_91
Employee
Employee
10 solutions authored 100 replies posted 50 replies posted

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.

View solution in original post

0 Likes
5 Replies
ScottA_91
Employee
Employee
10 solutions authored 100 replies posted 50 replies posted

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.

0 Likes

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.

Len
"Engineering is an Art. The Art of Compromise."
0 Likes

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.

0 Likes

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

Len
"Engineering is an Art. The Art of Compromise."
0 Likes

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.

0 Likes