Quantcast
Channel: MSP430 Technical Forums
Viewing all articles
Browse latest Browse all 2077

MSP430 LaunchPad, DriverLib, TIMER_A and CCR0 Duration

$
0
0

Hello,

 

I am trying to determine the frequency of the TIMER_A with a given Capture/Control Register 0 (CCR0) value 0.

 

My understanding is that the frequency is (SMCLK)* (1/CLOCKSOURCE_DIVIDER)*(1/Number of Cycles)

 

My configuration:

  • Clock source is SMCLK.  SMCLK frequency is 8MHz (1),
  • CCR0 value is 50000 decimal (0xC350).
  • TIMER_A is set in continuous mode (TIMER_A_CONTINUOUS_MODE)
  • "timer_a_ex2_continous ModeOperationWithCCR-Interrupt"
    • Src: MSP430ware/Libraries/Driver Library/MSP430F5xx_6xx/Example Projects/TIMER_A
    • The only change I made is this: replaced TIMER_A_CLOCKSOURCE_DIVIDER_1 with TIMER_A_CLOCKSOURCE_DIVIDER_16.

f =  (8 MHz)*(1/TIMER_A_CLOCKSOURCE_DIVIDER_16)*(1/50000) = 10Hz

 

When I execute the code I see the LED blink on and off with an estimated frequency of 0.80s.  I am using a simple timer on my phone to estimate the frequency.

 

Looks like I am off by one order of magnitude...

What am I missing?

I appreciate any help from the community?

 

With kind regards,

Electric Cowboy

 

References:

(1) - "slau533b - MSP-EXP430F5529LP User's Guide.pdf" - page 45/61

(2) - "slau390c - Unified Clock System.pdf", Figure 1-1 UCS Block Diagram - page 3/29.

 

 

Code excerpt:

 

        #define COMPARE_VALUE 50000 // Valid range is 16-bits 0x0000 (0d) to 0xFFFF (65535d)

 

        //Start timer in continuous mode sourced by SMCLK
        TIMER_A_configureContinuousMode( TIMER_A1_BASE,
                                         TIMER_A_CLOCKSOURCE_SMCLK,
                                         TIMER_A_CLOCKSOURCE_DIVIDER_16, // Here I changed from "..._1" to "..._16"
                                         TIMER_A_TAIE_INTERRUPT_DISABLE,
                                         TIMER_A_DO_CLEAR
                                         );

 

        //Initiaze compare mode
        TIMER_A_clearCaptureCompareInterruptFlag(TIMER_A1_BASE,
                                                 TIMER_A_CAPTURECOMPARE_REGISTER_0
                                                 );
        TIMER_A_initCompare(TIMER_A1_BASE,
                            TIMER_A_CAPTURECOMPARE_REGISTER_0,
                            TIMER_A_CAPTURECOMPARE_INTERRUPT_ENABLE,
                            TIMER_A_OUTPUTMODE_OUTBITVALUE,
                            COMPARE_VALUE
                            );

        TIMER_A_startCounter( TIMER_A1_BASE,
                              TIMER_A_CONTINUOUS_MODE
                              );

 

 

 


Viewing all articles
Browse latest Browse all 2077

Trending Articles