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.

MSP430F2112: BCM initialization: Setting fCPU=16MHz

Part Number: MSP430F2112

Hello,

My customer is trying to set the fCPU to 16MHz. But their firmware freezes right after "DCOCTL = CALDCO_16MHZ;".

My customer code is:

(CPU RESET)
  ...
  BCSCTL1 = CALBC1_16MHZ;
  DCOCTL = CALDCO_16MHZ;   //  >>> Freeze right after thi line.

So, could you please give us a initializaiton procedure to set fCPU=16MHz ?


My idea would be:

(CPU RESET)
  ...
  BCSCTL1 = 7;  // Errata BCL12 requires RSEL=7 during DCOCTL change.
  DCOCTL = CALDCO_16MHZ;
  BCSCTL1 = CALBC1_16MHZ;

I tried to write my idea, but I have the following concerns:

- Some sample codes shows "3-step clock startup sequence", but I'm not sure it is true for 16MHz. Especially, I'm afraid DCOCTL=0 is harmful. It should be 7.:
    from [msp430x21x2_clks.c]
    DCOCTL = 0;                               // Select lowest DCOx and MODx settings
    BCSCTL1 = CALBC1_8MHZ;                    // Set DCO to 8MHz
    DCOCTL = CALDCO_8MHZ;

To say strictly, my customer question was "how to set RSEL=15". I translated it to fPU=16MHz, but I'm not sure it is completely the same or not.

  • Hello,

    After reading the BCL12 Errata published for the MSP430F2112, it can be inferred that the method suggested for loading a specific DCO target value as suggested in the "TLV Structure" chapter of the MSP430x2xx Family User's Guide still applies if it is executed after a device reset prior to any other modifications being made to the BCSCTL1. Thus, if your startup code follows the structure shown in the example code (below) for initializing the DCO then your customer should be able to successfully set the DCO to 16MHz.

    #include <msp430.h>
    
    int main(void)
    {
      WDTCTL = WDTPW + WDTHOLD;                 // Stop Watchdog Timer
      if (CALBC1_16MHZ==0xFF)					// If calibration constant erased
      {											
        while(1);                               // do not load, trap CPU!!	
      }
      DCOCTL = 0;                               // Select lowest DCOx and MODx settings
      BCSCTL1 = CALBC1_16MHZ;                    // Set DCO to 16MHz
      DCOCTL = CALDCO_16MHZ;

    //rest of program....

    The thing to remember is that this process for setting the DCO to 16MHz will only work if it is executed after a device reset (PUC) because RSEL is still at its default value of 7. If the customer wants to change the speed of the DCO inside of their program, and not at the start of their program, then they will have to follow the workaround described in the Errata. There are different workarounds to keep in mind when they are going from RSEL >13 to <12 and RSEL <12 to >13. If the workarounds are followed then the customer can keep from experiencing the BCL12 dead time.

    Best regards,

    Matt Calvo

  • Matt,

    Thank you for your reply.

    Please forgivre my reconfirmation.

    If CALBC_16MHZ=15, it hits the BCS12 condition: "if all of the RSELx bits in the BSCTL1 register are set". But we don't have to care about it. in the next line we can change the DCOx or the MODx bits.

    (The bold words came from the errata document.)

    Is it correct ?

  • Hello,

    Don't worry about asking for clarification! The workaround section in the Errata is broken up into multiple sections. The chart on the top is referencing when the customer is switching RSEL from >13 to <12. The next paragraph is referencing switching RSEL from <12 to >13. The third paragraph is referencing the case where RSEL=15 (which would typically be the case if you are operating at 16MHz).

    If RSEL=15, the Errata states that you must reset it to its default value (RSEL=7) before accessing the DCOCTL to modify the DCOx and MODx bits. Thus, if the customer is running at 16MHz and wants to modify the DCOx and MODx bits, they must lower RSEL, modify the bits, then re-set RSEL to the desired value; all while following the guidelines of the Errata.

    In the case of the example provided, the 3 step process of clearing DCOCTL, loading BCSCTL1, and then loading DCOCTL only works if it is executed at the beginning of a device reset. Any other time you will have to follow the steps I described above.

    Best regards,

    Matt Calvo
  • Matt,
    Thank you very much. It helped me a lot.

**Attention** This is a public forum