Hi,
I've recently purchased a M52259Demo and have been playing with the Processor Expert both with supplied demos and from projects I've started from scratch. With both of them I'm having problems with the board running approx x5.5 slow when using the external 48MHz crystal.
Taking this project as an example:
C:\Program Files\Freescale\CodeWarrior for ColdFire V7.1\(CodeWarrior_Examples)\Processor_Expert_Examples\M52259EVB\Init_GPIO,
I simply change the Remote Debug to Coldfire V2-V4 JM60 OSBDM then compile and run. Unfortunately, I get junk on the serial port (set correctly to 38400,8,N,1) and the LED flashes three times slowly.
If I change the High Speed Clock in the CPU bean from external to internal, everything bursts into life correctly. The LED flashes at a sensible speed and the serial port produces the expected text.
In my own project, I have used a timer driven interrupt to flash an LED and a PWM channel to flash a different LED. Both methods run a factor of x5.5 slow on the external clock and at the correct speed when using the internal clock. The external clock input is set to 48MHz - unchanged from the defaults.
Is this likely to be me not pressing a button correctly somewhere or is it likely to be down to me having a duff demo board?
Thanks in advance for any help given!
Solved! Go to Solution.
Hello,
regarding to the problem with running M52259 from external clock. We are aware of this problem and it will be fixed in the next release of PE. For now as workaround is there the possibility to put the following code into CPU.c using "User code after PE initialization" property in "Build options" tab in CPU component (formerly called beans).
setReg8(OCLR, 0xC0); // Turn on crystal, External crystal oscillator enabled.
// External oscillator running in external crystal mode.
// External oscillator running in normal power mmode.
// Support external crystal of 32kHz.
setReg8(CCLR, 0x00); // Switch to crystal.
setReg8(OCHR, 0x00); // Turn off relaxation oscillator
Note:
For more datials please follow this https://community.freescale.com/message/63780#63780.
We are sorry for the inconvenience.
best regards
Vojtech Filip
Processor Expert Support Team
Hi
The M52259EVB has clock mode jumpers which control with which setting the board starts with - the DEMO doesn't. By overwriting the settings during initialisation the SW can however always control how it runs though.
Try a pre-compiled target image: http://www.utasker.com/SW_Demos.html.
There is one for your board which will allow you to test Ethernet, USB and the UART. An LED blinks at 2.5Hz - default Baud is 115200.
If it runs off, it is something to do with the HW - if not it is a setting.
Regards
Mark
Thanks Mark,
I've downloaded the image and programmed it in with success. The serial port confused me for a while - the correct baud rate is 19200, but I got that working as does the ethernet port. The LED flashes at about 2.3Hz as closely as I could measure it so it looks like I have good hardware (assuming that uTasker uses the external crystal).
I guess this tells me I have a configuration problem in my setup which is causing the clock to be a factor of x5.5 out. I can't see it though.....
Hi
Sorry about the serial port speed - I though it was 115200 in that demo but obviously not - you can also check and control the UART speed via TELNET (or via UART when the Baud is correct) - go to the serial menu. You can also save it by commanding "save".
When running from the external 48MHz the following may help at initialisation:
MCF_CLOCK_OCLR = (OSCEN | REFS | RANGE); // enable external crystal oscillator
MCF_CLOCK_CCLR = 0x00; // switch to crystal source
MCF_CLOCK_OCHR = 0x00; // disable relaxation oscillator
Then to set the PLL
MCF_CLOCK_CCHR = (PRE_DIVIDER - 1); // values from 1 to 8 possible - should generate 1..10MHz input
MCF_CLOCK_SYNCR = ((((PLL_MUL - 4)/2) << 12) | CLKSRC | PLLMODE | PLLEN | (POST_DIVIDE << 8)); // set up PLL to generate the required frequency
while (!(MCF_CLOCK_SYNSR & PLLOCKED)) { SIM_LOCK } // wait for PLL to lock
For your board to run at 80MHz:
MCF_CLOCK_CCHR = 6
MCF_CLOCK_SYNCR = 0x3007
You can also try the uTasker project since it gives you everthing that you need (from initialisation through device drivers, TCP/IP, USB to graphical library and SD-Card FAT). It allows you to simulate the Kirin3 (much easier to develop and debug with) - it also shows you the processor PLL setup results and warns you if anything is configured to give invalid results.
Regards
Mark
Hello,
regarding to the problem with running M52259 from external clock. We are aware of this problem and it will be fixed in the next release of PE. For now as workaround is there the possibility to put the following code into CPU.c using "User code after PE initialization" property in "Build options" tab in CPU component (formerly called beans).
setReg8(OCLR, 0xC0); // Turn on crystal, External crystal oscillator enabled.
// External oscillator running in external crystal mode.
// External oscillator running in normal power mmode.
// Support external crystal of 32kHz.
setReg8(CCLR, 0x00); // Switch to crystal.
setReg8(OCHR, 0x00); // Turn off relaxation oscillator
Note:
For more datials please follow this https://community.freescale.com/message/63780#63780.
We are sorry for the inconvenience.
best regards
Vojtech Filip
Processor Expert Support Team
Thanks Vojtech Filip, that solved the problem.
It solved my problem also with the Axiom CMM52259- OEM board . It has the same CLKMOD configuration. We detected the wrong system clock configuration after we tried to use the UART and got garbled output .
Thanks.