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.
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 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:
/* * ------------------------------------------- * 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 = { TIMER_A_CLOCKSOURCE_ACLK, // ACLK Clock Source TIMER_A_CLOCKSOURCE_DIVIDER_1, // ACLK/1 = 32 kHz TIMER_PERIOD, // 4 ms period TIMER_A_TAIE_INTERRUPT_DISABLE, // Disable Timer interrupt TIMER_A_CCIE_CCR0_INTERRUPT_ENABLE , // Enable CCR0 interrupt TIMER_A_DO_CLEAR // Clear value }; int main(void) { /* Stop WDT */ MAP_WDT_A_holdTimer(); /* Configuring P1.0 as output */ MAP_GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0); MAP_GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0); /* Initializing ACLK to LFXT (effectively 32khz) */ MAP_CS_initClockSignal(CS_ACLK, CS_LFXTCLK_SELECT, CS_CLOCK_DIVIDER_1); /* Configuring Timer_A1 for Up Mode */ MAP_Timer_A_configureUpMode(TIMER_A1_MODULE, &upConfig); /* Enabling interrupts and starting the timer */ MAP_Interrupt_enableSleepOnIsrExit(); MAP_Interrupt_enableInterrupt(INT_TA1_0); MAP_Timer_A_startCounter(TIMER_A1_MODULE, TIMER_A_UP_MODE); /* Enabling MASTER interrupts */ MAP_Interrupt_enableMaster(); /* Sleeping when not in use */ while (1) { MAP_PCM_gotoLPM0(); } } void timer_a_0_isr(void) { MAP_GPIO_toggleOutputOnPin(GPIO_PORT_P1, GPIO_PIN0); MAP_Timer_A_clearCaptureCompareInterrupt(TIMER_A1_MODULE, TIMER_A_CAPTURECOMPARE_REGISTER_0); }
Regards, Ryan
**Attention** This is a public forum