How to stop the processor?

Discussion to talk about software related topics only.
Post Reply
khoney
Posts: 125
Joined: Fri Sep 11, 2009 12:43 pm

How to stop the processor?

Post by khoney »

I'd like to stop my 5270 module to see if it is causing an EMI problem with the rest of my circuit. I would like to issue commands to put it in stop mode so that it won't wake up. I've tried issuing the following commands:

sim.scm.lpicr=0xF0;
sim.ccm.lpcr=0xC0;
sim.ccm.lpcr=0xD0;
asm("stop #0x0700");

All this does is reset the microcontroller. I think I might not be in the correct mode to execute the stop instruction, but I'm having a real hard time gleaning the pertinent info from the Freescale manuals. Can anyone provide me with a working sequence to stop the module?
User avatar
lgitlitz
Posts: 331
Joined: Wed Apr 23, 2008 11:43 am
Location: San Diego, CA
Contact:

Re: How to stop the processor?

Post by lgitlitz »

Sorry but it is not that easy to stop the processor and keep your application alive on the MOD5270. The problem is that your application is running from SDRAM. When you stop the processor then you are also stopping the refreshing of the SDRAM which means you loose your application. I have experimented a bit with self refresh mode but it was tricky and I have not got this to fully work.

I made a post a few weeks ago that describes how to reduce power on the MOD5270 by slowing the clock speed ( http://forum.embeddedethernet.com/viewt ... ?f=7&t=512 ). The first thing I would try is running this example to see if EMI is affected. You may want to try running at full speed and just disabling the PHY with the function DisablePHY(); from ethernet.h.

There is also Frequency modulation adjustment in the PLL that generated the CPU clock frequency. This is designed to reduce EMI. This code was used on the PK70 platform and adjusted using a spectrum analyzer. Depending on your final hardware you may need to adjust the values defined at the beginning of this code. Look at the clock chapter of the MCF5270RM for more information on how these values effect the clock.

-Larry

Code: Select all

/**************************************************************/
// The Following section of code turns on the spread spectrum
//	for the PLL and also reduces pin drive strengh
// This should be used to reduce EMI emissions	
/**************************************************************/
	#define FM_RATE (0x1000)	// fref/40
	//#define FM_RATE (0)			// fref/80
	
	//#define FM_DEPTH	(0)			// FM disabled
	//#define FM_DEPTH	(0x400)		// 1% of fsys\2
	#define FM_DEPTH	(0x800)		// 2% of fsys\2
	
	#define FM_EXP (128)
		
	#define SYNSR_LOCK_BIT 0x00000008
	
	//sim.clock.syncr |= 0x8000; 
	sim.gpio.dscr_eim = 0;
	sim.gpio.dscr_feci2c = 0;
	sim.gpio.dscr_uart = 0;
	sim.gpio.dscr_qspi = 0;
	sim.gpio.dscr_timer = 0;

	//syncr factory setting = 0x03000000, MFD = 011, RFD = 000
	sim.clock.syncr |= FM_EXP; // set to calculated EXP
	sim.clock.syncr &= ~0x00000C00; // Clear Depth fields to disable modulation
	while((sim.clock.synsr & SYNSR_LOCK_BIT) != SYNSR_LOCK_BIT);  //wait to lock
	
	sim.clock.syncr |= 0x00080000; //MFD = 011, RFD = 001
	sim.clock.syncr |= ( FM_RATE | FM_DEPTH);  
	while((sim.clock.synsr & SYNSR_LOCK_BIT) != SYNSR_LOCK_BIT);  //wait to lock
	
	sim.clock.syncr &= ~0x00080000; //MFD = 011, RFD = 000
	
	while((sim.clock.synsr & 2) != 2);  // Wait for calibration to be done

/********************************************************************/
// EMI reduction code done
/**************************************************************/
	
	OSTimeDly(2);
	
	if((sim.clock.synsr & 1) == 1)
		printf("Frequency Modulation of Clock Successfully Calibrated!\r\n");
	else
		printf("Frequency Modulation of Clock FAILED Calibration!\r\n");
	
khoney
Posts: 125
Joined: Fri Sep 11, 2009 12:43 pm

Re: How to stop the processor?

Post by khoney »

Hi Larry,

Thank you for your very helpful response. I actually don't care if the application quits running, because I have a separate processor that is doing the 'EMI sensitive' stuff, and I'm trying to see how things work if I turn off the 5270. What I would like to do is run my app normally, then through a GUI menu option on my Netburner-controlled LCD, stop the clock on the 5270. Are you saying that this will always generate a reset?
User avatar
pbreed
Posts: 1091
Joined: Thu Apr 24, 2008 3:58 pm

Re: How to stop the processor?

Post by pbreed »

I'm lazy I'd just add a switch that holds RSTI low.
I think that effectively stops everything.
(This does not work if you need the GPIO to stay in a fixed state.)
User avatar
lgitlitz
Posts: 331
Joined: Wed Apr 23, 2008 11:43 am
Location: San Diego, CA
Contact:

Re: How to stop the processor?

Post by lgitlitz »

To just stop the processor for EMI testing on a MCF5270/34 you can use the following code:

Code: Select all

#include <sim.h>
#include <ethernet.h>


DisablePHY();
sim.scm.lpicr=0xF0;
sim.ccm.lpcr=0xC8;
asm("stop #0x2700");
The problem you were having is that you were writing 0x0700 to the SR register which will put the processor in User mode. Writing a stop instruction in User mode will trap the processor so always use 0x2X00 to keep the CPU in Supervisor mode. I also suggest calling the function DisablePHY(); from Ethernet.h. This will put the Ethernet PHY in low power mode which will also turn off the 25MHz oscillator on the PHY. You will need to reset the processor to recover from stop mode since the SDRAM data is now corrupt.

-Larry
khoney
Posts: 125
Joined: Fri Sep 11, 2009 12:43 pm

Re: How to stop the processor?

Post by khoney »

Awesome, Larry! Thanks a heap!
User avatar
tod
Posts: 587
Joined: Sat Apr 26, 2008 8:27 am
Location: Southern California
Contact:

Re: How to stop the processor?

Post by tod »

khoney,

sounds like once you get it working it would make a great wiki article to link up to the how to page.

Tod (one-man wiki evangelist team)
Post Reply