Black Box with a View, Part 2
Subject:   timing
Date:   2006-03-01 02:54:00
From:   bartvan deenen
Hi George

I've tried both clock sources, and still can't really figure out the interrupt frequency I'm getting. I'm now at ACLK, being LFXT1CLK/8. A Readback on BCSCTL1 reads C4, which fits. I should be getting 1MHz on ACTL, so with a TIMER_PERIOD of 10000 I should be getting interrupts a 100 Hz. I am getting interrupts at 1236 Hz, so I'm still missing something somewhere.
Anyway this is all part of the fun :-) I hope you're doing some tcp stuff in the next installment.

Full Threads Oldest First

Showing messages 1 through 5 of 5.

  • timing
    2006-03-01 03:55:38  bartvan deenen [View]

    Found my timing problem. There is a bug in timera.h, where ID_DIV8 is (3<<6) and it should be (3<<4). So i set the wrong bits. My time measurement wasn't very accurate, the 1236Hz should have been 800 Hz.

    I'm also using the bit of code from page 4-12 of the user guide. My code is now:

    void LED_Timer_Init(int* ignore, struct _LED* const ledp) {

    if (_ledp) {

    _ledp = ledp;

    _BIC_SR(OSCOFF); // turn on oscillator
    BCSCTL1 |= XTS; // high frequency
    do {
    IFG1 &= ~OFIFG;
    volatile unsigned char i;
    } while ( IFG1 & OFIFG );
    BCSCTL2 |= SELM1 | SELM0 | BIT3;
    BCSCTL1 &= ~(BIT4 | BIT5);
    BCSCTL1 |= BIT5 | BIT4;
    TACCR0 = 0;


    • timing
      2006-03-01 10:39:07  georgebelotsky [View]

      Actually, timera.h looks correct.

      3 << 6 = 0xC0
      = 0x80 + 0x40
      ... which is bits 7 and 6 set

      From page 11-20 of the

        MSP430x1xx Family User's Guide
      , the IDx bits (which control input clock divider) are 7 and 6 -- if both are set, the clock is divided by 8.

      Also, several of TI's code examples -- such as fet140_ta_09.c -- illustrates the use of the ACLK with an HF crystal.

      Best Wishes,

      • timing
        2006-03-01 11:58:52  bartvan deenen [View]

        Huh, the User Guide shows on page 4-15 the DIVAx bits of BCSCTL1 to be bits 4 and 5
        • timing
          2006-03-01 12:00:52  bartvan deenen [View]

          Oh I see
          I was dividing the ACLK, and there is another divider for Timer A. Complicated all these timers.

          • timing
            2006-03-01 18:11:06  georgebelotsky [View]

            Yes, configuring the hardware can be error prone.

            Particularly, watch out for the convenience macros that define symbolic names for various bits. The macros are helpful, but there is nothing to prevent you applying them to the wrong register.

            Try TI's examples as a starting point when dealing with MSP430 features that are new to you. You can be reasonably sure that they are setting up the microcontroller correctly.

            Get the example to run first, then use it as a guide to build your own device driver for the hardware in question.

            Best Wishes,