I'm programming on a Fujitsu Microcontroller from the MB95Fxxx family and I'm trying to switch the clock modes. (I'm using the MB95 So I can switch from MAIN-PLL Clock to SUB-PLL Clock without any problems but I can not switch from SUB-PLL to MAIN-PLL correctly...
I managed to isolate the prob: to switch the clock modes we only have
2 registers (SYCC (0x07) and PLLC (0x06)). If I read the value back (I copied them into a variable) and compare them with the values in the memory map, respectively on address 0x06 and 0x07, the values don't correspond !
Code to switch from SUB-PLL to MAIN-PLL Code
PLLC_MPEN = 1; While (!PLLC_MPRDY); /* the program waits here */
The Symbol PLLC_MPRDY is 0, but the corresponding bit in memory at address 0x06 is set ! So the program works and switch every 2s in one of both modes. (I checked if the quartz were oscillating)
Does someone already have this problem ? or have a solution ?
bad news, PLLC_MPRDY is equal to 0, so the bit won=B4t be shiffted. So I =B4m already at the first position... At the first position (of the Byte) is another bit that is already set...The Condition is already true....
What are PLLC_MPEN and PLLC_MPRDY? Did you define them, or are they part of the SDK?
From how you have used them, I'm guessing that they're individual bits within the registers, implemented as macros which expand to bitfields in a structure located at a specific address, e.g.:
If you have enabled optimisations, the compiler will need the underlying variable to have been labelled as "volatile", as its value will change even when the CPU is in a busy-wait loop.
It sounds as if you might not be using the macros correctly. How about posting their definitions?
Possibly you need to use a symbol other than PLLC_MPEN in the second line. you may have to go to the datasheet for the processor to find out what the name of the register that holds the apropriate bit is called.
Thank you for the answers :-) The microcontroller, which I=B4m working with, is the Fujitsu MB95F168.
@Jasen: you are right, the MPEN symbol should not be used in the second line: I found an application note with following code example:
MPEN =3D 1; while(IO_PLLC.bit.MPRDY =3D=3D0) {;}
Sounds similar to the code I wrote...
@Nobody: The optimizations are deactivated. You are right, the individual bits within the registers, are implemented as macros which expand to bitfields in a structure located at a specific address. I also posted the IO-Definitions. (they were given from manufacturer.)
I thought that I could use the PLLC_MPRDY to check if the MAIN-PLL Clock has been stabilized or not... Even if I use _pllc.bit._MPRDY, as suggest in the example, I don=B4t have the right value from memory...
The complete IO-Map Header File can be downloaded here:
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.