Page 1 of 1

Setting Clock speed on MOD5441X

Posted: Thu Jul 03, 2014 4:44 pm
by joshuaberry
Hi,
I am trying to set up a 'low power' operation mode for a battery operated project but I still would like to return to full speed to perform processing routines, then back to low speed.

At the moment as a start, I am setting sim2.clock.pll_cr[REFDIV] to 1 to half the Vco frequency. This works most of the time but seems to lock up sometimes, usually after a power reset (as opposed to a soft reset)

Here's the code I'm using to set this (which is partly based on this post: http://forum.embeddedethernet.com/viewt ... ?f=7&t=512) :

Code: Select all


	SerialClose(0);

	// set the Fvco clock speed variable
	CPU_CLOCK = 125000000;

	// set PLL_CR[REFDIV] to 1
	sim2.clock.pll_cr |= (1 << 8);

	asm("nop"); asm("nop"); asm("nop"); // Some nops to ensure lose of clock is detected
	while( ( sim2.clock.pll_sr & 0x10 ) == 0 );  // Wait for PLL lock


	// Now adjust the system tick
	DWORD tpmr = ( CPU_CLOCK / (128 * 2) );		// divide by 2 because we halved the Fvco by setting the REFDIV bit to 1
	tpmr /= TICKS_PER_SECOND;
	sim2.pit[0].pmr = ( WORD ) tpmr;

	SimpleOpenSerial( 0, 9600 );

As said this works most of the time and I haven't figured out what conditions cause it to fail.

I'm looking at slowing down some other clocks in sim2.clock.pll_dr (turning some off that I don't need) but I have had less success with that and will come to it once this is working. Does anyone have any advice for the code above, or any other advice for changing system clock speed back and forth?

Thanks, (and sorry for the vague question :S)

Josh

Re: Setting Clock speed on MOD5441X

Posted: Thu Jul 03, 2014 7:49 pm
by roland.ames
I haven't tried changing the main system clock, but you might be interested in http://forum.embeddedethernet.com/viewt ... f=3&t=1922

Re: Setting Clock speed on MOD5441X

Posted: Sun Jul 06, 2014 6:54 pm
by joshuaberry
Thanks for the reply. I saw that post and I've turned off what I don't need but it didn't achieve as much as I'd like. I'll keep poring through the Ref manual...