This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Read CPU frequency from registers on F5438?

Is it possible to read out the CPU frequency from software registers, and is it also possible to read out the peripheral clock frequencies?

I have looked in the user manual but have not found any code examples.

 

I don't know how the system is going to be set up, just going to deliver a software package that should be able to run on a couple of different hardware/software configurations. I would like to know the frequency so that I could do e.g. a software delay.

  • Adde said:

    Is it possible to read out the CPU frequency from software registers, and is it also possible to read out the peripheral clock frequencies?

    There isn't a single register that would provide this information, however, you should be able to determine the configuration of the device and how things are engaged to calculate the operating frequencies of the various clocks.  That said, this only gets you to a formula based on a reference frequency which would potentially be dependent on any external clock source feeding the MSP430.  That would be something that you can't determine easily, but could be a #define that would be used to specify to your software what the reference frequency is.

    You might be able to approximately calculate frequency using the REFO, the internal Low Frequency Oscillator, or something similar which runs at a specific frequency, within some tolerance.

     

    Adde said:

    I don't know how the system is going to be set up, just going to deliver a software package that should be able to run on a couple of different hardware/software configurations. I would like to know the frequency so that I could do e.g. a software delay.

    If you can get an input into your software package on the reference frequency at implementation time, then you should be able to develop a software package to calculate the frequency.

  • Thank you Brandon, you have given me some basic understanding of this.

    I am developing on another platform which uses a 18 MHz crystal. I output ACLK, MCLK and SMCLK to measure them using an oscilloscope. I found they were ran at 32,5 kHz, 1,035 MHz and 1,035 MHz respectively. Although MCLK were just active part of this time, why is that?

    Furthermore I read out my DCO bits = 20, MOD bits = 144 and DCOSEL bits = 32. But I don't know how to use these to determine a frequency even on this platform. Can you help me, or give me further hints?

    How can I read the LFO, or REFO? There's something called the DCO, is this the LFO or REFO?

    /Adde

     

  • You asked about "LFO". Do you mean VLO?

    VLO is a very low power oscillator. Its frequency, ~9 kHz, is not accurate and varies from chip to chip as well as at different operating voltage and temperature.

    REFO is a different oscillator. Its frequency, ~32.768 kHz, is more accurate but not as accurate as the XT1 oscillator connected to and external 32.768 kHz cryatal.

    DCO is yet another oscillator. Its frequency is adjustable (digitally controlled) by register settings from 0.1 to 100 MHz. But even at the same register setting, the frequency varies from chip to chip as well as at different operating voltage and temperature. The FLL hardware can automatically adjust the register settings using either REFO, XT1, or XT2 as a reference.

    XT1 and XT2 oscillators need external crystals. The frequencies are as accurate as the crystal and better than any of the above internal oscillators.

    ACLK, MCLK, and SMCLK are what I called clock routes. Using register settings, you can sellect from the various oscillator sources, divide the frequency down by a factor of 2^n and deliver the resulting clock to other parts of the chip.

    Thus, you can read the current register settings and figure out the frequencies of ACLK, MCLK, and SMCLK.  You can also change the settings to get other frequencies. Section 3 of the current F5xxx User's Guide explains this.

     

  • I'm going to read section 3 in the user manual once more, and I thank you very much for your answer.

    When I wrote LFO, I meant the Low Frequency Oscillator, but this might have the same function in the F5438 chip, as the VLO you describe?

    You can divide down and set the clock routes in the registers, that I've seen, and I understand the purpose. But on what frequency/oscillator are these based, the LFO, XT1, XT2 or REFO? If you use XT1 or XT2 together with 18 MHz crystals, are they still 32.768 Hz?

    /Adde

  • Without any external components or inputs, F5438 can generate VLO, REFO, and/or DCO all by itself. Each with the frequency (or frequency range) stated in my previous quick reply. The frequencies are not very precise, but REFO is the most precise one among them.

    You can connect a low frequency crystal to XT1 pins. F5438 can generate the frequency of that crystal in the LFO mode. Usually a 32769 Hz watch crystal is used which has much better precision as compared with REFO. Other low frequencies can also be generated, depending on the crystal used.

    You can connect a high frequency crystal to XT1 and/or XT2 pins. F5438 can generate the frquency of the crystal too. In the case it is connected to XT1 pins, you need to set it to HFO mode. XT2 is a HFO and cannot be used for low frequency.

    You can also connect an external clock signal to XT1IN or XT2IN. And F5438 can use that frequency too.

    The CPU and Peripheral Modules cannot use any of the above sources directly. For the CPU, you need to select (and divide) one of those sources and that is called MCLK.

    Similarly, you can selet (and divide) another (or the same) source and call it SMCLK. And yet another one called ACLK.

    Most peripheral can further select (and divide again) between SMCLK or ACLK to use.

**Attention** This is a public forum