Jump to content

Characterize DCO without 32.768 kHz xtal

Recommended Posts

This is a method to measure the DCO frequency by timing serial data.


The ASCII character 'x' has two falling edges that are 8 bit times apart. There are also two 4 bit times from falling to rising and rising to falling. At 9600 bps the time between edges will be 833.33 us. Counting the number of DCO clock ticks that occur between the falling clock edges will allow the DCO frequency to be calculated.




The stored DCO calibrations are shown and then frequency measurement begins. Each time the 'x' character is sent a line of info will be displayed.


RSEL - Range SELect - the lower four bits of BCSCTL1

DCO - All eight bits of DCOCTL

T - The count of DCO clock pulses

F - Calculated DCO frequency in kHz




The accuracy of the measurement is dependent on the accuracy of the serial data. Using the serial port of the Launchpad gave readings about 0.2% low. The SMCLK is output on P1.4 so a frequency counter can be used to determine how well this works.




Timer A capture is used to accurately count the DCO clock ticks between falling edges.


Code excerpt

   for(; {
                                           // --- Measure duration of 8 bits
       TACCTL1 &= ~CCIFG;                  // Clear capture flag
                                           // Wait for falling edge, check for S2 press
       while(!(TACCTL1 & CCIFG)) if(!(P1IN & BIT3)) { s2(); continue; }
       start = TACCR1;                     // Save captured start time
       TACCTL1 &= ~CCIFG;                  // Clear capture flag
       while(!(TACCTL1 & CCIFG));          // Wait for falling edge
       stop = TACCR1;                      // Save captured stop time

       duration = stop - start;            // Calculate duration of 8 bits
                                           // Calculate frequency
       freq = (unsigned)(((unsigned long)duration * 39322) >> 15);
                                           // Setup serial using measured bit duration
       serial_setup(BIT1, BIT2, duration >> 3);
                                           // Show info
       printf("RSEL: %u  DCO: %u  T: %u  F: %u kHz\r\n", (unsigned)(BCSCTL1 & 0x0F), (unsigned)DCOCTL, duration, freq);
                                           // Increment DCO


Link to post
Share on other sites
  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...