Lichen Wang schrieb:
The method in slaa047.pdf is trying to adjust the DCO to maintain a certain
desired frequency. I do not think you need to do that. What you need is
to get a high enough DCO frequency and to know what that frequency is.
I suggest the following:
(a) Add an external resistor (100K, 1%) and set Rosc=1
a value around 270k will give better stablity over temperature but no so
high frequencies
(b) Set RSELx=7 (instead of default =4), default DCO+MOD are fine
(The above should give you stable and fast enough DCO frequency.)
(c) Use the 32768Hz to generate a 4096Hz ACLK. (32768 / 8=4096)
(d) Use the DCO output as MCLK and SMCLK.
(e) Use TimerA or TimerB, clock it with SMCLK and use the capture
mode to capture the rising (or falling) edge of ACLK.
(f) The difference of consecutive captured counts times 4096 is the
frequency of SMCLK.
(g) Use this measure frequency of SMCLK to set the baudrate divider.
(h) You can free (or stop) the 32768Hz and the Timer for other use.
you can use the fll_adjust() function from the mspgcc library. it
implements this. there is an example in "examples/libraries"
[...]
The external resistor will help reducing the temperature and voltage
dependency of DCO frequency. However, I think there is still about
15% variation from chip to chip.
that's without calibration. once that is done, you can save the clock
settings in the flash. however you'still only have +/-5% which isn't
accurate enough for the serial port (not over the entire temperaure
range at least).
(the msp430-dco tool can be used to get calibration values, parallel
port JTAG only)
chris