MCF5208 - Can't Change PLL frequency in Codewarrior debugger config file

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MCF5208 - Can't Change PLL frequency in Codewarrior debugger config file

2,909 Views
GeorgeA
Contributor I
I would like to change the PLL frequency in the debug config file but I get an error when it runs the config file. The error is "writemem error: writemem.b 0xfc090006 0x77 failed."
 
It looks like you cannot enter LIMP mode, which is needed according to the mcf5208 manual before changing the PLL divider.
 
I am able to do this in my ROM code, but need a way to do it in my RAM download code.
 
Any help appreciated.
 
- George
 
Part of my config file script:
;   /* The MFD bits may only be written when the device is in limp mode MISCCR[LIMP] = 1 */
;   mcf5208_ptr->RCP.MISCCR = MCF5208_CLOCK_MISCCR_LIMP | MCF5208_CLOCK_MISCCR_LIMPDIV(2);
writemem.w 0xFC0A0010 0x1002
delay 10
;   /* CPUDIV = 3, BUSDIV = 6 */
;   mcf5208_ptr->CLK.PODR = 0x36;
;writemem.b 0xFC090000 0x36
;   /* Multiply 16Mhz reference crystal by 125 to acheive system clock of 166.67Mhz */
;   mcf5208_ptr->CLK.PFDR = 0x77;        // 158.67MHz - to sync backplane comms. at higher rate.
writemem.b 0xFC090006 0x77
     
;   /* Exit limp mode */
;   // Per errata, after exiting LIMP mode, 0x40000000 must be written to addr. 0xFC0A8080.
;   // This must be done prior to initiallizing SDRAM. (Otherwise it wont work.)
;   mcf5208_ptr->RCP.MISCCR &= ~MCF5208_CLOCK_MISCCR_LIMP;
writemem.w 0xFC0A0010 0x0002
delay 10
writemem.l 0xFC0A8080 0x40000000;
 
Labels (1)
0 Kudos
2 Replies

673 Views
GeorgeA
Contributor I

Yes, I am using a mem file. I modified my mem file with range statements for each register I write to, but this did not solve the problem.

After much experimentation, (and frustration) I found that changing the instruction that puts the device in LIMP mode solves the problem. I don't know why it works, but here is the change:

Code:

;   /* The MFD bits may only be written when the device is in limp mode MISCCR[LIMP] = 1 */;   mcf5208_ptr->RCP.MISCCR = MCF5208_CLOCK_MISCCR_LIMP | MCF5208_CLOCK_MISCCR_LIMPDIV(2);;writemem.w 0xFC0A0010 0x1002  ; old instructionwritemem.w 0xFC0A0010 0x1010  ; new: write LIMP mode enable bit in high and low byte.

 


 My ROM code doesn't seem to need this. When I use the writemem.w on other registers it works. Not sure what's going on.

 

- George

0 Kudos

673 Views
marc_paquette
Contributor V
Are you using a mem file? If so, make sure the address you are writing to is not write-protected.
 
I've been told that you should change the "Clock Module Registers" part of your mem file to something like:

// Clock Module Registers
range      0xFC090000 0xFC090000 1 ReadWrite    // PODR
reserved   0xFC090001 0xFC090001
range      0xFC090002 0xFC090002 1 ReadWrite    // PCR
reserved   0xFC090003 0xFC090003
range      0xFC090004 0xFC090004 1 ReadWrite    // PMDR
reserved   0xFC090005 0xFC090005
range      0xFC090006 0xFC090006 1 ReadWrite    // PFDR
reserved   0xFC090007 0xFC09FFFF
 
Marc.
0 Kudos