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.

MSP432 Driverlib

Hello,


I use the MSP432 Lauchpad and I have problems to configure the timer_A with ACLK. I want to have every 4ms one timer interrupt, but the interrupts are much faster during dubugging. Here is the code:

    /////////////////////////////////////////////////////////////////////////////////////////////////////////
    //set up clock source

    GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_PJ,GPIO_PIN0 | GPIO_PIN1 | GPIO_PIN3 | GPIO_PIN4,        GPIO_PRIMARY_MODULE_FUNCTION);

    CS_setExternalClockSourceFrequency(32000,CS_48MHZ);

    PCM_setCoreVoltageLevel(PCM_VCORE1);
    FlashCtl_setWaitState(FLASH_BANK0, 2);
    FlashCtl_setWaitState(FLASH_BANK1, 2);

    CS_startHFXT(false);
    CS_startLFXT(CS_LFXT_DRIVE3);

    CS_initClockSignal(CS_MCLK,CS_HFXTCLK_SELECT,CS_CLOCK_DIVIDER_1);
    CS_initClockSignal(CS_ACLK,CS_LFXTCLK_SELECT,CS_CLOCK_DIVIDER_1);

    /////////////////////////////////////////////////////////////////////////////////////////////////////////
    //configurate the the Timer_A0 in up mode
    //every 4ms (250Hz) occurs an interrupt

    Timer_A_UpModeConfig Timer_A0_configuration;


    Timer_A0_configuration.clockSource = TIMER_A_CLOCKSOURCE_ACLK;
    Timer_A0_configuration.clockSourceDivider = TIMER_A_CLOCKSOURCE_DIVIDER_1;
    Timer_A0_configuration.timerPeriod = 123;
    Timer_A0_configuration.timerInterruptEnable_TAIE = TIMER_A_TAIE_INTERRUPT_DISABLE;
    Timer_A0_configuration.captureCompareInterruptEnable_CCR0_CCIE = TIMER_A_CCIE_CCR0_INTERRUPT_ENABLE;
    Timer_A0_configuration.timerClear = TIMER_A_SKIP_CLEAR;
    Timer_A_configureUpMode(TIMER_A0_MODULE, &Timer_A0_configuration);

    Timer_A_enableInterrupt(TIMER_A0_MODULE);

    Timer_A_startCounter(TIMER_A0_MODULE, TIMER_A_UP_MODE);

    //timer A0
    void (*functionPtr)(void);
    functionPtr = &TimerA0interrruptHandler;
    Interrupt_registerInterrupt(INT_TA0_N, functionPtr);
    Interrupt_enableInterrupt(INT_TA0_N);

  • Hello,

    Your initialization seems correct, are you making sure to clear the CCI flag inside of the ISR? Can you confirm the frequency of your LFXT crystal?

    Regards,
    Ryan
  • Hello Ryan,

    The clock crystal (32768) is the original from the MSP432 Launchpad. After clearing up fault flags in CS register, there aren't be new fault flags. I think the crystal works well. Now I use the Timer_32 with 48Mhz. This works well.

    Ryan Brown1 said:

    Your initialization seems correct, are you making sure to clear the CCI flag inside of the ISR?

    Yes I cleared the CCI flag in the interrupt handler routine.

    Regards,

    Emru

  • Hello Emru,

    The attached code properly uses Timer_A with ACLK to create an interrupt every 4 ms: 

    timer_a_upmode_gpio_toggle.c
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    /*
    * -------------------------------------------
    * MSP432 DriverLib - v2_20_00_08
    * -------------------------------------------
    *
    * --COPYRIGHT--,BSD,BSD
    * Copyright (c) 2014, Texas Instruments Incorporated
    * All rights reserved.
    *
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted provided that the following conditions
    * are met:
    *
    * * Redistributions of source code must retain the above copyright
    * notice, this list of conditions and the following disclaimer.
    *
    * * Redistributions in binary form must reproduce the above copyright
    * notice, this list of conditions and the following disclaimer in the
    * documentation and/or other materials provided with the distribution.
    *
    * * Neither the name of Texas Instruments Incorporated nor the names of
    * its contributors may be used to endorse or promote products derived
    * from this software without specific prior written permission.
    *
    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
    * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
    * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
    * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
    * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    * --/COPYRIGHT--*/
    /*******************************************************************************
    * MSP432 Toggle P1.0, Up Mode, LFXT ACLK
    *
    * Description: Toggle P1.0 using software and TA_0 ISR. Timer0_A is
    * configured for up mode, thus the timer overflows when TAR counts
    * to CCR0. In this example, CCR0 is loaded with 130 which makes the LED
    * toggle every four milliseconds..
    * ACLK = 32 kHz, MCLK = SMCLK = default DCO ~1MHz
    * TACLK = ACLK
    *
    * MSP432P401
    * -------------------
    * /|\| |
    * | | |
    * --|RST |
    * | |
    * | P1.0|-->LED
    * | |
    *
    * Author: Timothy Logan
    * Modifier: Ryan Brown
    *******************************************************************************/
    /* DriverLib Includes */
    #include "driverlib.h"
    /* Application Defines */
    #define TIMER_PERIOD 130
    /* Timer_A UpMode Configuration Parameter */
    const Timer_A_UpModeConfig upConfig =
    {
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Regards, Ryan

  • Hello Ryan,

    I see that I used a false function to clear the interrupt flag. Thank you very much.

    Best regards,
    Emru

**Attention** This is a public forum