Strange clock behavior

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

cross mob
Anonymous
Not applicable

Hi

   

I have an external 24MHz crystal and the ECO is using this. In the configure system clocks window, Direct_Sel, PLL1_Sel and PLL0_Sel are all set to use ECO. HFCLK uses Direct_Sel, and the SYSCLK divider is 1. Everything is thus running at 24MHz.

   

I have 2 clocks placed in my .cysch. One is set to 24MHz the other to 1kHz. On the clock tab in the .cydwr page one has a divider of 1 the other 24,000. This all seems correct.

   

There is a timer using the slow clock, its count is set to 1000. I have an ISR on the slow clock TC. The ISR toggles an LED. The LED, in operation, flashes at 0.5Hz - which is also correct.

   

But, if I set IMO to 40MHz but leave everything else the same (still using the 24MHz HFCLK for everything that I can see), then my LED flashes faster thus the 1kHz clock (based on HFCLK) must have sped up. Measuring the LED frequency I can see that the 1kHz clock is actually 40/24 * 1kHz. That is, my slow clock is using IMO.

   

Why? [Recap: the 1kHz clock has HFCLK defined as its source]

0 Likes
11 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

It might be easier for us to follow your explanation when we have a project that shows that behavior. Can you please post your complete project, so that we all can have a look at all of your settings. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Should be attached. Ignore most of the project as I'm in "playing" mode. But have a look at the Timers and Clock_2. The Timers seem to be using IMO but I think it shouldn't be.

0 Likes
Anonymous
Not applicable

Sorry. Won't upload.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Try harder.

   

 

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

🙂

   

Here's a project archive. Workspace zip is too big.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

In that uploaded project there is no "slow" clock of 1kHz.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

You're right, I removed that but the problem still remains.

   

The block called system timer was origianally fed with a 1kHz clock. I changed it so everything is now using 24MHz. The TC int is now at 4Hz (couldn't get to 1Hz with a pre-scale of 128 and a max 16-bit counter).

   

But anyway, all of the timers seem to be using IMO and not HFCLK.

0 Likes
Anonymous
Not applicable

But when I just copy the timers from the SC4 (previously attached) project into a blank one, they don't seem to use IMO. That is, I can vary the IMO frequency setting (which shouldn't be being used by anything else) and my LED flashes at the correct rate,

   

I wonder is it anything to do with BLE.

0 Likes
Anonymous
Not applicable

That appears to have confirmed it. If I remove the BLE component then I can get everything to run at 24MHz ECO. Changing the IMO frequency makes no difference to my timers - as expected.

   

If the BLE part is present, then, even though all of the settings appear to be correct and ECO is selected for everything (configure system clocks, etc), the timers run at the IMO rate - not as expected.

   

I can't believe that PSoC Creator and the PSoC is at fault, so I must be doing something wrong.

   

I have an open case with Cypress (2 days old).

0 Likes
Anonymous
Not applicable

There is an interesting statement in the PSoC4_BLE TRM. Fig 8-1 on page 86 shows that either ECO, IMO or EXTCLK can be used to generate HFCLK (and hence SYSCLK and PERn_CLKs). IMO can be from 3-48MHz.

   

But the interesting bit is on page 229 in the BLESS section. Here it states that ECO is used for the Radio-PHY, and it mentions that ECO can be 3, 6, 12 or 24MHz. But then it goes on to mention HFCLK's use and that it can range from 3-48MHz. So it appears that HFCLK is driven by IMO when BLESS is using ECO.

   

If this is true then is there any way of using ECO for internal peripherals? If not, then this device is sadly of no use to us.

0 Likes
Anonymous
Not applicable

That'll teach me for using the Cypress BLE example code.

   

There is a line of code which puts the BLE into deep sleep. But upon deep sleep entry HFCLK is switched to IMO. Upon deep sleep exit HFCLK is NOT switched back to ECO.

   

See TRM pages 232-233.

   

Hope this may be of some help to others.

0 Likes