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.

MSP430FR2355: How to calculate frequency of timers

Part Number: MSP430FR2355


Hello, 

I'm attempting to get some direction on how to calculate the frequency for the different timers on the MSP430FR2355. 

Here are the situations I'm looking for. 

  • RTC
    • I know this is using XT1CLK which is 32kh or ~32768
    • RTCMOD sets the interrupt timer in the sample code as 32-1 which is suppose to be 1hz / 1sec
    • So if I want 10 seconds is it as simple as 10*(32-1)?
  • Timer_B0
    • In the sample code it is using the ACLK which is also 32kh or ~32768
    • Timer B0 seems to have two modes I'm interested in
      • Continous Mode
        • counts up to a 8, 10, 12, or 16 BIT max value
        • I can use a divider to change the frequency
        • According to the sample code 16bit value for CNTL gives me a frequency of .5hz, once every 2 seconds. 
        • So how do I go about calculating for say 1 second or 10 seconds?
      • UpMode
        • seems to be the most straight forward. Simply counts up to a value set in CCR0 for the timer
        • sample code uses 50000 has an example with a SMCLK, which is ~1MHz, but it doesn't give me a frequency to reference to for the timer
        • So how would I calculate 1 sec or 10 or can I? It appears CCR0 is a 16bit reg, so the max is 65535 and was still way faster than I want. 

Any insight would be helpful. 

Michael 

  • > So if I want 10 seconds is it as simple as 10*(32-1)?

    Actually (10*32)-1. This supposes you have set RTCPS=7 (/1024) [Ref User Guide (SLAU445I) Table 15-2.]

    > Continuous Mode

    65536 counts / 32768 counts/sec = 2 seconds. Continuous mode has a fixed upper bound, so you can't get 1 second. You can get 10 seconds by setting TB0EX0=(5-1) [/5]: 65536 counts / (32768/5) counts/sec = 10 seconds.

    > UpMode

    As you say, the max CCR0 count is (65535+1), and 65536 counts / 1000000 counts/sec = 0.065536 seconds, or about 65.5ms. By setting ID=3 [/8] and TB0EX0=(8-1) [another /8] you can get as much as 65536 counts / (1000000/8/8) counts/sec = ~4.2 seconds. (To get 65536 counts, set CCR0=65536-1.)

  • Hey Bruce, 

    Ok this is what I was looking for.

    However, I was hoping for some clarification. I was messing with the Continuous mode and it seems I'm able to get 1 sec. 

    TB0CTL = TBSSEL_1 | CNTL_1 | MC_2 | ID_3 | TBCLR | TBIE;

    I set timer B0 controls to ACLK (32khz), counter lenght of FFF (4096), Continous mode, and divider /8.

    which based on your math I get

    Count / (Crystal / Divider)
    
    4096 / (32768 / 8)
    
    4096 / 4096 = 1 Sec

    Did I get that right? The blinking light seems to be at 1sec, but I was just hoping for some confirmation. 

    In either case thank you for your help. 

    Michael

  • You're right. That's what I get for doing the (12-bit) arithmetic in my head, rather than spelling it out the way you did.

  • Hi Michael,

    Haven’t heard from you for several days, so I’m assuming you were able to resolve your issue. If this isn’t the case, please click the "This did NOT resolve my issue" button and reply to this thread with more information. If this thread locks, please click the "Ask a related question" button and in the new thread describe the current status of your issue and any additional details you may have to assist us in helping to solve your issues.

**Attention** This is a public forum