Hi,
This is a basic question about the MSP430 clock settings for MSP430G2xx series.Is it required to use the code "clr.b &DCOCTL ; set lowest DCOx and MODx settings"when setting the DCO clock.The user guide and the sample code recommends below to set the DCO clock. clr.b &DCOCTL ; set lowest DCOx and MODx settings bis.b #DCO2+DCO1+DCO0, &DCOCTL ; select max DCO Tap bis.b #RSEL0+RSEL1+RSEL2, &BCSCTL1 ; select range 7
Is it safe to remove the "clr.b &DCOCTL" line if we do not need to reconfigure the DCO during programexecution?
Regards.Paddu.
paddu1Is it safe to remove the "clr.b &DCOCTL" line if we do not need to reconfigure the DCO during program execution?
This line is required when you switch the RSEL setting. because when you just switch RSEL while DCOx is in the higher hegions, the resulting DCO frequency might be far too much for the MSP and it will crash.Also, during a switch of RSEL, there might be one truncated (= high-frequency) DCO pulse which won't do any good too.It is recommended to not only set DCOx back, but also use a /2 divider on MCLK while doing the switch.However, to make this precaution work, you must change RSEL before you set DCOx high again. (switch the two bis.b lines in your example)
In your posted example, the clr.b probably isn't necessary, but it might leave a MODx bit set while DCOx is already on max, which is not a valid setting (even though likely not harmful).
_____________________________________Before posting bug reports or ask for help, do at least quick scan over this article. It applies to any kind of problem reporting. On any forum. And/or look here.If you cannot discuss your problem in the public, feel free to start a private conversation: click on my name and then 'start conversation'. But please do so only if you really cannot do it in a public thread, as I usually read all threads. And I prefer to answer where others can profit from it (or contribute to it) too.
Hello Jens-Michael,
Thank you so much for the information.
I understood that we need to set lowest tap when there is a need to switch RSEL(Frequencies).And according to my understanding if there is no necessary to switch between different frequencies, this code is not ncessary at the begining of the program(intialization of clock)because after reset the DCO will start from the lowest settings.
Regardspaddu.
paddu1because after reset the DCO will start from the lowest settings.
DCOx starts with DCO_3 after a reset, not with DCO_0.